From abd5d55420d2ddd627cefe7a37519e6d3b4e90bc Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Thu, 13 Aug 2026 09:02:22 -0700 Subject: [PATCH] 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 --- .../e2e/golden-source-control-commit.spec.ts | 8 ++++ .../golden-source-control-open-diff.spec.ts | 4 +- tests/e2e/helpers/golden-source-control.ts | 41 +++++++++++++------ 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/tests/e2e/golden-source-control-commit.spec.ts b/tests/e2e/golden-source-control-commit.spec.ts index 590193502ea..70fb7c4e3e1 100644 --- a/tests/e2e/golden-source-control-commit.spec.ts +++ b/tests/e2e/golden-source-control-commit.spec.ts @@ -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 }) diff --git a/tests/e2e/golden-source-control-open-diff.spec.ts b/tests/e2e/golden-source-control-open-diff.spec.ts index d8989c03b9b..1c7f2735889 100644 --- a/tests/e2e/golden-source-control-open-diff.spec.ts +++ b/tests/e2e/golden-source-control-open-diff.spec.ts @@ -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 }) diff --git a/tests/e2e/helpers/golden-source-control.ts b/tests/e2e/helpers/golden-source-control.ts index 4e0bc16b0fa..251cbdf8f35 100644 --- a/tests/e2e/helpers/golden-source-control.ts +++ b/tests/e2e/helpers/golden-source-control.ts @@ -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 { 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) }