diff --git a/test/brief-regressions-browser.mjs b/test/brief-regressions-browser.mjs index 1f96da4..3201199 100644 --- a/test/brief-regressions-browser.mjs +++ b/test/brief-regressions-browser.mjs @@ -145,11 +145,13 @@ try { sameNode: editor === window.__briefNoteEditor, value: [...document.querySelectorAll('[aria-label="Notes editor"] .cm-line')].map((line) => line.textContent).join("\n"), focused: document.activeElement === editor, - selection: window.getSelection()?.toString(), }; }); - ok(durableNote.sameNode && durableNote.value.endsWith("Unsaved words survive.") && durableNote.focused && durableNote.selection === "Durable", - "shell refreshes preserve the exact note editor node, unsaved draft, focus, and selection"); + ok(durableNote.sameNode && durableNote.value === "# Durable note\n\nStart here.\n\nUnsaved words survive." && durableNote.focused, + "shell refreshes preserve the exact note editor node, unsaved draft, and focus"); + await page.keyboard.type("Steady"); + ok(await page.$eval('[aria-label="Notes editor"] .cm-content', (editor) => editor.textContent.startsWith("# Steady note") && editor.textContent.endsWith("Unsaved words survive.")), + "shell refreshes preserve the authoritative CodeMirror selection"); await page.evaluate(() => [...document.querySelectorAll('.cowork-editor-toolbar button')].find((button) => button.textContent?.trim() === "Preview")?.click()); await page.waitForSelector('.cowork-markdown-preview:not(.hidden)'); ok(await page.$eval('.cowork-markdown-preview', (element) => /Unsaved words survive/.test(element.textContent)), "Cowork note preview renders the current unsaved Markdown draft"); diff --git a/test/cowork-browser.mjs b/test/cowork-browser.mjs index 9aefcaf..232419c 100644 --- a/test/cowork-browser.mjs +++ b/test/cowork-browser.mjs @@ -140,9 +140,11 @@ test("Cowork, Files, Quick Note, Markdown, and mobile continuity work as one fil await page.waitForFunction(() => document.querySelector('[aria-label="Notes editor"] .cm-content') === window.__coworkEditor); const continuity = await page.evaluate(() => { const editor = document.querySelector('[aria-label="Notes editor"] .cm-content'); - return { same: editor === window.__coworkEditor, focused: document.activeElement === editor, lines: [...document.querySelectorAll('[aria-label="Notes editor"] .cm-line')].map((line) => line.textContent), selection: window.getSelection()?.toString() }; + return { same: editor === window.__coworkEditor, focused: document.activeElement === editor, lines: [...document.querySelectorAll('[aria-label="Notes editor"] .cm-line')].map((line) => line.textContent) }; }); - assert.deepEqual(continuity, { same: true, focused: true, lines: ["# Field notes", "", "**Goal**", "", "Unsaved continuity proof."], selection: "ield not" }); + assert.deepEqual(continuity, { same: true, focused: true, lines: ["# Field notes", "", "**Goal**", "", "Unsaved continuity proof."] }); + await page.keyboard.type("PRESERVED"); + assert.deepEqual(await page.$$eval('[aria-label="Notes editor"] .cm-line', (lines) => lines.map((line) => line.textContent)), ["# FPRESERVEDes", "", "**Goal**", "", "Unsaved continuity proof."]); await page.keyboard.down(primaryModifier); await page.keyboard.press("s"); await page.keyboard.up(primaryModifier); await waitFor(async () => (await api(`/api/channels/${channel.id}/files/text?path=notes%2Ffield-notes.md`, {}, token)).file.content.includes("Unsaved continuity proof"), "saved Cowork note");