Skip to content

Commit 8cbb1d2

Browse files
test(workbench): replace the logs-real source edit atomically
A truncating writeFile can split into two watcher invalidations under load, logging "Project source changed." twice and tripping the strict locator; the shared atomic replacement makes one edit one invalidation.
1 parent f2f1aee commit 8cbb1d2

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎packages/workbench/tests/logs-real.e2e.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { writeFile } from 'node:fs/promises';
2-
31
import { expect } from '@rstest/playwright';
42

53
import { createWorkbenchAssetSource } from '../../agent-bundle/src/dev/workbench-assets.ts';
64
import { startDevServer } from '../../agent-bundle/src/dev/workbench-server.ts';
75
import { createProjectFixture, removeProjectFixture } from '../../agent-bundle/tests/helpers/project-fixture.ts';
86
import { timeScale } from '../../agent-bundle/tests/support/time-scale.ts';
7+
import { replaceWatchedSource } from '../../agent-bundle/tests/support/watched-files.ts';
98
import { buildWorkbench, e2e, workbenchAssets, workbenchUrl } from './support/workbench-e2e.ts';
109

1110
const browserTimeout = 12_000 * timeScale;
@@ -31,7 +30,9 @@ e2e('shows real producer logs with replay, filters, redaction, responsive layout
3130
const replay = await (await replayed).json() as { readonly replay: Readonly<{ readonly records: readonly unknown[] }> };
3231
expect(replay.replay.records.length).toBeGreaterThan(0);
3332

34-
await writeFile(project.skillSource, `${project.skillMarkdown}\nSource change for Logs E2E.\n`);
33+
// One atomic replacement is one watcher invalidation; a truncating write
34+
// can split into two under load and log "Project source changed." twice.
35+
await replaceWatchedSource(project.root, project.skillSource, `${project.skillMarkdown}\nSource change for Logs E2E.\n`);
3536
await expect(page.getByText('Project source changed.')).toBeVisible({ timeout: browserTimeout });
3637
await expect(page.locator('.logs-entries > li').first()).toBeVisible({ timeout: browserTimeout });
3738
await expect(page.locator('.logs-entry-level').first()).toBeVisible();

0 commit comments

Comments
 (0)