Compare commits

...

4 Commits

Author SHA1 Message Date
Zhi
3b9533a432 Add debug output to global setup 2026-03-14 08:47:12 +00:00
Zhi
350238f84c Fix selectors in full workflow test 2026-03-14 08:44:47 +00:00
Zhi
6d79de92db Add full workflow test: login -> create project -> milestone -> task/meeting/support -> logout 2026-03-14 08:42:06 +00:00
Zhi
0d0a8c9a48 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
2026-03-14 08:34:55 +00:00
4 changed files with 226 additions and 45 deletions

87
global-setup.ts Normal file
View File

@@ -0,0 +1,87 @@
import { chromium } from '@playwright/test';
const WIZARD_URL = process.env.WIZARD_URL || 'http://wizard:8080/wizard';
const WIZARD_API_URL = process.env.WIZARD_API_URL || 'http://wizard:8080';
async function setupWizard() {
console.log('🔧 Running global setup: Configure wizard...');
const browser = await chromium.launch();
const page = await browser.newPage();
try {
// Navigate to frontend - should redirect to wizard since not configured
const frontendURL = process.env.FRONTEND_URL || 'http://frontend:3000';
console.log(`📱 Navigating to ${frontendURL}...`);
await page.goto(frontendURL);
await page.waitForLoadState('networkidle');
// Step 0: Welcome
console.log('⏳ Waiting for wizard page...');
await page.waitForSelector('h1:has-text("HarborForge")', { timeout: 10000 });
const connectButton = page.locator('button:has-text("Connect to Wizard")');
if (await connectButton.isVisible().catch(() => false)) {
console.log('🔗 Clicking Connect to Wizard...');
await connectButton.click();
// Wait for the step to change after clicking
await page.waitForTimeout(3000);
// Check what's on the page now
const pageContent = await page.content();
console.log('Page after click:', pageContent.substring(0, 2000));
// Wait for step 1: Database
console.log('📝 Waiting for Database configuration...');
try {
await page.waitForSelector('h2:has-text("Database configuration")', { timeout: 5000 });
} catch (e) {
console.log('Could not find Database config, trying alternate selector...');
// Try waiting for any h2
await page.waitForSelector('h2', { timeout: 5000 });
console.log('Found h2:', await page.locator('h2').first().textContent());
}
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
console.log('📝 Filling Admin account...');
await page.waitForSelector('h2:has-text("Admin account")', { timeout: 10000 });
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');
await page.click('button:has-text("Next")');
// Wait for step 3: Backend URL
console.log('📝 Filling Backend URL...');
await page.waitForSelector('h2:has-text("Backend URL")', { timeout: 10000 });
const backendURL = process.env.BACKEND_URL || 'http://backend:8000';
await page.locator('label:has-text("Backend Base URL") input').fill(backendURL);
await page.click('button:has-text("Finish setup")');
// Wait for step 4: Complete
console.log('✅ Waiting for setup complete...');
await page.waitForSelector('h2:has-text("Setup complete!")', { timeout: 10000 });
console.log('✅ Wizard configured successfully!');
} else {
console.log('⚠️ Wizard already configured or on main page');
}
await browser.close();
return;
} catch (error) {
console.error('❌ Wizard setup failed:', error);
await browser.close();
throw error;
}
}
export default setupWizard;

View File

@@ -1,4 +1,5 @@
import { defineConfig, devices } from '@playwright/test';
import path from 'path';
const baseURL = process.env.FRONTEND_URL || 'http://frontend:3000';
@@ -19,5 +20,8 @@ export default defineConfig({
use: { ...devices['Desktop Chrome'] },
},
],
// Don't start webServer - services are started via docker-compose
// Global setup runs before all tests - configure wizard once
globalSetup: path.join(__dirname, 'global-setup.ts'),
// Global teardown runs after all tests
globalTeardown: undefined,
});

129
tests/full-workflow.spec.ts Normal file
View File

