diff --git a/tests/e2e/add-project-default-checkout.spec.ts b/tests/e2e/add-project-default-checkout.spec.ts index 6b37aa990..0ae5b8514 100644 --- a/tests/e2e/add-project-default-checkout.spec.ts +++ b/tests/e2e/add-project-default-checkout.spec.ts @@ -1,5 +1,5 @@ import { execFileSync } from 'child_process' -import { mkdirSync, rmSync, writeFileSync } from 'fs' +import { mkdirSync, realpathSync, rmSync, writeFileSync } from 'fs' import { mkdtemp } from 'fs/promises' import os from 'os' import path from 'path' @@ -12,7 +12,12 @@ async function createCloneFixture(): Promise<{ sourcePath: string destinationParent: string }> { - const rootPath = await mkdtemp(path.join(os.tmpdir(), 'orca-e2e-add-project-clone-')) + // Why: realpathSync so the path the test asserts on matches the store's + // repo.path on macOS, where os.tmpdir() (/var/...) symlinks to /private/var/... + // and the app canonicalizes repo.path via `git rev-parse --show-toplevel`. + const rootPath = realpathSync( + await mkdtemp(path.join(os.tmpdir(), 'orca-e2e-add-project-clone-')) + ) tempRoots.push(rootPath) const sourcePath = path.join(rootPath, 'default-checkout-source') @@ -38,7 +43,12 @@ async function createLinkedWorktreeFixture(): Promise<{ mainPath: string siblingPath: string }> { - const rootPath = await mkdtemp(path.join(os.tmpdir(), 'orca-e2e-add-project-linked-')) + // Why: realpathSync so mainPath matches the store's repo.path on macOS, where + // os.tmpdir() (/var/...) symlinks to /private/var/... and the app canonicalizes + // repo.path via `git rev-parse --show-toplevel` on add. + const rootPath = realpathSync( + await mkdtemp(path.join(os.tmpdir(), 'orca-e2e-add-project-linked-')) + ) tempRoots.push(rootPath) const mainPath = path.join(rootPath, 'linked-source') diff --git a/tests/e2e/folder-setup-shallow-priority.spec.ts b/tests/e2e/folder-setup-shallow-priority.spec.ts index b970a29ba..0f6fee861 100644 --- a/tests/e2e/folder-setup-shallow-priority.spec.ts +++ b/tests/e2e/folder-setup-shallow-priority.spec.ts @@ -1,5 +1,5 @@ import { execFileSync } from 'child_process' -import { mkdirSync, rmSync, writeFileSync } from 'fs' +import { mkdirSync, realpathSync, rmSync, writeFileSync } from 'fs' import { mkdtemp } from 'fs/promises' import os from 'os' import path from 'path' @@ -28,7 +28,12 @@ async function createShallowPriorityTruncationFixture(): Promise<{ webClientPath: string groupName: string }> { - const parentPath = await mkdtemp(path.join(os.tmpdir(), 'orca-e2e-shallow-priority-')) + // Why: realpathSync so the paths the test asserts on match the store's + // repo.path / projectGroup.parentPath on macOS, where os.tmpdir() (/var/...) + // symlinks to /private/var/... and the app canonicalizes paths on import. + const parentPath = realpathSync( + await mkdtemp(path.join(os.tmpdir(), 'orca-e2e-shallow-priority-')) + ) tempRoots.push(parentPath) const archivePath = path.join(parentPath, 'archive') const webClientPath = path.join(parentPath, 'z-web-client') @@ -54,7 +59,12 @@ async function createCancellableScanFixture(): Promise<{ webPath: string groupName: string }> { - const parentPath = await mkdtemp(path.join(os.tmpdir(), 'orca-e2e-cancellable-scan-')) + // Why: realpathSync so the paths the test asserts on match the store's + // canonicalized repo.path / projectGroup.parentPath on macOS (os.tmpdir() + // /var/... symlinks to /private/var/...). + const parentPath = realpathSync( + await mkdtemp(path.join(os.tmpdir(), 'orca-e2e-cancellable-scan-')) + ) tempRoots.push(parentPath) const apiPath = path.join(parentPath, 'api') const webPath = path.join(parentPath, 'web') diff --git a/tests/e2e/folder-setup.spec.ts b/tests/e2e/folder-setup.spec.ts index cbabf8e0b..e3d06c78b 100644 --- a/tests/e2e/folder-setup.spec.ts +++ b/tests/e2e/folder-setup.spec.ts @@ -1,5 +1,5 @@ import { execFileSync } from 'child_process' -import { mkdirSync, rmSync, writeFileSync } from 'fs' +import { mkdirSync, realpathSync, rmSync, writeFileSync } from 'fs' import { mkdtemp } from 'fs/promises' import os from 'os' import path from 'path' @@ -29,7 +29,11 @@ async function createNestedRepoFixture(): Promise<{ projectPaths: string[] groupName: string }> { - const parentPath = await mkdtemp(path.join(os.tmpdir(), 'orca-e2e-folder-setup-')) + // Why: realpathSync so the projectPaths the test asserts on match the store's + // canonicalized repo.path / projectGroup.parentPath on macOS, where + // os.tmpdir() (/var/...) symlinks to /private/var/... and the app canonicalizes + // imported paths via `git rev-parse --show-toplevel`. + const parentPath = realpathSync(await mkdtemp(path.join(os.tmpdir(), 'orca-e2e-folder-setup-'))) tempRoots.push(parentPath) const repoNames = ['api-service', 'web-client'] const projectPaths = repoNames.map((name) => path.join(parentPath, name)) @@ -51,7 +55,12 @@ async function createLargeNestedRepoFixture(): Promise<{ groupName: string selectedProjectPaths: string[] }> { - const parentPath = await mkdtemp(path.join(os.tmpdir(), 'orca-e2e-large-folder-setup-')) + // Why: realpathSync so the projectPaths the test asserts on match the store's + // canonicalized repo.path on macOS (os.tmpdir() /var/... symlinks to + // /private/var/...). + const parentPath = realpathSync( + await mkdtemp(path.join(os.tmpdir(), 'orca-e2e-large-folder-setup-')) + ) tempRoots.push(parentPath) const nestedParent = path.join( parentPath, diff --git a/tests/e2e/global-setup.ts b/tests/e2e/global-setup.ts index 5a70a8bc2..d43efcde4 100644 --- a/tests/e2e/global-setup.ts +++ b/tests/e2e/global-setup.ts @@ -12,7 +12,7 @@ import { execSync } from 'child_process' import { randomUUID } from 'crypto' -import { existsSync, mkdirSync, mkdtempSync, writeFileSync } from 'fs' +import { existsSync, mkdirSync, mkdtempSync, realpathSync, writeFileSync } from 'fs' import path from 'path' import os from 'os' @@ -56,7 +56,10 @@ export default function globalSetup(): void { // ── 2. Create a seeded test git repo ─────────────────────────────── // Why: each test run gets its own git repo so the suite is fully // idempotent. No test depends on whatever repos the user has open. - const testRepoDir = mkdtempSync(path.join(os.tmpdir(), 'orca-e2e-repo-')) + // Why: realpathSync so the seeded path matches the store's repo.path on + // macOS, where os.tmpdir() (/var/...) symlinks to /private/var/... and the + // app canonicalizes repo.path via `git rev-parse --show-toplevel` on add. + const testRepoDir = realpathSync(mkdtempSync(path.join(os.tmpdir(), 'orca-e2e-repo-'))) execSync('git init', { cwd: testRepoDir, stdio: 'pipe' }) execSync('git config user.email "e2e@test.local"', { cwd: testRepoDir, stdio: 'pipe' }) diff --git a/tests/e2e/golden-core-flows.spec.ts b/tests/e2e/golden-core-flows.spec.ts index 376f85d07..5bd3a1872 100644 --- a/tests/e2e/golden-core-flows.spec.ts +++ b/tests/e2e/golden-core-flows.spec.ts @@ -1,5 +1,5 @@ import { execFileSync } from 'child_process' -import { mkdirSync, rmSync, writeFileSync } from 'fs' +import { mkdirSync, realpathSync, rmSync, writeFileSync } from 'fs' import { mkdtemp } from 'fs/promises' import os from 'os' import path from 'path' @@ -31,7 +31,10 @@ function escapeRegExp(value: string): string { } async function createGitRepo(prefix: string, name: string): Promise { - const rootPath = await mkdtemp(path.join(os.tmpdir(), prefix)) + // Why: macOS os.tmpdir() (/var/...) symlinks to /private/var/..., and the app + // canonicalizes repo.path via `git rev-parse --show-toplevel` on add. Resolve + // the symlink here so the path the test asserts on matches what the store holds. + const rootPath = realpathSync(await mkdtemp(path.join(os.tmpdir(), prefix))) tempRoots.push(rootPath) const repoPath = path.join(rootPath, name) diff --git a/tests/e2e/helpers/orca-app.ts b/tests/e2e/helpers/orca-app.ts index 9fd62f89c..cb4f95c53 100644 --- a/tests/e2e/helpers/orca-app.ts +++ b/tests/e2e/helpers/orca-app.ts @@ -21,7 +21,15 @@ import { type ElectronApplication, type TestInfo } from '@stablyai/playwright-test' -import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs' +import { + existsSync, + mkdtempSync, + mkdirSync, + readFileSync, + realpathSync, + rmSync, + writeFileSync +} from 'fs' import { execSync } from 'child_process' import { randomUUID } from 'crypto' import os from 'os' @@ -133,7 +141,10 @@ function isValidGitRepo(repoPath: string): boolean { } function createSeededTestRepo(): string { - const testRepoDir = mkdtempSync(path.join(os.tmpdir(), 'orca-e2e-repo-')) + // Why: realpathSync so the seeded path matches the store's repo.path on + // macOS, where os.tmpdir() (/var/...) symlinks to /private/var/... and the + // app canonicalizes repo.path via `git rev-parse --show-toplevel` on add. + const testRepoDir = realpathSync(mkdtempSync(path.join(os.tmpdir(), 'orca-e2e-repo-'))) execSync('git init', { cwd: testRepoDir, stdio: 'pipe' }) execSync('git config user.email "e2e@test.local"', { cwd: testRepoDir, stdio: 'pipe' })