Skip to content

Commit 401cb59

Browse files
committed
fix(spec): the dashboard settings hints read in business terms
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzh1FMUQYf1PcEunaaK
1 parent 573a376 commit 401cb59

2 files changed

Lines changed: 105 additions & 9 deletions

File tree

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* #36816 — the dashboard settings panel's hints are written for the person
5+
* building the dashboard, not for a developer.
6+
*
7+
* The console renders `dashboardForm` from the bundled spec, and an English
8+
* console shows each row's `helpText` exactly as written here (there is no
9+
* `en` overlay). Before this card nine of those hints spoke developer
10+
* vocabulary: a casing convention ("snake_case unique identifier"), a CSS
11+
* length ("in steps of 0.25rem (4 = 1rem)"), and "config".
12+
*
13+
* What is pinned is the KIND of text, never a sentence: each rewritten row
14+
* still declares a hint, and no hint anywhere in the form reaches for that
15+
* vocabulary. The control proves the vocabulary test can fire, against the
16+
* hints as they read before the rewrite.
17+
*/
18+
19+
import { describe, it, expect } from 'vitest';
20+
21+
import { dashboardForm } from './dashboard.form';
22+
23+
type FormField = { field?: string; helpText?: string; fields?: FormField[] };
24+
25+
/** Developer vocabulary a dashboard builder cannot act on. */
26+
const DEVELOPER_VOCABULARY = /tailwind|\d\s*(?:rem|px|em)\b|snake_case|camel_?case|kebab-case|\bconfig\b/i;
27+
28+
/** The rows this card rewrote, by dot path from the form root. */
29+
const REWRITTEN_ROWS = [
30+
'name',
31+
'label',
32+
'columns',
33+
'gap',
34+
'refreshIntervalSeconds',
35+
'header',
36+
'widgets',
37+
'dateRange',
38+
'globalFilters',
39+
] as const;
40+
41+
/** The hints those rows carried before, the control's population. */
42+
const PRE_REWRITE_HINTS = [
43+
'snake_case unique identifier',
44+
'Space between widgets, in steps of 0.25rem (4 = 1rem)',
45+
'Dashboard header config (title, subtitle, actions)',
46+
];
47+
48+
/** Every declared field of the form with its dot path, nested rows included. */
49+
function allFields(): Array<{ path: string; field: FormField }> {
50+
const out: Array<{ path: string; field: FormField }> = [];
51+
const walk = (fields: FormField[] | undefined, prefix: string) => {
52+
for (const f of fields ?? []) {
53+
if (!f?.field) continue;
54+
const path = prefix ? `${prefix}.${f.field}` : f.field;
55+
out.push({ path, field: f });
56+
walk(f.fields, path);
57+
}
58+
};
59+
for (const section of (dashboardForm.sections ?? []) as Array<{ fields?: FormField[] }>) {
60+
walk(section.fields, '');
61+
}
62+
return out;
63+
}
64+
65+
function row(path: string): FormField {
66+
const hit = allFields().find((f) => f.path === path);
67+
if (!hit) throw new Error(`dashboardForm declares no row \`${path}\``);
68+
return hit.field;
69+
}
70+
71+
describe('#36816 — dashboard settings hints read in business terms', () => {
72+
it('control: the vocabulary test fires on the hints as they read before', () => {
73+
for (const hint of PRE_REWRITE_HINTS) {
74+
expect(hint, hint).toMatch(DEVELOPER_VOCABULARY);
75+
}
76+
});
77+
78+
for (const path of REWRITTEN_ROWS) {
79+
it(`\`${path}\` declares a hint free of developer vocabulary`, () => {
80+
const hint = row(path).helpText;
81+
expect(typeof hint, `${path}.helpText`).toBe('string');
82+
expect(hint!.trim().length, `${path}.helpText is empty`).toBeGreaterThan(0);
83+
expect(hint).not.toMatch(DEVELOPER_VOCABULARY);
84+
});
85+
}
86+
87+
it('no hint anywhere in the form uses developer vocabulary', () => {
88+
const hinted = allFields().filter(({ field }) => typeof field.helpText === 'string');
89+
// Non-vacuity: the sweep sees at least the rows rewritten here.
90+
expect(hinted.length).toBeGreaterThanOrEqual(REWRITTEN_ROWS.length);
91+
const offenders = hinted
92+
.filter(({ field }) => DEVELOPER_VOCABULARY.test(field.helpText!))
93+
.map(({ path, field }) => `${path}: ${field.helpText}`);
94+
expect(offenders).toEqual([]);
95+
});
96+
});