@@ -0,0 +1,129 @@
import { test, expect } from '@playwright/test';
const BASE_URL = process.env.BASE_URL || 'http://frontend:3000';
// Test credentials from globalSetup
const ADMIN_USERNAME = 'admin';
const ADMIN_PASSWORD = 'admin123';
test.describe('Full Workflow', () => {
test('login -> create project -> create milestone -> create task/meeting/support -> logout', async ({ page }) => {
// Step 1: Login
console.log('🔐 Logging in...');
await page.goto(`${BASE_URL}/login`);
await page.waitForLoadState('networkidle');
await page.fill('input[type="text"], input[name="username"]', ADMIN_USERNAME);
await page.fill('input[type="password"], input[name="password"]', ADMIN_PASSWORD);
await page.click('button[type="submit"], button:has-text("Login")');
// Wait for redirect after login
await page.waitForURL(`${BASE_URL}/**`, { timeout: 10000 }).catch(() => {});
await page.waitForLoadState('networkidle');
console.log('✅ Logged in');
// Step 2: Create Project
console.log('📁 Creating project...');
await page.goto(`${BASE_URL}/projects`);
await page.waitForLoadState('networkidle');
// Click create project button - it's "+ New"
await page.click('button:has-text("+ New")');
await page.waitForSelector('form.inline-form', { timeout: 5000 }).catch(() => {});
// Fill project form
await page.fill('input[placeholder="Project name"]', 'Test Project');
// Submit project form
await page.click('button:has-text("Create")');
// Wait for project to be created
await page.waitForTimeout(2000);
console.log('✅ Project created');
// Step 3: Create Milestone
console.log('🎯 Creating milestone...');
await page.goto(`${BASE_URL}/milestones`);
await page.waitForLoadState('networkidle');
// Wait for page to load
await page.waitForSelector('h2:has-text("Milestones")', { timeout: 10000 });
// Click create milestone button - it's "+ NewMilestones"
await page.click('button:has-text("+ NewMilestones")');
await page.waitForSelector('form', { timeout: 5000 }).catch(() => {});
// Fill milestone form
await page.fill('input[placeholder="Title"]', 'Test Milestone');
await page.fill('textarea[placeholder="Description"]', 'Milestone for E2E testing');
// Submit milestone form
await page.click('button:has-text("Create")');
// Wait for milestone to be created
await page.waitForTimeout(2000);
console.log('✅ Milestone created');
// Step 4: Create Task (issue type)
console.log('📝 Creating task...');
await page.goto(`${BASE_URL}/issues/new`);
await page.waitForLoadState('networkidle');
// Wait for form to load
await page.waitForSelector('select[name="issue_type"]', { timeout: 10000 });
// Select issue type: Task
await page.selectOption('select[name="issue_type"]', 'task');
await page.fill('input[placeholder="Title"]', 'Test Task');
await page.fill('textarea[placeholder="Description"]', 'Task for E2E testing');
await page.click('button:has-text("Create")');
await page.waitForTimeout(2000);
console.log('✅ Task created');
// Step 5: Create Meeting (issue type)
console.log('📅 Creating meeting...');
await page.goto(`${BASE_URL}/issues/new`);
await page.waitForLoadState('networkidle');
await page.waitForSelector('select[name="issue_type"]', { timeout: 10000 });
// Select issue type: Meeting
await page.selectOption('select[name="issue_type"]', 'meeting');
await page.selectOption('select[name="issue_subtype"]', 'recap');
await page.fill('input[placeholder="Title"]', 'Test Meeting');
await page.fill('textarea[placeholder="Description"]', 'Meeting for E2E testing');
await page.click('button:has-text("Create")');
await page.waitForTimeout(2000);
console.log('✅ Meeting created');
// Step 6: Create Support (issue type)
console.log('🆘 Creating support...');
await page.goto(`${BASE_URL}/issues/new`);
await page.waitForLoadState('networkidle');
await page.waitForSelector('select[name="issue_type"]', { timeout: 10000 });
// Select issue type: Support
await page.selectOption('select[name="issue_type"]', 'support');
await page.selectOption('select[name="issue_subtype"]', 'information');
await page.fill('input[placeholder="Title"]', 'Test Support');
await page.fill('textarea[placeholder="Description"]', 'Support request for E2E testing');
await page.click('button:has-text("Create")');
await page.waitForTimeout(2000);
console.log('✅ Support created');
// Step 7: Logout
console.log('🚪 Logging out...');
// Click logout button in sidebar
await page.click('button:has-text("Logout")');
await page.waitForURL(`${BASE_URL}/login`, { timeout: 10000 }).catch(() => {});
console.log('✅ Logged out');
// Verify we're on login page
await expect(page.locator('h1, h2')).toContainText(/Login|Sign/i, { timeout: 5000 });
});
});

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
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');
}
});
});