Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions test/brief-regressions-browser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import puppeteer from "puppeteer";

const primaryModifier = process.platform === "darwin" ? "Meta" : "Control";

const root = process.cwd();
const dataDir = join(root, ".native-test-data", `brief-browser-${process.pid}`);
const freePort = () => new Promise((resolve, reject) => {
Expand Down Expand Up @@ -124,10 +126,10 @@ try {
await page.evaluate(() => [...document.querySelectorAll('[data-cowork-files] button')].find((button) => button.textContent?.includes("Quiet refresh proof.md"))?.click());
await page.waitForFunction(() => document.querySelector('[aria-label="Notes editor"] .cm-content')?.textContent.includes("Start here"));
await page.click('[aria-label="Notes editor"] .cm-content');
await page.keyboard.down("Control"); await page.keyboard.press("End"); await page.keyboard.up("Control");
await page.keyboard.down(primaryModifier); await page.keyboard.press("a"); await page.keyboard.up(primaryModifier); await page.keyboard.press("ArrowRight");
await page.keyboard.type("\n\nUnsaved words survive.");
await page.click('[aria-label="Notes editor"] .cm-line');
await page.keyboard.press("Home");
await page.keyboard.down(primaryModifier); await page.keyboard.press("a"); await page.keyboard.up(primaryModifier); await page.keyboard.press("ArrowLeft");
for (let index = 0; index < 2; index++) await page.keyboard.press("ArrowRight");
await page.keyboard.down("Shift"); for (let index = 0; index < 7; index++) await page.keyboard.press("ArrowRight"); await page.keyboard.up("Shift");
await page.evaluate(() => {
Expand Down
19 changes: 10 additions & 9 deletions test/cowork-browser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async function browserExecutable() {
}

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

// A second authenticated member joins the same ordinary workspace file.
Expand All @@ -158,7 +159,7 @@ test("Cowork, Files, Quick Note, Markdown, and mobile continuity work as one fil
await page.waitForSelector('[data-cowork-viewer="crew"]');
await collaboratorPage.waitForSelector('[data-cowork-viewer="captain"]');
await collaboratorPage.click('[aria-label="Notes editor"] .cm-content');
await collaboratorPage.keyboard.down("Control"); await collaboratorPage.keyboard.press("End"); await collaboratorPage.keyboard.up("Control");
await collaboratorPage.keyboard.down(primaryModifier); await collaboratorPage.keyboard.press("a"); await collaboratorPage.keyboard.up(primaryModifier); await collaboratorPage.keyboard.press("ArrowRight");
await collaboratorPage.keyboard.type("\nLive words from Crew.");
await page.waitForFunction(() => document.querySelector('[aria-label="Notes editor"] .cm-content')?.textContent.includes("Live words from Crew"));
await collaboratorPage.evaluate(() => {
Expand Down Expand Up @@ -225,15 +226,15 @@ test("Cowork, Files, Quick Note, Markdown, and mobile continuity work as one fil
await page.evaluate(() => [...document.querySelectorAll('[data-cowork-files] button')].find((button) => button.textContent.includes("tool.ts"))?.click());
await page.waitForSelector('[aria-label="Code editor"][data-cowork-language="typescript"] .cm-lineNumbers');
await page.click('[aria-label="Code editor"] .cm-content');
await page.keyboard.down("Control"); await page.keyboard.press("End"); await page.keyboard.up("Control");
await page.keyboard.down(primaryModifier); await page.keyboard.press("a"); await page.keyboard.up(primaryModifier); await page.keyboard.press("ArrowRight");
await page.keyboard.press("Enter"); await page.keyboard.press("Tab"); await page.keyboard.type("const searchableValue = 42;");
assert.equal(await page.$eval('[aria-label="Code editor"] .cm-line:last-child', (line) => line.textContent.startsWith(" ")), true);
await page.keyboard.down("Control"); await page.keyboard.press("f"); await page.keyboard.up("Control");
await page.keyboard.down(primaryModifier); await page.keyboard.press("f"); await page.keyboard.up(primaryModifier);
await page.waitForSelector('[aria-label="Code editor"] .cm-search input');
await page.type('[aria-label="Code editor"] .cm-search input', "searchableValue");
assert.ok(await page.$$eval('[aria-label="Code editor"] .cm-searchMatch', (matches) => matches.length) > 0);
await page.keyboard.press("Escape");
await page.keyboard.down("Control"); await page.keyboard.press("s"); await page.keyboard.up("Control");
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=code%2Ftool.ts`, {}, token)).file.content.includes("searchableValue"), "saved TypeScript editor content");

// Docs keeps a page-oriented editor and its formatting controls write
Expand All @@ -243,11 +244,11 @@ test("Cowork, Files, Quick Note, Markdown, and mobile continuity work as one fil
await page.evaluate(() => [...document.querySelectorAll('[data-cowork-files] button')].find((button) => button.textContent.includes("proposal.md"))?.click());
await page.waitForSelector('.cowork-doc-page [aria-label="Docs editor"]');
await page.click('[aria-label="Docs editor"] .cm-content');
await page.keyboard.down("Control"); await page.keyboard.press("End"); await page.keyboard.up("Control");
await page.keyboard.down(primaryModifier); await page.keyboard.press("a"); await page.keyboard.up(primaryModifier); await page.keyboard.press("ArrowRight");
await page.keyboard.press("Enter");
await page.evaluate(() => [...document.querySelectorAll('.cowork-editor-toolbar button')].find((button) => button.textContent.trim() === "Bold")?.click());
await page.keyboard.type("shared proposal");
await page.keyboard.down("Control"); await page.keyboard.press("s"); await page.keyboard.up("Control");
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=docs%2Fproposal.md`, {}, token)).file.content.includes("**shared proposal**"), "saved formatted document");

// Cowork-local Explorer actions operate in nested folders over the same
Expand Down
Loading