From 566ad4d08181681327cbdf7dac4cc9878c4ba774 Mon Sep 17 00:00:00 2001 From: PathGao Date: Sat, 1 Aug 2026 12:42:42 +0800 Subject: [PATCH] test: refresh stale toolbar UI contracts --- scripts/reloadOpenToolbar.test.ts | 6 +++--- scripts/toolbarCustomizationWiring.test.ts | 24 +++++++++------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/scripts/reloadOpenToolbar.test.ts b/scripts/reloadOpenToolbar.test.ts index b7830656..6c2ed434 100644 --- a/scripts/reloadOpenToolbar.test.ts +++ b/scripts/reloadOpenToolbar.test.ts @@ -24,10 +24,10 @@ test('preview-level open shortcut handles Ctrl/Cmd+O outside Monaco without doub assert.match(markdownViewer, /cmdOrCtrl[\s\S]*key === 'o'[\s\S]*selectFile\(\)/); }); -test('editor toolbar delegates to Monaco actions and exposes expected Markdown commands', () => { +test('editor toolbar delegates actions and optional payloads to Monaco', () => { assert.match(markdownViewer, /import EditorToolbar from '\.\/components\/EditorToolbar\.svelte'/); - assert.match(markdownViewer, / editorPane\?\.runEditorAction\(actionId\)\}/); - assert.match(editor, /export function runEditorAction\(actionId: string\)/); + assert.match(markdownViewer, / editorPane\?\.runEditorAction\(actionId, payload\)\}/); + assert.match(editor, /export function runEditorAction\(actionId: string, payload\?: any\)/); for (const actionId of [ 'fmt-bold', diff --git a/scripts/toolbarCustomizationWiring.test.ts b/scripts/toolbarCustomizationWiring.test.ts index 1af4c54a..483292df 100644 --- a/scripts/toolbarCustomizationWiring.test.ts +++ b/scripts/toolbarCustomizationWiring.test.ts @@ -78,21 +78,17 @@ test('settings modal does not light-dismiss when clicking the backdrop', () => { assert.doesNotMatch(settingsComponent, /function handleBackdropClick[\s\S]*onclose\(\)/); }); -test('toolbar settings use collapsed accordions for application and editor toolbars', () => { - const accordionBlocks = Array.from(settingsComponent.matchAll(//g)); - - assert.equal(accordionBlocks.length, 2); - assert.match(accordionBlocks[0][0], /settings\.applicationToolbar/); - assert.match(accordionBlocks[1][0], /settings\.editorToolbar/); - assert.match(accordionBlocks[0][0], //); - assert.match(accordionBlocks[1][0], //); - assert.match(accordionBlocks[0][0], /class="toolbar-settings-chevron"/); - assert.match(accordionBlocks[1][0], /class="toolbar-settings-chevron"/); - for (const block of accordionBlocks) { - assert.doesNotMatch(block[0], /]*\sopen(?:[\s=>]|$)/); +test('toolbar settings expose application and editor sections', () => { + const sectionBlocks = Array.from(settingsComponent.matchAll(/
\s*<\/div>/g)); + + assert.equal(sectionBlocks.length, 2); + assert.match(sectionBlocks[0][0], /settings\.applicationToolbar/); + assert.match(sectionBlocks[1][0], /settings\.editorToolbar/); + for (const block of sectionBlocks) { + assert.match(block[0], /class="toolbar-section-header"/); + assert.match(block[0], /class="toolbar-settings-list" role="list"/); } - assert.match(settingsComponent, /\.toolbar-settings\[open\]\s+\.toolbar-settings-chevron/); - assert.match(settingsComponent, /\.toolbar-settings-summary::-webkit-details-marker/); + assert.doesNotMatch(settingsComponent, /toolbar-settings-accordion/); }); test('interactive button labels are directly translated for every supported language', () => {