Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: files changed app/test/playwright/specs/chat-todo-list-render.spec.ts,scripts/__tests__/brows

Steven Enamakel9fd38037ecd7
diff --git a/app/test/playwright/specs/chat-todo-list-render.spec.ts b/app/test/playwright/specs/chat-todo-list-render.spec.ts
index 330ae65d12..5e51ef2190 100644
--- a/app/test/playwright/specs/chat-todo-list-render.spec.ts
+++ b/app/test/playwright/specs/chat-todo-list-render.spec.ts
@@ -100,7 +100,8 @@ const RULES = [
* element's own attribute (`todo-list.tsx:46`), so this finds the real
* component rather than a wrapper that happens to carry a test id.
*/
-const allLists = (page: Page): Locator => page.locator('[data-slot="todo-list"]');
+const allTodoSurfaces = (page: Page): Locator =>
+ page.locator('[data-testid="todo-checklist"], [data-testid="todo-receipt"]');
/** The pinned, always-current list above the composer. */
const pinnedList = (page: Page): Locator => page.getByTestId('todo-checklist');
@@ -110,8 +111,11 @@ const pinnedList = (page: Page): Locator => page.getByTestId('todo-checklist');
* one given a test id (`Conversations.tsx:1659`), so excluding it leaves
* exactly the `TodoListPart` renders.
*/
-const snapshotLists = (page: Page): Locator =>
- page.locator('[data-testid="todo-receipt"] [data-slot="todo-list"]');
+const snapshotReceipts = (page: Page): Locator => page.getByTestId('todo-receipt');
+
+/** A settled pinned task card maps stored in-progress items to pending. */
+const settledPinnedCard = (page: Page): Locator =>
+ page.locator('[data-testid="todo-checklist"][data-state="waiting"]');
async function expandSnapshotReceipts(page: Page): Promise<void> {
const receipts = page.getByTestId('todo-receipt');
@@ -174,7 +178,9 @@ test.describe('Todo list render', () => {
// Control: no list of either kind before the agent writes one, so the
// assertions below are about something that appeared.
- await expect(allLists(page), 'a todo list was on screen before any write').toHaveCount(0);
+ await expect(allTodoSurfaces(page), 'a todo surface was on screen before any write').toHaveCount(
+ 0
+ );
const threadId = await waitForSelectedThreadId(page);
const before = (await upstreamBodies()).length;
@@ -198,9 +204,9 @@ test.describe('Todo list render', () => {
'the todo tool round-tripped but rendered nothing in the transcript'
).toHaveCount(1, { timeout: 60_000 });
await expandSnapshotReceipts(page);
- await expect(snapshotLists(page)).toHaveCount(1);
+ await expect(snapshotReceipts(page)).toHaveCount(1);
- const snapshot = snapshotLists(page).first();
+ const snapshot = snapshotReceipts(page).first();
await expect
.poll(async () => itemStates(snapshot), { timeout: 30_000 })
.toEqual(['active', 'pending', 'pending']);
@@ -214,32 +220,36 @@ test.describe('Todo list render', () => {
await openChat(page);
const threadId = await waitForSelectedThreadId(page);
+ const firstWriteRequestCount = (await upstreamBodies()).length;
await sendTurn(page, threadId, 'TODOPLAN write the release plan');
await expect(page.getByTestId('todo-receipt')).toHaveCount(1, { timeout: 60_000 });
await expandSnapshotReceipts(page);
- await expect(snapshotLists(page)).toHaveCount(1);
+ await expect(snapshotReceipts(page)).toHaveCount(1);
await expect
.poll(async () => itemStates(snapshotLists(page).first()), { timeout: 30_000 })
.toEqual(['active', 'pending', 'pending']);
+ expect(await upstreamBodies()).toHaveLengthGreaterThan(firstWriteRequestCount + 1);
+
+ const secondWriteRequestCount = (await upstreamBodies()).length;
await sendTurn(page, threadId, 'TODOADVANCE keep going');
await expect(
page.getByTestId('todo-receipt'),
'the second todo call did not produce its own transcript render'
).toHaveCount(2, { timeout: 60_000 });
await expandSnapshotReceipts(page);
- await expect(snapshotLists(page)).toHaveCount(2);
+ await expect(snapshotReceipts(page)).toHaveCount(2);
// The new snapshot carries the new write...
await expect
- .poll(async () => itemStates(snapshotLists(page).nth(1)), { timeout: 30_000 })
+ .poll(async () => itemStates(snapshotReceipts(page).nth(1)), { timeout: 30_000 })
.toEqual(['done', 'done', 'active']);
// ...and the first one has NOT moved. A shared store behind both renders
// would rewrite history: the transcript would show the agent having always
// known the final state, which is exactly what a transcript must not do.
expect(
- await itemStates(snapshotLists(page).first()),
+ await itemStates(snapshotReceipts(page).first()),
'the earlier transcript snapshot was rewritten by a later write'
).toEqual(['active', 'pending', 'pending']);
});
@@ -248,15 +258,20 @@ test.describe('Todo list render', () => {
await openChat(page);
const threadId = await waitForSelectedThreadId(page);
- // A valid write first, so the pinned list exists and the assertion below
- // is about its contents rather than its absence.
+ // A valid write first, so the pinned task card exists and the assertion
+ // below is about its stored contents rather than its absence.
+ const firstWriteRequestCount = (await upstreamBodies()).length;
await sendTurn(page, threadId, 'TODOPLAN write the release plan');
- await expect(pinnedList(page), 'the pinned checklist never appeared').toBeVisible({
- timeout: 60_000,
+ await expect
+ .poll(async () => (await upstreamBodies()).length, { timeout: 60_000 })
+ .toBeGreaterThan(firstWriteRequestCount + 1);
+ await expect(settledPinnedCard(page), 'the settled task card never appeared').toHaveCount(1, {
+ timeout: 30_000,
});
await expect
- .poll(async () => itemStates(pinnedList(page)), { timeout: 30_000 })
- .toEqual(['active', 'pending', 'pending']);
+ .poll(async () => itemStates(settledPinnedCard(page).first()), { timeout: 30_000 })
+ .toEqual(['pending', 'pending', 'pending']);
+ expect(await itemTexts(settledPinnedCard(page).first())).toEqual([...STEPS]);
// Now a write the core refuses (`todo_tests.rs:77`).
//
@@ -275,7 +290,13 @@ test.describe('Todo list render', () => {
})
.toBeGreaterThan(before + 1);
- const states = await itemStates(pinnedList(page));
+ await expect(settledPinnedCard(page), 'the rejected write hid the previous task card').toHaveCount(
+ 1,
+ { timeout: 30_000 }
+ );
+ const states = await itemStates(settledPinnedCard(page).first());
+ expect(await itemTexts(settledPinnedCard(page).first())).toEqual([...STEPS]);
+ expect(states).toEqual(['pending', 'pending', 'pending']);
expect(
states.filter(state => state === 'active').length,
`the pinned checklist showed a list the core refused to store: ${JSON.stringify(states)}`
diff --git a/scripts/__tests__/browser-test-skips.test.mjs b/scripts/__tests__/browser-test-skips.test.mjs
index 55a24a3359..19b1613975 100644
--- a/scripts/__tests__/browser-test-skips.test.mjs
+++ b/scripts/__tests__/browser-test-skips.test.mjs
@@ -41,3 +41,21 @@ test("ignores inert text but scans executable template interpolations", () => {
"7: const nested = `outer ${({ value: `inner ${this.skip()}` })}`;",
]);
});
+
+test('ignores regex literals without letting their delimiters hide executable calls', () => {
+ const source = [
+ 'const quote = /"/;',
+ "test.skip('missing after quote regex');",
+ 'const backtick = /`/;',
+ 'this.skip();',
+ 'const fakeCall = /test.skip\\(foo\\)/;',
+ 'const commentStart = /\\/\\//;',
+ 'const blockCommentStart = /\\/\\*/;',
+ `test.skip('tracked'); // ${url}`,
+ ].join('\n');
+
+ assert.deepEqual(untrackedSkipLines(source), [
+ "2: test.skip('missing after quote regex');",
+ '4: this.skip();',
+ ]);
+});
diff --git a/scripts/ci/check-browser-test-skips.mjs b/scripts/ci/check-browser-test-skips.mjs
index 25b5ded977..de49083039 100644
--- a/scripts/ci/check-browser-test-skips.mjs
+++ b/scripts/ci/check-browser-test-skips.mjs
@@ -1,136 +1,41 @@
#!/usr/bin/env node
// Every executable browser-test skip needs its tracking issue on the same line.
-import { execFileSync } from "node:child_process";
-import { readFileSync } from "node:fs";
+import { execFileSync } from 'node:child_process';
+import { readFileSync } from 'node:fs';
+import { createRequire } from 'node:module';
+const requireFromApp = createRequire(new URL('../../app/package.json', import.meta.url));
+const ts = requireFromApp('typescript');
const issueUrl = /https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/issues\/\d+/;
-function tokenize(source) {
- const tokens = [];
- let index = 0;
- let line = 1;
- const advance = (end) => {
- while (index < end) if (source[index++] === "\n") line++;
- };
- const scan = (templateExpression = false) => {
- let braces = 0;
- while (index < source.length) {
- const char = source[index];
- if (templateExpression && char === "}") {
- if (braces === 0) {
- index++;
- return;
- }
- braces--;
- }
- if (templateExpression && char === "{") braces++;
- if (/\s/.test(char)) {
- advance(index + 1);
- continue;
- }
- if (char === "/" && source[index + 1] === "/") {
- const end = source.indexOf("\n", index);
- advance(end < 0 ? source.length : end);
- continue;
- }
- if (char === "/" && source[index + 1] === "*") {
- const close = source.indexOf("*/", index + 2);
- advance(close < 0 ? source.length : close + 2);
- continue;
- }
- if (char === "'") {
- const quote = char;
- const start = index;
- const tokenLine = line;
- index++;
- while (index < source.length) {
- if (source[index] === "\\") {
- advance(Math.min(index + 2, source.length));
- continue;
- }
- if (source[index] === quote) {
- index++;
- break;
- }
- advance(index + 1);
- }
- tokens.push({ value: "<string>", start, end: index, line: tokenLine });
- continue;
- }
- if (char === '"') {
- const start = index;
- const tokenLine = line;
- index++;
- while (index < source.length) {
- if (source[index] === "\\") {
- advance(Math.min(index + 2, source.length));
- continue;
- }
- if (source[index++] === '"') break;
- if (source[index - 1] === "\n") line++;
- }
- tokens.push({ value: "<string>", start, end: index, line: tokenLine });
- continue;
- }
- if (char === "`") {
- const start = index;
- const tokenLine = line;
- index++;
- while (index < source.length) {
- if (source[index] === "\\") {
- advance(Math.min(index + 2, source.length));
- continue;
- }
- if (source[index] === "`") {
- index++;
- break;
- }
- if (source[index] === "$" && source[index + 1] === "{") {
- advance(index + 2);
- scan(true);
- continue;
- }
- advance(index + 1);
- }
- tokens.push({ value: "<template>", start, end: index, line: tokenLine });
- continue;
- }
- const start = index;
- const tokenLine = line;
- if (/[A-Za-z_$]/.test(char)) {
- index++;
- while (index < source.length && /[\w$]/.test(source[index])) index++;
- } else {
- index++;
- }
- tokens.push({
- value: source.slice(start, index),
- start,
- end: index,
- line: tokenLine,
- });
- }
- };
- scan();
- return tokens;
-}
-
export function untrackedSkipLines(source) {
- const lines = source.split("\n");
- const tokens = tokenize(source);
+ const sourceFile = ts.createSourceFile(
+ 'browser-spec.tsx',
+ source,
+ ts.ScriptTarget.Latest,
+ true,
+ ts.ScriptKind.TSX
+ );
+ const lines = source.split('\n');
const failures = [];
- for (let index = 0; index + 2 < tokens.length; index++) {
+
+ function visit(node) {
if (
- tokens[index].value !== "." ||
- tokens[index + 1].value !== "skip" ||
- tokens[index + 2].value !== "("
- )
- continue;
- const line = tokens[index + 1].line;
- if (!issueUrl.test(lines[line - 1] ?? ""))
- failures.push(`${line}: ${lines[line - 1]?.trim() ?? ""}`);
+ ts.isCallExpression(node) &&
+ ts.isPropertyAccessExpression(node.expression) &&
+ node.expression.name.text === 'skip'
+ ) {
+ const line = sourceFile.getLineAndCharacterOfPosition(node.expression.name.getStart(sourceFile))
+ .line + 1;
+ if (!issueUrl.test(lines[line - 1] ?? '')) {
+ failures.push(`${line}: ${lines[line - 1]?.trim() ?? ''}`);
+ }
+ }
+ ts.forEachChild(node, visit);
}
+
+ visit(sourceFile);
return failures;
}
@@ -141,12 +46,12 @@ if (
let files;
try {
files = execFileSync(
- "git",
- ["ls-files", "app/test/e2e/specs", "app/test/playwright/specs"],
- { encoding: "utf8" },
+ 'git',
+ ['ls-files', 'app/test/e2e/specs', 'app/test/playwright/specs'],
+ { encoding: 'utf8' }
)
.trim()
- .split("\n")
+ .split('\n')
.filter(Boolean);
} catch (error) {
console.error(`Could not list browser specs: ${error.message}`);
@@ -154,13 +59,13 @@ if (
}
const failures = [];
for (const file of files) {
- const badLines = untrackedSkipLines(readFileSync(file, "utf8"));
- failures.push(...badLines.map((line) => `${file}:${line}`));
+ const badLines = untrackedSkipLines(readFileSync(file, 'utf8'));
+ failures.push(...badLines.map(line => `${file}:${line}`));
}
if (failures.length) {
console.error(
- "Browser-test skips need a GitHub issue URL on the same line:\n" +
- failures.map((line) => ` ${line}`).join("\n"),
+ 'Browser-test skips need a GitHub issue URL on the same line:\n' +
+ failures.map(line => ` ${line}`).join('\n')
);
process.exit(1);
}
diff --git a/scripts/ci/self-hosted/lanes-plan.mjs b/scripts/ci/self-hosted/lanes-plan.mjs
index 703e309111..f5867721cf 100644
--- a/scripts/ci/self-hosted/lanes-plan.mjs
+++ b/scripts/ci/self-hosted/lanes-plan.mjs
@@ -341,6 +341,7 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
{
name: "browser-test-skip-guard",
when: areas.frontend,
+ needs: ["pnpm-install"],
run: "node scripts/ci/check-browser-test-skips.mjs",
},
{