Add full workflow test: login -> create project -> milestone -> task/meeting/support -> logout

This commit is contained in:
Zhi
2026-03-14 08:42:06 +00:00
parent 0d0a8c9a48
commit 6d79de92db

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

@@ -0,0 +1,120 @@
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
await page.click('button:has-text("Create"), button:has-text("New Project")');
await page.waitForSelector('form', { timeout: 5000 }).catch(() => {});
// Fill project form
await page.fill('input[name="name"], label:has-text("Name") input', 'Test Project');
await page.fill('input[name="description"], label:has-text("Description") input', 'Project for E2E testing');
// Submit project form
await page.click('button[type="submit"], button:has-text("Create"), button:has-text("Save")');
// 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');
// Click create milestone button
await page.click('button:has-text("Create"), button:has-text("New Milestone")');
await page.waitForSelector('form', { timeout: 5000 }).catch(() => {});
// Fill milestone form
await page.fill('input[name="title"], label:has-text("Title") input', 'Test Milestone');
await page.fill('textarea[name="description"], label:has-text("Description") textarea', 'Milestone for E2E testing');
// Submit milestone form
await page.click('button[type="submit"], button:has-text("Create"), button:has-text("Save")');
// Wait for milestone to be created
await page.waitForTimeout(2000);
console.log('✅ Milestone created');
// Step 4: Create Task (under milestone)
console.log('📝 Creating task...');
await page.goto(`${BASE_URL}/issues/new`);
await page.waitForLoadState('networkidle');
// Select issue type: Task
await page.selectOption('select[name="issue_type"], select:has-text("Type")', 'task');
await page.fill('input[name="title"], label:has-text("Title") input', 'Test Task');
await page.fill('textarea[name="description"], label:has-text("Description") textarea', 'Task for E2E testing');
await page.click('button[type="submit"], button:has-text("Create"), button:has-text("Save")');
await page.waitForTimeout(2000);
console.log('✅ Task created');
// Step 5: Create Meeting (under milestone)
console.log('📅 Creating meeting...');
await page.goto(`${BASE_URL}/issues/new`);
await page.waitForLoadState('networkidle');
// Select issue type: Meeting
await page.selectOption('select[name="issue_type"], select:has-text("Type")', 'meeting');
await page.selectOption('select[name="issue_subtype"], select:has-text("Subtype")', 'recap');
await page.fill('input[name="title"], label:has-text("Title") input', 'Test Meeting');
await page.fill('textarea[name="description"], label:has-text("Description") textarea', 'Meeting for E2E testing');
await page.click('button[type="submit"], button:has-text("Create"), button:has-text("Save")');
await page.waitForTimeout(2000);
console.log('✅ Meeting created');
// Step 6: Create Support (under milestone)
console.log('🆘 Creating support...');
await page.goto(`${BASE_URL}/issues/new`);
await page.waitForLoadState('networkidle');
// Select issue type: Support
await page.selectOption('select[name="issue_type"], select:has-text("Type")', 'support');
await page.selectOption('select[name="issue_subtype"], select:has-text("Subtype")', 'information');
await page.fill('input[name="title"], label:has-text("Title") input', 'Test Support');
await page.fill('textarea[name="description"], label:has-text("Description") textarea', 'Support request for E2E testing');
await page.click('button[type="submit"], button:has-text("Create"), button:has-text("Save")');
await page.waitForTimeout(2000);
console.log('✅ Support created');
// Step 7: Logout
console.log('🚪 Logging out...');
// Click logout button in sidebar or header
await page.click('button:has-text("Logout"), button:has-text("Sign Out")');
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 });
});
});