Files
automaker/apps/ui/tests/projects/new-project-creation.spec.ts
Test User 036a7d9d26 refactor: update e2e tests to use 'load' state for page navigation
- Changed instances of `waitForLoadState('networkidle')` to `waitForLoadState('load')` across multiple test files and utility functions to improve test reliability in applications with persistent connections.
- Added documentation to the e2e testing guide explaining the rationale behind using 'load' state instead of 'networkidle' to prevent timeouts and flaky tests.
2025-12-22 17:16:55 -05:00

54 lines
1.9 KiB
TypeScript

/**
* Project Creation E2E Test
*
* Happy path: Create a new blank project from welcome view
*/
import { test, expect } from '@playwright/test';
import * as fs from 'fs';
import * as path from 'path';
import { createTempDirPath, cleanupTempDir, setupWelcomeView } from '../utils';
const TEST_TEMP_DIR = createTempDirPath('project-creation-test');
test.describe('Project Creation', () => {
test.beforeAll(async () => {
if (!fs.existsSync(TEST_TEMP_DIR)) {
fs.mkdirSync(TEST_TEMP_DIR, { recursive: true });
}
});
test.afterAll(async () => {
cleanupTempDir(TEST_TEMP_DIR);
});
test('should create a new blank project from welcome view', async ({ page }) => {
const projectName = `test-project-${Date.now()}`;
await setupWelcomeView(page, { workspaceDir: TEST_TEMP_DIR });
await page.goto('/');
await page.waitForLoadState('load');
await expect(page.locator('[data-testid="welcome-view"]')).toBeVisible({ timeout: 10000 });
await page.locator('[data-testid="create-new-project"]').click();
await page.locator('[data-testid="quick-setup-option"]').click();
await expect(page.locator('[data-testid="new-project-modal"]')).toBeVisible({ timeout: 5000 });
await page.locator('[data-testid="project-name-input"]').fill(projectName);
await expect(page.getByText('Will be created at:')).toBeVisible({ timeout: 5000 });
await page.locator('[data-testid="confirm-create-project"]').click();
await expect(page.locator('[data-testid="board-view"]')).toBeVisible({ timeout: 15000 });
await expect(
page.locator('[data-testid="project-selector"]').getByText(projectName)
).toBeVisible({ timeout: 5000 });
const projectPath = path.join(TEST_TEMP_DIR, projectName);
expect(fs.existsSync(projectPath)).toBe(true);
expect(fs.existsSync(path.join(projectPath, '.automaker'))).toBe(true);
});
});