Files
automaker/apps/ui/tests/git/worktree-integration.spec.ts
Test User 46caae05d2 feat: improve test setup and authentication handling
- Added `dev:test` script to package.json for streamlined testing without file watching.
- Introduced `kill-test-servers` script to ensure no existing servers are running on test ports before executing tests.
- Enhanced Playwright configuration to use mock agent for tests, ensuring consistent API responses and disabling rate limiting.
- Updated various test files to include authentication steps and handle login screens, improving reliability and reducing flakiness in tests.
- Added `global-setup` for e2e tests to ensure proper initialization before test execution.
2025-12-30 00:06:27 -05:00

66 lines
1.6 KiB
TypeScript

/**
* Worktree Integration E2E Test
*
* Happy path: Display worktree selector with main branch
*/
import { test, expect } from '@playwright/test';
import * as fs from 'fs';
import {
waitForNetworkIdle,
createTestGitRepo,
cleanupTempDir,
createTempDirPath,
setupProjectWithPath,
waitForBoardView,
authenticateForTests,
handleLoginScreenIfPresent,
} from '../utils';
const TEST_TEMP_DIR = createTempDirPath('worktree-tests');
interface TestRepo {
path: string;
cleanup: () => Promise<void>;
}
test.describe('Worktree Integration', () => {
let testRepo: TestRepo;
test.beforeAll(async () => {
if (!fs.existsSync(TEST_TEMP_DIR)) {
fs.mkdirSync(TEST_TEMP_DIR, { recursive: true });
}
});
test.beforeEach(async () => {
testRepo = await createTestGitRepo(TEST_TEMP_DIR);
});
test.afterEach(async () => {
if (testRepo) {
await testRepo.cleanup();
}
});
test.afterAll(async () => {
cleanupTempDir(TEST_TEMP_DIR);
});
test('should display worktree selector with main branch', async ({ page }) => {
await setupProjectWithPath(page, testRepo.path);
await authenticateForTests(page);
await page.goto('/');
await page.waitForLoadState('load');
await handleLoginScreenIfPresent(page);
await waitForNetworkIdle(page);
await waitForBoardView(page);
const branchLabel = page.getByText('Branch:');
await expect(branchLabel).toBeVisible({ timeout: 10000 });
const mainBranchButton = page.locator('[data-testid="worktree-branch-main"]');
await expect(mainBranchButton).toBeVisible({ timeout: 15000 });
});
});