diff --git a/e2e/config-workspace.spec.ts b/e2e/config-workspace.spec.ts index 4326fa75..ff6bd04f 100644 --- a/e2e/config-workspace.spec.ts +++ b/e2e/config-workspace.spec.ts @@ -19,6 +19,7 @@ test('modules are summaries with one link to each editor', async ({page}) => { ]) { const card = modules.getByRole('region', {name: section, exact: true}); await expect(card.getByRole('button', {name: 'Edit', exact: true})).toHaveCount(0); + await expect(card.locator('.rp-light.info')).toHaveCount(0); await card.getByRole('link', {name: 'Open page'}).click(); await expect(page).toHaveURL(new RegExp('#/' + path)); if (section === 'global') await expect(page.getByRole('region', {name: 'Persistent global settings'})).toBeInViewport(); @@ -68,6 +69,7 @@ test('legacy validation links focus diagnostics beside the source at its line', await expect(page.getByRole('tab', {name: 'Config files', exact: true})).toHaveAttribute('aria-selected', 'true'); await expect(page.getByRole('tab', {name: 'Validation', exact: true})).toHaveCount(0); await expect(page.getByRole('region', {name: 'Diagnostics', exact: true})).toBeFocused(); + await expect(page.getByRole('region', {name: 'Diagnostics', exact: true})).toBeInViewport(); await expect(page.locator('.cm-activeLine')).toContainText('tproxy_port:'); await expect(page.getByRole('list', {name: 'Diagnostics'})).toHaveCount(1); }); @@ -179,9 +181,20 @@ test('global controls share widths and align beneath wrapped labels', async ({pa elements.map(element => { const outer = element.getBoundingClientRect(); const control = element.querySelector('.rp-input, .rp-selectbtn')!.getBoundingClientRect(); - return {row: outer.top, top: control.top, width: control.width, height: control.height}; + const label = element.querySelector('label')!; + const range = document.createRange(); + range.selectNodeContents(label); + return {row: outer.top, top: control.top, width: control.width, height: control.height, labelLines: range.getClientRects().length}; }) ); + if (width === 390) expect.soft(fields.every(field => field.labelLines === 1)).toBe(true); + await expect.soft(page.locator('[data-setting] > .rp-field[style*="width"]')).toHaveCount(0); + const notes = page.getByRole('region', {name: 'Temporary runtime overrides'}).locator('.rp-fieldgrid > .rp-label'); + await expect(notes).toHaveCount(2); + for (const note of await notes.all()) + expect + .soft(await note.evaluate(element => element.getBoundingClientRect().width / element.parentElement!.getBoundingClientRect().width)) + .toBeGreaterThan(0.99); expect(Math.max(...fields.map(field => field.width)) - Math.min(...fields.map(field => field.width))).toBeLessThanOrEqual(1); for (const row of new Set(fields.map(field => field.row))) { const controls = fields.filter(field => field.row === row); @@ -270,6 +283,36 @@ for (const mode of ['validation', 'restart'] as const) { await expect(card).toContainText(mode === 'restart' ? '1 setting takes effect only after a restart; nothing written' : 'Validation found 1 error'); }); } +test('diagnostic source actions show a button and open the named file', async ({page}) => { + await mockBackend(page, {faults: true}); + await page.goto('/#/config?tab=validate'); + const action = page + .getByRole('region', {name: 'Diagnostics', exact: true}) + .getByRole('button', {name: /Open.*rules.dae/}) + .first(); + await expect(action).toBeVisible(); + await expect(action).not.toHaveClass(/quiet/); + await expect(action).toContainText('Open'); + await action.click(); + await expect(page).toHaveURL(/source=src-rules/); +}); + +for (const width of [390, 1440]) { + test(`accepted diagnostics retain focus and provenance with redacted sources at ${width}px`, async ({page}) => { + await page.setViewportSize({width, height: 1000}); + const {api, handlers} = await mockBackend(page, {faults: true}); + const config = await api.config(); + config.sources[0].content = ''; + handlers['GET config'] = async () => config; + await page.goto('/#/config?tab=validate'); + const panel = page.getByRole('region', {name: 'Diagnostics', exact: true}); + await expect(panel).toBeFocused(); + await expect(panel).toBeInViewport(); + await expect(panel).toContainText('accepted configuration'); + await expect(panel.getByRole('listitem').first()).toBeVisible(); + await expect(panel).not.toContainText('Current config file diagnostics'); + }); +} test('invalid stored hex ports remain visible and can be corrected', async ({page}) => { const {api, handlers} = await mockBackend(page); diff --git a/src/features/config/Modules.tsx b/src/features/config/Modules.tsx index 877426cc..77a84f9d 100644 --- a/src/features/config/Modules.tsx +++ b/src/features/config/Modules.tsx @@ -29,7 +29,7 @@ export function Modules(props: ModulesProps) { )} {card.summary && ( - + {card.summary} )} diff --git a/src/features/config/SourceCard.tsx b/src/features/config/SourceCard.tsx index 57a2cc7e..8cee3422 100644 --- a/src/features/config/SourceCard.tsx +++ b/src/features/config/SourceCard.tsx @@ -144,8 +144,8 @@ export function SourceCard(props: SourceCardProps) { {item.detail} - ))} diff --git a/src/features/config/useConfigPage.ts b/src/features/config/useConfigPage.ts index c4f0ef63..66a9ff8e 100644 --- a/src/features/config/useConfigPage.ts +++ b/src/features/config/useConfigPage.ts @@ -97,7 +97,7 @@ export function useConfigPage({go, query}: PageProps) { editor, focusLine, generation: config.data?.generation_id ?? '', - focusDiagnostics: params.get('tab') === 'validate' || params.get('panel') === 'diagnostics' + focusDiagnostics: params.get('tab') === 'validate' } : null; const newSourceProps: NewSourceProps | null = diff --git a/src/features/config/view.test.ts b/src/features/config/view.test.ts index 27ec69e8..7c09462b 100644 --- a/src/features/config/view.test.ts +++ b/src/features/config/view.test.ts @@ -323,3 +323,7 @@ it('prefers reported source reasons over inferred credentials and falls back for } expect(readOnlyBadge({...source, read_only_reason: 'future' as never}, true, true, honk, t)?.reason).toBe('secret'); }); + +it('does not invent a source filename when no main file exists', () => { + expect(sectionSummaries([], honk, 'en', t).every(card => card.range === '')).toBe(true); +}); diff --git a/src/features/config/view.ts b/src/features/config/view.ts index fdafdf42..be800cf8 100644 --- a/src/features/config/view.ts +++ b/src/features/config/view.ts @@ -149,7 +149,7 @@ export function sectionSummaries(sources: ConfigSource[], engine: Engine, lang: source: main, block: null, href, - range: main ? fileName(main) : 'config.dae', + range: main ? fileName(main) : '', // Only a writable main file is offered as the place to add the section. summary: main?.writable ? t('config.moduleAbsent', {file: fileName(main)}) : t('config.moduleAbsentReadOnly'), note: null diff --git a/src/features/settings/GlobalSettings.tsx b/src/features/settings/GlobalSettings.tsx index 0faf78c8..9fe9e4ac 100644 --- a/src/features/settings/GlobalSettings.tsx +++ b/src/features/settings/GlobalSettings.tsx @@ -46,7 +46,6 @@ export function GlobalSettings(props: PageProps) { * { - width: auto !important; - min-width: 0; - } - .rp-fieldgrid :is(.rp-field > label, .lbl) { - min-height: 32px; - } - .rp-fieldgrid :is(.rp-input, .rp-selectbtn) { - width: 100%; - } - .rp-fieldgrid > .rp-label { - grid-column: 1 / -1; - } +.rp-fieldgrid > .rp-label { + grid-column: 1 / -1; } /* A searchable picker's popover spans its trigger, as a picker's list does; the virtual rows cannot size it. */