Skip to content

Commit baf3dfc

Browse files
committed
Make Cowork editor tests Mac-native
Signed-off-by: Joseph Yaksich <gitcommit90@users.noreply.github.com>
1 parent 41ba986 commit baf3dfc

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

test/brief-regressions-browser.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { rmSync, writeFileSync } from "node:fs";
44
import { join } from "node:path";
55
import puppeteer from "puppeteer";
66

7+
const primaryModifier = process.platform === "darwin" ? "Meta" : "Control";
8+
79
const root = process.cwd();
810
const dataDir = join(root, ".native-test-data", `brief-browser-${process.pid}`);
911
const freePort = () => new Promise((resolve, reject) => {
@@ -124,10 +126,10 @@ try {
124126
await page.evaluate(() => [...document.querySelectorAll('[data-cowork-files] button')].find((button) => button.textContent?.includes("Quiet refresh proof.md"))?.click());
125127
await page.waitForFunction(() => document.querySelector('[aria-label="Notes editor"] .cm-content')?.textContent.includes("Start here"));
126128
await page.click('[aria-label="Notes editor"] .cm-content');
127-
await page.keyboard.down("Control"); await page.keyboard.press("End"); await page.keyboard.up("Control");
129+
await page.keyboard.down(primaryModifier); await page.keyboard.press("a"); await page.keyboard.up(primaryModifier); await page.keyboard.press("ArrowRight");
128130
await page.keyboard.type("\n\nUnsaved words survive.");
129131
await page.click('[aria-label="Notes editor"] .cm-line');
130-
await page.keyboard.press("Home");
132+
await page.keyboard.down(primaryModifier); await page.keyboard.press("a"); await page.keyboard.up(primaryModifier); await page.keyboard.press("ArrowLeft");
131133
for (let index = 0; index < 2; index++) await page.keyboard.press("ArrowRight");
132134
await page.keyboard.down("Shift"); for (let index = 0; index < 7; index++) await page.keyboard.press("ArrowRight"); await page.keyboard.up("Shift");
133135
await page.evaluate(() => {

test/cowork-browser.mjs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ async function browserExecutable() {
2020
}
2121

2222
const executablePath = await browserExecutable();
23+
const primaryModifier = process.platform === "darwin" ? "Meta" : "Control";
2324
const freePort = () => new Promise((resolve, reject) => {
2425
const server = createServer(); server.once("error", reject);
2526
server.listen(0, "127.0.0.1", () => { const port = server.address().port; server.close(() => resolve(port)); });
@@ -128,10 +129,10 @@ test("Cowork, Files, Quick Note, Markdown, and mobile continuity work as one fil
128129
await page.waitForFunction(() => document.querySelector('[aria-label="Notes editor"] .cm-content')?.textContent.includes("Field notes"));
129130
const editorContent = '[aria-label="Notes editor"] .cm-content';
130131
await page.click(editorContent);
131-
await page.keyboard.down("Control"); await page.keyboard.press("End"); await page.keyboard.up("Control");
132+
await page.keyboard.down(primaryModifier); await page.keyboard.press("a"); await page.keyboard.up(primaryModifier); await page.keyboard.press("ArrowRight");
132133
await page.keyboard.type("\nUnsaved continuity proof.");
133134
await page.click('[aria-label="Notes editor"] .cm-line');
134-
await page.keyboard.press("Home");
135+
await page.keyboard.down(primaryModifier); await page.keyboard.press("a"); await page.keyboard.up(primaryModifier); await page.keyboard.press("ArrowLeft");
135136
for (let index = 0; index < 3; index++) await page.keyboard.press("ArrowRight");
136137
await page.keyboard.down("Shift"); for (let index = 0; index < 8; index++) await page.keyboard.press("ArrowRight"); await page.keyboard.up("Shift");
137138
await page.evaluate(() => { window.__coworkEditor = document.querySelector('[aria-label="Notes editor"] .cm-content'); });
@@ -142,7 +143,7 @@ test("Cowork, Files, Quick Note, Markdown, and mobile continuity work as one fil
142143
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() };
143144
});
144145
assert.deepEqual(continuity, { same: true, focused: true, lines: ["# Field notes", "", "**Goal**", "", "Unsaved continuity proof."], selection: "ield not" });
145-
await page.keyboard.down("Control"); await page.keyboard.press("s"); await page.keyboard.up("Control");
146+
await page.keyboard.down(primaryModifier); await page.keyboard.press("s"); await page.keyboard.up(primaryModifier);
146147
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");
147148

148149
// A second authenticated member joins the same ordinary workspace file.
@@ -158,7 +159,7 @@ test("Cowork, Files, Quick Note, Markdown, and mobile continuity work as one fil
158159
await page.waitForSelector('[data-cowork-viewer="crew"]');
159160
await collaboratorPage.waitForSelector('[data-cowork-viewer="captain"]');
160161
await collaboratorPage.click('[aria-label="Notes editor"] .cm-content');
161-
await collaboratorPage.keyboard.down("Control"); await collaboratorPage.keyboard.press("End"); await collaboratorPage.keyboard.up("Control");
162+
await collaboratorPage.keyboard.down(primaryModifier); await collaboratorPage.keyboard.press("a"); await collaboratorPage.keyboard.up(primaryModifier); await collaboratorPage.keyboard.press("ArrowRight");
162163
await collaboratorPage.keyboard.type("\nLive words from Crew.");
163164
await page.waitForFunction(() => document.querySelector('[aria-label="Notes editor"] .cm-content')?.textContent.includes("Live words from Crew"));
164165
await collaboratorPage.evaluate(() => {
@@ -225,15 +226,15 @@ test("Cowork, Files, Quick Note, Markdown, and mobile continuity work as one fil
225226
await page.evaluate(() => [...document.querySelectorAll('[data-cowork-files] button')].find((button) => button.textContent.includes("tool.ts"))?.click());
226227
await page.waitForSelector('[aria-label="Code editor"][data-cowork-language="typescript"] .cm-lineNumbers');
227228
await page.click('[aria-label="Code editor"] .cm-content');
228-
await page.keyboard.down("Control"); await page.keyboard.press("End"); await page.keyboard.up("Control");
229+
await page.keyboard.down(primaryModifier); await page.keyboard.press("a"); await page.keyboard.up(primaryModifier); await page.keyboard.press("ArrowRight");
229230
await page.keyboard.press("Enter"); await page.keyboard.press("Tab"); await page.keyboard.type("const searchableValue = 42;");
230231
assert.equal(await page.$eval('[aria-label="Code editor"] .cm-line:last-child', (line) => line.textContent.startsWith(" ")), true);
231-
await page.keyboard.down("Control"); await page.keyboard.press("f"); await page.keyboard.up("Control");
232+
await page.keyboard.down(primaryModifier); await page.keyboard.press("f"); await page.keyboard.up(primaryModifier);
232233
await page.waitForSelector('[aria-label="Code editor"] .cm-search input');
233234
await page.type('[aria-label="Code editor"] .cm-search input', "searchableValue");
234235
assert.ok(await page.$$eval('[aria-label="Code editor"] .cm-searchMatch', (matches) => matches.length) > 0);
235236
await page.keyboard.press("Escape");
236-
await page.keyboard.down("Control"); await page.keyboard.press("s"); await page.keyboard.up("Control");
237+
await page.keyboard.down(primaryModifier); await page.keyboard.press("s"); await page.keyboard.up(primaryModifier);
237238
await waitFor(async () => (await api(`/api/channels/${channel.id}/files/text?path=code%2Ftool.ts`, {}, token)).file.content.includes("searchableValue"), "saved TypeScript editor content");
238239

239240
// Docs keeps a page-oriented editor and its formatting controls write
@@ -243,11 +244,11 @@ test("Cowork, Files, Quick Note, Markdown, and mobile continuity work as one fil
243244
await page.evaluate(() => [...document.querySelectorAll('[data-cowork-files] button')].find((button) => button.textContent.includes("proposal.md"))?.click());
244245
await page.waitForSelector('.cowork-doc-page [aria-label="Docs editor"]');
245246
await page.click('[aria-label="Docs editor"] .cm-content');
246-
await page.keyboard.down("Control"); await page.keyboard.press("End"); await page.keyboard.up("Control");
247+
await page.keyboard.down(primaryModifier); await page.keyboard.press("a"); await page.keyboard.up(primaryModifier); await page.keyboard.press("ArrowRight");
247248
await page.keyboard.press("Enter");
248249
await page.evaluate(() => [...document.querySelectorAll('.cowork-editor-toolbar button')].find((button) => button.textContent.trim() === "Bold")?.click());
249250
await page.keyboard.type("shared proposal");
250-
await page.keyboard.down("Control"); await page.keyboard.press("s"); await page.keyboard.up("Control");
251+
await page.keyboard.down(primaryModifier); await page.keyboard.press("s"); await page.keyboard.up(primaryModifier);
251252
await waitFor(async () => (await api(`/api/channels/${channel.id}/files/text?path=docs%2Fproposal.md`, {}, token)).file.content.includes("**shared proposal**"), "saved formatted document");
252253

253254
// Cowork-local Explorer actions operate in nested folders over the same

0 commit comments

Comments
 (0)