Convert wizard setup to globalSetup

- global-setup.ts: configures wizard before tests run
- playwright.config.ts: uses globalSetup
- wizard.spec.ts: simplified to just verify frontend loads
This commit is contained in:
Zhi
2026-03-14 08:34:55 +00:00
parent db9fadd13d
commit 0d0a8c9a48
3 changed files with 81 additions and 45 deletions

View File

@@ -3,52 +3,13 @@ import { test, expect } from '@playwright/test';
const FRONTEND_URL = process.env.FRONTEND_URL || 'http://frontend:3000';
test.describe('Setup Wizard', () => {
test('complete wizard flow through frontend', async ({ page }) => {
// Navigate to frontend
await page.goto(FRONTEND_URL);
test('frontend loads and shows main page after wizard configuration', async ({ page }) => {
// Navigate to frontend - wizard should be configured by globalSetup
await page.goto(FRONTEND_URL);
await page.waitForLoadState('networkidle');
// Step 0: Welcome
// Should now show main page (not wizard redirect)
// After wizard config, frontend should load normally
await expect(page.locator('h1')).toContainText('HarborForge', { timeout: 10000 });
const connectButton = page.locator('button:has-text("Connect to Wizard")');
if (await connectButton.isVisible().catch(() => false)) {
await connectButton.click();
// Wait for step 1: Database
await page.waitForSelector('h2:has-text("Database configuration")', { timeout: 10000 });
await page.locator('label:has-text("Host") input').fill('mysql');
await page.locator('label:has-text("Port") input').fill('3306');
await page.locator('label:has-text("Username") input').fill('harborforge');
await page.locator('label:has-text("Password") input').fill('harborforge_pass');
await page.locator('label:has-text("Database") input').fill('harborforge');
await page.click('button:has-text("Next")');
// Wait for step 2: Admin
await page.waitForSelector('h2:has-text("Admin account")', { timeout: 10000 });
// Debug: print page content before filling
console.log('Page URL at Admin step:', page.url());
console.log('Page content:', await page.content());
await page.locator('label:has-text("Password") input').fill('admin123');
await page.locator('label:has-text("Email") input').fill('admin@test.com');
await page.locator('label:has-text("Full name") input').fill('Test Admin');
// Click Next - might fail if password is empty (validation)
await page.click('button:has-text("Next")');
// Wait for step 3: Backend URL
await page.waitForSelector('h2:has-text("Backend URL")', { timeout: 15000 });
await page.locator('label:has-text("Backend Base URL") input').fill('http://backend:8000');
await page.click('button:has-text("Finish setup")');
// Wait for step 4: Complete
await expect(page.locator('h2')).toContainText('Setup complete!', { timeout: 10000 });
} else {
// Wizard was already configured
await expect(page.locator('h1')).toContainText('HarborForge');
}
});
});