mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 20:03:37 +00:00
chore: update CI configuration and enhance test stability
- Added deterministic API key and environment variables in e2e-tests.yml to ensure consistent test behavior. - Refactored CodexProvider tests to improve type safety and mock handling, ensuring reliable test execution. - Updated provider-factory tests to mock installation detection for CodexProvider, enhancing test isolation. - Adjusted Playwright configuration to conditionally use external backend, improving flexibility in test environments. - Enhanced kill-test-servers script to handle external server scenarios, ensuring proper cleanup of test processes. These changes improve the reliability and maintainability of the testing framework, leading to a more stable development experience.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Page } from '@playwright/test';
|
||||
import { clickElement } from '../core/interactions';
|
||||
import { handleLoginScreenIfPresent } from '../core/interactions';
|
||||
import { waitForElement } from '../core/waiting';
|
||||
import { authenticateForTests } from '../api/client';
|
||||
|
||||
@@ -15,22 +16,8 @@ export async function navigateToBoard(page: Page): Promise<void> {
|
||||
await page.goto('/board');
|
||||
await page.waitForLoadState('load');
|
||||
|
||||
// Check if we're on the login screen and handle it
|
||||
const loginInput = page
|
||||
.locator('[data-testid="login-api-key-input"], input[type="password"][placeholder*="API key"]')
|
||||
.first();
|
||||
const isLoginScreen = await loginInput.isVisible({ timeout: 2000 }).catch(() => false);
|
||||
if (isLoginScreen) {
|
||||
const apiKey = process.env.AUTOMAKER_API_KEY || 'test-api-key-for-e2e-tests';
|
||||
await loginInput.fill(apiKey);
|
||||
await page.waitForTimeout(100);
|
||||
await page
|
||||
.locator('[data-testid="login-submit-button"], button:has-text("Login")')
|
||||
.first()
|
||||
.click();
|
||||
await page.waitForURL('**/board', { timeout: 5000 });
|
||||
await page.waitForLoadState('load');
|
||||
}
|
||||
// Handle login redirect if needed
|
||||
await handleLoginScreenIfPresent(page);
|
||||
|
||||
// Wait for the board view to be visible
|
||||
await waitForElement(page, 'board-view', { timeout: 10000 });
|
||||
@@ -48,22 +35,8 @@ export async function navigateToContext(page: Page): Promise<void> {
|
||||
await page.goto('/context');
|
||||
await page.waitForLoadState('load');
|
||||
|
||||
// Check if we're on the login screen and handle it
|
||||
const loginInputCtx = page
|
||||
.locator('[data-testid="login-api-key-input"], input[type="password"][placeholder*="API key"]')
|
||||
.first();
|
||||
const isLoginScreenCtx = await loginInputCtx.isVisible({ timeout: 2000 }).catch(() => false);
|
||||
if (isLoginScreenCtx) {
|
||||
const apiKey = process.env.AUTOMAKER_API_KEY || 'test-api-key-for-e2e-tests';
|
||||
await loginInputCtx.fill(apiKey);
|
||||
await page.waitForTimeout(100);
|
||||
await page
|
||||
.locator('[data-testid="login-submit-button"], button:has-text("Login")')
|
||||
.first()
|
||||
.click();
|
||||
await page.waitForURL('**/context', { timeout: 5000 });
|
||||
await page.waitForLoadState('load');
|
||||
}
|
||||
// Handle login redirect if needed
|
||||
await handleLoginScreenIfPresent(page);
|
||||
|
||||
// Wait for loading to complete (if present)
|
||||
const loadingElement = page.locator('[data-testid="context-view-loading"]');
|
||||
@@ -127,22 +100,8 @@ export async function navigateToAgent(page: Page): Promise<void> {
|
||||
await page.goto('/agent');
|
||||
await page.waitForLoadState('load');
|
||||
|
||||
// Check if we're on the login screen and handle it
|
||||
const loginInputAgent = page
|
||||
.locator('[data-testid="login-api-key-input"], input[type="password"][placeholder*="API key"]')
|
||||
.first();
|
||||
const isLoginScreenAgent = await loginInputAgent.isVisible({ timeout: 2000 }).catch(() => false);
|
||||
if (isLoginScreenAgent) {
|
||||
const apiKey = process.env.AUTOMAKER_API_KEY || 'test-api-key-for-e2e-tests';
|
||||
await loginInputAgent.fill(apiKey);
|
||||
await page.waitForTimeout(100);
|
||||
await page
|
||||
.locator('[data-testid="login-submit-button"], button:has-text("Login")')
|
||||
.first()
|
||||
.click();
|
||||
await page.waitForURL('**/agent', { timeout: 5000 });
|
||||
await page.waitForLoadState('load');
|
||||
}
|
||||
// Handle login redirect if needed
|
||||
await handleLoginScreenIfPresent(page);
|
||||
|
||||
// Wait for the agent view to be visible
|
||||
await waitForElement(page, 'agent-view', { timeout: 10000 });
|
||||
@@ -187,24 +146,8 @@ export async function navigateToWelcome(page: Page): Promise<void> {
|
||||
await page.goto('/');
|
||||
await page.waitForLoadState('load');
|
||||
|
||||
// Check if we're on the login screen and handle it
|
||||
const loginInputWelcome = page
|
||||
.locator('[data-testid="login-api-key-input"], input[type="password"][placeholder*="API key"]')
|
||||
.first();
|
||||
const isLoginScreenWelcome = await loginInputWelcome
|
||||
.isVisible({ timeout: 2000 })
|
||||
.catch(() => false);
|
||||
if (isLoginScreenWelcome) {
|
||||
const apiKey = process.env.AUTOMAKER_API_KEY || 'test-api-key-for-e2e-tests';
|
||||
await loginInputWelcome.fill(apiKey);
|
||||
await page.waitForTimeout(100);
|
||||
await page
|
||||
.locator('[data-testid="login-submit-button"], button:has-text("Login")')
|
||||
.first()
|
||||
.click();
|
||||
await page.waitForURL('**/', { timeout: 5000 });
|
||||
await page.waitForLoadState('load');
|
||||
}
|
||||
// Handle login redirect if needed
|
||||
await handleLoginScreenIfPresent(page);
|
||||
|
||||
await waitForElement(page, 'welcome-view', { timeout: 10000 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user