Skip to content

Commit a4d91c8

Browse files
committed
Prove Cowork selection preservation portably
Signed-off-by: Joseph Yaksich <gitcommit90@users.noreply.github.com>
1 parent 2803266 commit a4d91c8

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

test/brief-regressions-browser.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,13 @@ try {
145145
sameNode: editor === window.__briefNoteEditor,
146146
value: [...document.querySelectorAll('[aria-label="Notes editor"] .cm-line')].map((line) => line.textContent).join("\n"),
147147
focused: document.activeElement === editor,
148-
selection: window.getSelection()?.toString(),
149148
};
150149
});
151-
ok(durableNote.sameNode && durableNote.value.endsWith("Unsaved words survive.") && durableNote.focused && durableNote.selection === "Durable",
152-
"shell refreshes preserve the exact note editor node, unsaved draft, focus, and selection");
150+
ok(durableNote.sameNode && durableNote.value === "# Durable note\n\nStart here.\n\nUnsaved words survive." && durableNote.focused,
151+
"shell refreshes preserve the exact note editor node, unsaved draft, and focus");
152+
await page.keyboard.type("Steady");
153+
ok(await page.$eval('[aria-label="Notes editor"] .cm-content', (editor) => editor.textContent.startsWith("# Steady note") && editor.textContent.endsWith("Unsaved words survive.")),
154+
"shell refreshes preserve the authoritative CodeMirror selection");
153155
await page.evaluate(() => [...document.querySelectorAll('.cowork-editor-toolbar button')].find((button) => button.textContent?.trim() === "Preview")?.click());
154156
await page.waitForSelector('.cowork-markdown-preview:not(.hidden)');
155157
ok(await page.$eval('.cowork-markdown-preview', (element) => /Unsaved words survive/.test(element.textContent)), "Cowork note preview renders the current unsaved Markdown draft");

test/cowork-browser.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,11 @@ test("Cowork, Files, Quick Note, Markdown, and mobile continuity work as one fil
140140
await page.waitForFunction(() => document.querySelector('[aria-label="Notes editor"] .cm-content') === window.__coworkEditor);
141141
const continuity = await page.evaluate(() => {
142142
const editor = document.querySelector('[aria-label="Notes editor"] .cm-content');
143-
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() };
143+
return { same: editor === window.__coworkEditor, focused: document.activeElement === editor, lines: [...document.querySelectorAll('[aria-label="Notes editor"] .cm-line')].map((line) => line.textContent) };
144144
});
145-
assert.deepEqual(continuity, { same: true, focused: true, lines: ["# Field notes", "", "**Goal**", "", "Unsaved continuity proof."], selection: "ield not" });
145+
assert.deepEqual(continuity, { same: true, focused: true, lines: ["# Field notes", "", "**Goal**", "", "Unsaved continuity proof."] });
146+
await page.keyboard.type("PRESERVED");
147+
assert.deepEqual(await page.$$eval('[aria-label="Notes editor"] .cm-line', (lines) => lines.map((line) => line.textContent)), ["# FPRESERVEDes", "", "**Goal**", "", "Unsaved continuity proof."]);
146148
await page.keyboard.down(primaryModifier); await page.keyboard.press("s"); await page.keyboard.up(primaryModifier);
147149
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");
148150

0 commit comments

Comments
 (0)