fix(tests): unbreak macos worktree test and scratch flake
The worktree symlink test compared canonicalized output against a raw tempdir path; on macOS `/var` is a symlink to `/private/var`, so the expectation never matched. The scratch-launch spec re-listed sessions after its poll, which can observe the transient empty list the daemon's 2s reconcile tick produces. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1912,6 +1912,9 @@ mod tests {
|
||||
std::fs::create_dir(&from).unwrap();
|
||||
let to = linked_parent.join("new");
|
||||
|
||||
// On macOS the temp dir itself lives behind a symlink (/var ->
|
||||
// /private/var), so compare against the canonical real parent.
|
||||
let real_parent = real_parent.canonicalize().unwrap();
|
||||
let observed_from = canonicalize_move_endpoint(&from);
|
||||
let observed_to = canonicalize_move_endpoint(&to);
|
||||
assert_eq!(observed_from, real_parent.join("old"));
|
||||
|
||||
@@ -29,20 +29,28 @@ base("scratch happy path: launch creates a scratch-dir session", async ({ page }
|
||||
// whose parent directory basename is "scratch" (the harness isolates
|
||||
// the app dir under a per-worker temp tree, so we assert structure
|
||||
// rather than absolute location).
|
||||
// The sessions list is a cache the daemon reconciles on a 2s tick, so
|
||||
// a disk snapshot can briefly clobber a freshly created session. Hold
|
||||
// on to the snapshot the poll accepted instead of re-listing, which
|
||||
// could observe the transient empty list.
|
||||
let session: Awaited<ReturnType<typeof listSessions>>[number] | undefined;
|
||||
await expect
|
||||
.poll(async () => (await listSessions(serve.baseUrl)).length, {
|
||||
timeout: 15_000,
|
||||
})
|
||||
.toBeGreaterThan(0);
|
||||
.poll(
|
||||
async () => {
|
||||
const sessions = await listSessions(serve.baseUrl);
|
||||
if (sessions.length === 1) session = sessions[0];
|
||||
return sessions.length;
|
||||
},
|
||||
{ timeout: 15_000, intervals: [100, 200, 400] },
|
||||
)
|
||||
.toBe(1);
|
||||
|
||||
const sessions = await listSessions(serve.baseUrl);
|
||||
expect(sessions).toHaveLength(1);
|
||||
const session = sessions[0]!;
|
||||
expect(session.scratch).toBe(true);
|
||||
expect(session).toBeDefined();
|
||||
expect(session!.scratch).toBe(true);
|
||||
// Walk the path with the node:path helpers so this works on
|
||||
// Windows (`C:\foo\scratch\<id>`) as well as POSIX. The assertion
|
||||
// is "the parent dir is named scratch", expressed cross-platform.
|
||||
const projectPath = session.project_path as string;
|
||||
const projectPath = session!.project_path as string;
|
||||
expect(basename(dirname(projectPath))).toBe("scratch");
|
||||
} finally {
|
||||
await serve.stop();
|
||||
|
||||
Reference in New Issue
Block a user