test(e2e): verify golden commit author and fix test flakiness

- Configure git author name/email at worktree level during setup
- Verify commits are made with correct author details in assertions
- Add explicit timeouts to file visibility waits and git status polling
- Fix test ordering to seed edits after source control is open
- Simplify git status refresh logic to rely on automatic updates
This commit is contained in:
Jinjing
2026-08-13 09:45:48 -07:00
parent 3cab4d633c
commit abd5d55420
3 changed files with 38 additions and 15 deletions
@@ -6,6 +6,8 @@ import {
cleanupGoldenWorktree,
createGoldenWorktree,
GOLDEN_CHANGED_PATH,
GOLDEN_GIT_AUTHOR_EMAIL,
GOLDEN_GIT_AUTHOR_NAME,
installPassingNodePreCommitHook,
openGoldenSourceControl,
seedGoldenSourceEdit
@@ -52,6 +54,12 @@ test('@golden stages and commits a file through Source Control', async ({
{ timeout: 20_000, message: 'Golden commit worktree did not become clean' }
)
.toBe('')
expect(
execFileSync('git', ['show', '-s', '--format=%an%n%ae%n%s', 'HEAD'], {
cwd: fixture.worktreePath,
encoding: 'utf8'
}).trim()
).toBe(`${GOLDEN_GIT_AUTHOR_NAME}\n${GOLDEN_GIT_AUTHOR_EMAIL}\ntest: golden daily loop`)
await expect.poll(() => existsSync(hookMarkerPath), { timeout: 20_000 }).toBe(true)
await expect(
orcaPage.locator('[data-sonner-toast]').filter({ hasText: /node|command not found|cmd\.exe/i })
@@ -19,15 +19,15 @@ test('@golden opens an unstaged file diff from Source Control', async ({
}) => {
const fixture = createGoldenWorktree(testRepoPath, 'open-diff')
registerPostElectronShutdownCleanup(async () => cleanupGoldenWorktree(testRepoPath, fixture))
seedGoldenSourceEdit(fixture.worktreePath)
await waitForSessionReady(orcaPage)
await openGoldenSourceControl(orcaPage, testRepoPath, fixture)
seedGoldenSourceEdit(fixture.worktreePath)
const changedFile = orcaPage
.locator('[data-testid="source-control-entry"]')
.filter({ hasText: path.basename(GOLDEN_CHANGED_PATH) })
await expect(changedFile).toBeVisible()
await expect(changedFile).toBeVisible({ timeout: 15_000 })
await changedFile.click()
await expect(orcaPage.locator('.monaco-diff-editor')).toBeVisible({ timeout: 20_000 })
+28 -13
View File
@@ -8,6 +8,8 @@ import { expect } from './orca-app'
export const GOLDEN_CHANGED_PATH = 'src/index.ts'
export const GOLDEN_REMOVED_LINE = 'export const hello = "world"'
export const GOLDEN_ADDED_LINE = 'export const hello = "golden daily loop"'
export const GOLDEN_GIT_AUTHOR_NAME = 'Orca E2E'
export const GOLDEN_GIT_AUTHOR_EMAIL = 'orca-e2e@example.invalid'
const GOLDEN_PRE_COMMIT_MARKER = '.e2e-pre-commit-ran'
export type GoldenWorktree = {
@@ -24,6 +26,18 @@ export function createGoldenWorktree(repoPath: string, label: string): GoldenWor
cwd: repoPath,
stdio: 'pipe'
})
execFileSync('git', ['config', 'extensions.worktreeConfig', 'true'], {
cwd: worktreePath,
stdio: 'pipe'
})
execFileSync('git', ['config', '--worktree', 'user.name', GOLDEN_GIT_AUTHOR_NAME], {
cwd: worktreePath,
stdio: 'pipe'
})
execFileSync('git', ['config', '--worktree', 'user.email', GOLDEN_GIT_AUTHOR_EMAIL], {
cwd: worktreePath,
stdio: 'pipe'
})
return { branchName, worktreePath }
}
@@ -65,10 +79,6 @@ export function installPassingNodePreCommitHook(fixture: GoldenWorktree): string
const hookPath = path.join(hooksPath, 'pre-commit')
const markerPath = path.join(hooksPath, GOLDEN_PRE_COMMIT_MARKER)
fixture.hooksPath = hooksPath
execFileSync('git', ['config', 'extensions.worktreeConfig', 'true'], {
cwd: fixture.worktreePath,
stdio: 'pipe'
})
execFileSync('git', ['config', '--worktree', 'core.hooksPath', hooksPath], {
cwd: fixture.worktreePath,
stdio: 'pipe'
@@ -133,24 +143,29 @@ export async function openGoldenSourceControl(
fixture: GoldenWorktree
): Promise<void> {
await activateGoldenWorktree(page, repoPath, fixture.worktreePath)
await page.evaluate(async (worktreePath) => {
await page.evaluate(() => {
const store = window.__store
if (!store) {
throw new Error('window.__store is not available')
}
const state = store.getState()
const worktree = Object.values(state.worktreesByRepo)
.flat()
.find((entry) => entry.id === state.activeWorktreeId)
if (!worktree) {
throw new Error('Golden worktree is not active')
}
state.setGitStatus(worktree.id, await window.api.git.status({ worktreePath }))
state.setRightSidebarTab('explorer')
state.setRightSidebarOpen(true)
}, fixture.worktreePath)
})
await page.getByRole('button', { name: /Source Control/ }).click()
await expect(page.getByRole('textbox', { name: 'Commit message' })).toBeVisible({
timeout: 10_000
})
await expect
.poll(
() =>
page.evaluate(() => {
const state = window.__store?.getState()
return state?.activeWorktreeId
? Object.hasOwn(state.gitStatusByWorktree, state.activeWorktreeId)
: false
}),
{ timeout: 10_000, message: 'Automatic Git status refresh did not complete' }
)
.toBe(true)
}