fix(e2e): canonicalize temp repo paths so golden tests pass on macOS (#6718)
This commit is contained in:
parent
ffe50add49
commit
63e96db7dd
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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' })
|
||||
|
|
|
|||
|
|
@ -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<string> {
|
||||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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' })
|
||||
|
|
|
|||
Loading…
Reference in New Issue