Files
HarborForge.Frontend.Test/tests/full-workflow.spec.ts

130 lines
5.0 KiB
TypeScript

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