‎packages/spec/src/ui/dashboard.form.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export const dashboardForm = defineForm({
1111
description: 'Dashboard identity and description.',
1212
columns: 2,
1313
fields: [
14-
{ field: 'name', type: 'text', required: true, colSpan: 1, helpText: 'snake_case unique identifier' },
15-
{ field: 'label', type: 'text', required: true, colSpan: 1, helpText: 'Display name' },
14+
{ field: 'name', type: 'text', required: true, colSpan: 1, helpText: 'A unique internal name for this dashboard: lowercase letters, numbers and underscores, starting with a letter (for example sales_overview).' },
15+
{ field: 'label', type: 'text', required: true, colSpan: 1, helpText: 'The title people see for this dashboard.' },
1616
{ field: 'description', type: 'textarea', colSpan: 2 },
1717
],
1818
},
@@ -21,14 +21,14 @@ export const dashboardForm = defineForm({
2121
description: 'Grid sizing and refresh cadence.',
2222
columns: 3,
2323
fields: [
24-
{ field: 'columns', type: 'number', colSpan: 1, helpText: 'Grid columns (default 12)' },
25-
{ field: 'gap', type: 'number', colSpan: 1, helpText: 'Space between widgets, in steps of 0.25rem (4 = 1rem)' },
26-
{ field: 'refreshIntervalSeconds', type: 'number', colSpan: 1, helpText: 'Auto-refresh (seconds)' },
24+
{ field: 'columns', type: 'number', colSpan: 1, helpText: 'How many columns the widgets are laid out on, from 1 to 24. Leave it empty and the dashboard picks a width that fits its widgets.' },
25+
{ field: 'gap', type: 'number', colSpan: 1, helpText: 'How much space to leave between widgets. Larger numbers spread them further apart; leave it empty for the standard spacing.' },
26+
{ field: 'refreshIntervalSeconds', type: 'number', colSpan: 1, helpText: 'How often the dashboard reloads its data, in seconds. Leave it empty or enter 0 to turn automatic reloading off.' },
2727
{
2828
field: 'header',
2929
type: 'composite',
3030
colSpan: 3,
31-
helpText: 'Dashboard header config (title, subtitle, actions)',
31+
helpText: 'What shows at the top of the dashboard: its title, its description and action buttons.',
3232
// The children are ENUMERATED (#16458) so `os i18n extract` emits a
3333
// `metadataForms.dashboard.fields['header.<child>']` key for each one
3434
// and the platform catalogs can name them. All three — the console
@@ -67,7 +67,7 @@ export const dashboardForm = defineForm({
6767
field: 'widgets',
6868
type: 'repeater',
6969
required: true,
70-
helpText: 'Dashboard widgets with position and sizing',
70+
helpText: 'The charts, numbers and tables on this dashboard, and where each one sits.',
7171
// Row-property names (#17508): every authorable row property, `label`
7272
// equal to the item schema's `.meta({ title })`, so `os i18n extract`
7373
// emits a catalog key per column and the panel keeps its schema-derived
@@ -100,11 +100,11 @@ export const dashboardForm = defineForm({
100100
collapsible: true,
101101
collapsed: true,
102102
fields: [
103-
{ field: 'dateRange', type: 'composite', helpText: 'Default date range selector' },
103+
{ field: 'dateRange', type: 'composite', helpText: 'The period the dashboard opens with, and whether viewers may pick their own dates.' },
104104
{
105105
field: 'globalFilters',
106106
type: 'repeater',
107-
helpText: 'Filters applied to all widgets',
107+
helpText: 'Filters viewers can use to narrow every widget at once, or only the widgets you choose.',
108108
// Row-property names (#17508): every authorable row property, `label`
109109
// equal to the item schema's `.meta({ title })`, so `os i18n extract`
110110
// emits a catalog key per column and the panel keeps its schema-derived

0 commit comments

Comments
 (0)