mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
* Keep repository detection off the main IPC thread Share repository discovery decisions across synchronous compatibility callers and the existing asynchronous Git runner. Await discovery in project registration, nested imports, and folder upgrades, and recheck folder ownership after discovery completes. * Make repository detection fixtures work on native Windows * Await asynchronous Git checks in folder upgrade fixtures * Prevent duplicate project registration after async discovery * Check authoritative registration identity before renderer convergence * Narrow repository responsiveness to detection and registration * Keep one local project identity after concurrent registration * Run registration SSH coverage in the existing Docker lane * Keep folder upgrades responsive and recheck pending project ownership * test(git): cover classifier failure stages and literal path identity * test(git): use the current process host package * test(repos): use current process host in folder upgrade fixture * test(repos): use current process host in registration fixture
72 lines
2.8 KiB
TypeScript
72 lines
2.8 KiB
TypeScript
import { mkdtempSync, realpathSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import { test, expect } from './helpers/orca-app'
|
|
import { waitForSessionReady } from './helpers/store'
|
|
import { openSidebarProjectDialog } from './helpers/sidebar-project-dialog'
|
|
import { runProcess } from '@orca/process-host'
|
|
|
|
test.use({ seedTestRepo: false })
|
|
|
|
async function runFixtureGit(spec: Parameters<typeof runProcess>[0]): Promise<void> {
|
|
const result = await runProcess(spec)
|
|
expect(result.code, result.stderr).toBe(0)
|
|
}
|
|
|
|
test('Add Project opens a folder and preserves its workspace when Git appears', async ({
|
|
electronApp,
|
|
orcaPage,
|
|
registerPostElectronShutdownCleanup
|
|
}, testInfo) => {
|
|
const folderPath = realpathSync(mkdtempSync(join(tmpdir(), 'orca-folder-upgrade-')))
|
|
registerPostElectronShutdownCleanup(async () => {
|
|
const { rm } = await import('node:fs/promises')
|
|
await rm(folderPath, { recursive: true, force: true })
|
|
})
|
|
await waitForSessionReady(orcaPage)
|
|
await electronApp.evaluate(({ dialog }, path) => {
|
|
dialog.showOpenDialog = async () => ({ canceled: false, filePaths: [path], bookmarks: [] })
|
|
}, folderPath)
|
|
await openSidebarProjectDialog(orcaPage)
|
|
await orcaPage.getByRole('button', { name: /Browse folder/i }).click()
|
|
const dialog = orcaPage.getByRole('dialog', { name: 'Open as Folder' })
|
|
await expect(dialog).toBeVisible()
|
|
await orcaPage.screenshot({ path: testInfo.outputPath('open-folder.png') })
|
|
await dialog.getByRole('button', { name: 'Open as Folder', exact: true }).click()
|
|
await expect
|
|
.poll(() => orcaPage.evaluate(() => window.__store!.getState().repos[0]?.kind))
|
|
.toBe('folder')
|
|
await expect
|
|
.poll(() =>
|
|
orcaPage.evaluate(() => {
|
|
const state = window.__store!.getState()
|
|
return state.worktreesByRepo[state.repos[0].id]?.[0]?.id
|
|
})
|
|
)
|
|
.toBeTruthy()
|
|
const before = await orcaPage.evaluate(() => {
|
|
const state = window.__store!.getState()
|
|
const repo = state.repos[0]
|
|
return { repoId: repo.id, worktreeId: state.worktreesByRepo[repo.id]?.[0]?.id }
|
|
})
|
|
await orcaPage.screenshot({ path: testInfo.outputPath('folder-workspace.png') })
|
|
await runFixtureGit({ program: 'git', args: ['init', folderPath] })
|
|
await expect
|
|
.poll(() => orcaPage.evaluate(() => window.__store!.getState().repos[0]?.kind), {
|
|
timeout: 30_000
|
|
})
|
|
.toBe('git')
|
|
await expect
|
|
.poll(
|
|
() =>
|
|
orcaPage.evaluate(() => {
|
|
const state = window.__store!.getState()
|
|
const repo = state.repos[0]
|
|
return { repoId: repo.id, worktreeId: state.worktreesByRepo[repo.id]?.[0]?.id }
|
|
}),
|
|
{ timeout: 30_000 }
|
|
)
|
|
.toEqual(before)
|
|
await orcaPage.screenshot({ path: testInfo.outputPath('git-workspace.png') })
|
|
})
|