Compare commits
9 Commits
f50a2efdbf
...
df05820a95
| Author | SHA1 | Date | |
|---|---|---|---|
| df05820a95 | |||
| d8007fab3d | |||
| e41676fa5e | |||
| 896c1b6dbd | |||
| 24a5ed70ac | |||
| 61854829e8 | |||
| 9fdfdfe571 | |||
| b31fb01862 | |||
| 82e9dc2c86 |
@@ -6,7 +6,7 @@ const ADMIN_USERNAME = 'admin';
|
||||
const ADMIN_PASSWORD = 'admin123';
|
||||
|
||||
test.describe('Milestone Editor', () => {
|
||||
test('login -> create project -> create milestone through frontend form', async ({ page }) => {
|
||||
test('login -> create project -> create and edit milestone through modal', async ({ page }) => {
|
||||
// Step 1: Login (with retry — backend may still be warming up)
|
||||
console.log('🔐 Logging in...');
|
||||
|
||||
@@ -66,14 +66,14 @@ test.describe('Milestone Editor', () => {
|
||||
|
||||
await page.waitForSelector('button:has-text("+ New")', { timeout: 10000 });
|
||||
await page.click('button:has-text("+ New")');
|
||||
await page.waitForSelector('input[placeholder="Project name"]', { timeout: 10000 });
|
||||
await page.waitForSelector('.modal', { timeout: 10000 });
|
||||
|
||||
const projectName = 'Milestone Test Project ' + Date.now();
|
||||
console.log('Creating project with name:', projectName);
|
||||
await page.fill('input[placeholder="Project name"]', projectName);
|
||||
await page.fill('input[placeholder="Description (optional)"]', 'Project for milestone testing');
|
||||
await page.getByTestId('project-name-input').fill(projectName);
|
||||
await page.getByTestId('project-description-input').fill('Project for milestone testing');
|
||||
|
||||
await page.click('button:has-text("Create")');
|
||||
await page.click('.modal button.btn-primary:has-text("Create")');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// Wait for our specific project card to appear
|
||||
@@ -122,20 +122,27 @@ test.describe('Milestone Editor', () => {
|
||||
|
||||
// Step 5: Verify milestone was created
|
||||
console.log('🔍 Verifying milestone...');
|
||||
|
||||
// Get the heading text
|
||||
const headingText = await page.locator('h3').filter({ hasText: /Milestones/i }).textContent();
|
||||
console.log('Heading text:', headingText);
|
||||
|
||||
// Check if milestone count > 0
|
||||
const hasMilestone = headingText && /\(1?\d+\)/.test(headingText) && !headingText.includes('(0)');
|
||||
console.log('Has milestone:', hasMilestone);
|
||||
|
||||
// Verify milestone exists in UI
|
||||
expect(hasMilestone).toBe(true);
|
||||
console.log('✅ Milestone verified in UI');
|
||||
|
||||
// Note: intentionally NOT deleting the project/milestone — leave for inspection
|
||||
// Step 6: Open milestone and edit it via modal
|
||||
console.log('✏️ Editing milestone...');
|
||||
await page.click(`.milestone-item:has-text("${milestoneName}")`);
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.click('button:has-text("Edit Milestone")');
|
||||
await page.waitForSelector('.modal', { timeout: 10000 });
|
||||
|
||||
const updatedMilestoneName = `${milestoneName} Updated`;
|
||||
await page.getByTestId('milestone-title-input').fill(updatedMilestoneName);
|
||||
await page.click('.modal button.btn-primary:has-text("Save")');
|
||||
await page.waitForSelector('.modal', { state: 'detached', timeout: 10000 });
|
||||
await expect(page.locator(`h2:has-text("${updatedMilestoneName}")`)).toBeVisible({ timeout: 10000 });
|
||||
console.log('✅ Milestone edited');
|
||||
|
||||
console.log('🎉 All milestone tests passed!');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@ const ADMIN_USERNAME = 'admin';
|
||||
const ADMIN_PASSWORD = 'admin123';
|
||||
|
||||
test.describe('Project Editor', () => {
|
||||
test('login -> create project -> delete project -> logout', async ({ page }) => {
|
||||
test('login -> create project -> edit project via modal -> delete project -> logout', async ({ page }) => {
|
||||
// Step 1: Login
|
||||
console.log('🔐 Logging in...');
|
||||
await page.goto(`${BASE_URL}/login`);
|
||||
@@ -57,17 +57,14 @@ test.describe('Project Editor', () => {
|
||||
// Click create project button - it's "+ New"
|
||||
await page.waitForSelector('button:has-text("+ New")', { timeout: 10000 });
|
||||
await page.click('button:has-text("+ New")');
|
||||
// Wait for the form to appear (look for the project name input)
|
||||
await page.waitForSelector('input[placeholder="Project name"]', { timeout: 10000 });
|
||||
await page.waitForSelector('.modal', { timeout: 10000 });
|
||||
|
||||
// Fill project form with a unique, identifiable name
|
||||
const projectName = 'ProjEditor Test ' + Date.now();
|
||||
console.log('Creating project with name:', projectName);
|
||||
await page.fill('input[placeholder="Project name"]', projectName);
|
||||
await page.fill('input[placeholder="Description (optional)"]', 'Project for E2E testing');
|
||||
await page.getByTestId('project-name-input').fill(projectName);
|
||||
await page.getByTestId('project-description-input').fill('Project for E2E testing');
|
||||
|
||||
// Submit project form
|
||||
await page.click('button:has-text("Create")');
|
||||
await page.click('.modal button.btn-primary:has-text("Create")');
|
||||
|
||||
// Wait a bit for submission
|
||||
await page.waitForTimeout(2000);
|
||||
@@ -76,12 +73,23 @@ test.describe('Project Editor', () => {
|
||||
await page.waitForSelector(`.project-card:has-text("${projectName}")`, { timeout: 10000 });
|
||||
console.log('✅ Project created');
|
||||
|
||||
// Step 3: Delete the created project — click OUR project card by name
|
||||
console.log('🗑️ Deleting project...');
|
||||
|
||||
// Step 3: Edit the created project via modal
|
||||
console.log('✏️ Editing project via modal...');
|
||||
await page.click(`.project-card:has-text("${projectName}")`);
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
await page.click('button:has-text("Edit")');
|
||||
await page.waitForSelector('.modal', { timeout: 10000 });
|
||||
const updatedDescription = `Updated project description ${Date.now()}`;
|
||||
await page.getByTestId('project-description-input').fill(updatedDescription);
|
||||
await page.click('.modal button.btn-primary:has-text("Save")');
|
||||
await page.waitForSelector('.modal', { state: 'detached', timeout: 10000 });
|
||||
await expect(page.locator(`text=${updatedDescription}`)).toBeVisible({ timeout: 10000 });
|
||||
console.log('✅ Project edited');
|
||||
|
||||
// Step 4: Delete the created project — click OUR project card by name
|
||||
console.log('🗑️ Deleting project...');
|
||||
|
||||
// Look for delete button
|
||||
const deleteBtn = page.locator('button:has-text("Delete")');
|
||||
|
||||
263
tests/propose.spec.ts
Normal file
263
tests/propose.spec.ts
Normal file
@@ -0,0 +1,263 @@
|
||||
/**
|
||||
* Propose E2E Tests
|
||||
* Covers: create, list, view, edit, accept, reject, reopen flows
|
||||
*/
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
const BASE_URL = process.env.BASE_URL || process.env.FRONTEND_URL || 'http://frontend:3000';
|
||||
const ADMIN_USERNAME = 'admin';
|
||||
const ADMIN_PASSWORD = 'admin123';
|
||||
|
||||
test.describe('Propose Management', () => {
|
||||
const login = async (page: any) => {
|
||||
console.log('🔐 Logging in...');
|
||||
const MAX_LOGIN_RETRIES = 3;
|
||||
for (let attempt = 1; attempt <= MAX_LOGIN_RETRIES; attempt++) {
|
||||
console.log(`Login attempt ${attempt}/${MAX_LOGIN_RETRIES}`);
|
||||
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);
|
||||
|
||||
const loginPromise = page.waitForResponse(
|
||||
(r: any) => r.url().includes('/auth/token') && r.request().method() === 'POST',
|
||||
{ timeout: 15000 }
|
||||
).catch(() => null);
|
||||
|
||||
await page.click('button[type="submit"], button:has-text("Sign in")');
|
||||
|
||||
const loginResp = await loginPromise;
|
||||
if (loginResp && loginResp.status() === 200) {
|
||||
await page.waitForURL(`${BASE_URL}/**`, { timeout: 10000 }).catch(() => {});
|
||||
await page.waitForLoadState('networkidle');
|
||||
break;
|
||||
}
|
||||
if (attempt < MAX_LOGIN_RETRIES) {
|
||||
console.log('Retrying login in 3s...');
|
||||
await page.waitForTimeout(3000);
|
||||
}
|
||||
}
|
||||
|
||||
const token = await page.evaluate(() => localStorage.getItem('token'));
|
||||
expect(token, 'Login failed').toBeTruthy();
|
||||
console.log('✅ Logged in');
|
||||
};
|
||||
|
||||
const createProject = async (page: any, name: string) => {
|
||||
console.log(`📁 Creating project: ${name}`);
|
||||
await page.goto(`${BASE_URL}/projects`);
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.click('button:has-text("+ New")');
|
||||
await page.waitForSelector('.modal', { timeout: 10000 });
|
||||
await page.fill('.modal input[placeholder*="Project name"]', name);
|
||||
await page.fill('.modal textarea', 'Test project description');
|
||||
await page.click('.modal button:has-text("Create")');
|
||||
await page.waitForTimeout(1000);
|
||||
console.log('✅ Project created');
|
||||
};
|
||||
|
||||
const createMilestone = async (page: any, projectName: string, name: string) => {
|
||||
console.log(`📌 Creating milestone: ${name}`);
|
||||
await page.goto(`${BASE_URL}/projects`);
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.click(`.project-card:has-text("${projectName}")`);
|
||||
await page.waitForURL(/\/projects\/\d+/, { timeout: 10000 });
|
||||
await page.click('button:has-text("+ New")');
|
||||
await page.waitForSelector('.modal', { timeout: 10000 });
|
||||
await page.fill('input[data-testid="milestone-title-input"]', name);
|
||||
await page.click('.modal button:has-text("Create")');
|
||||
await page.waitForTimeout(1000);
|
||||
console.log('✅ Milestone created');
|
||||
};
|
||||
|
||||
test.describe('Propose CRUD Flow', () => {
|
||||
test('create propose -> view -> edit -> list', async ({ page }) => {
|
||||
const TS = Date.now();
|
||||
await login(page);
|
||||
const projectName = `Propose Test Project ${TS}`;
|
||||
await createProject(page, projectName);
|
||||
|
||||
// Navigate to Proposes page
|
||||
await page.goto(`${BASE_URL}/proposes`);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Select project filter
|
||||
await page.selectOption('select', { label: projectName });
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
// Create propose
|
||||
const proposeTitle = `Test Propose ${TS}`;
|
||||
const proposeDesc = `Description for propose ${TS}`;
|
||||
|
||||
await page.click('button:has-text("+ New Propose")');
|
||||
await page.waitForSelector('.modal', { timeout: 10000 });
|
||||
|
||||
await page.fill('.modal input[placeholder*="Propose title"]', proposeTitle);
|
||||
await page.fill('.modal textarea', proposeDesc);
|
||||
await page.click('.modal button:has-text("Create")');
|
||||
|
||||
// Wait for list to update
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Verify in list
|
||||
await expect(page.locator(`.milestone-card:has-text("${proposeTitle}")`)).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// View propose detail
|
||||
await page.click(`.milestone-card:has-text("${proposeTitle}")`);
|
||||
await page.waitForURL(/\/proposes\/\d+/, { timeout: 10000 });
|
||||
|
||||
// Verify detail page
|
||||
await expect(page.locator('h2')).toContainText(proposeTitle);
|
||||
await expect(page.locator('.section').filter({ has: page.locator('h3:has-text("Description")') }).locator('p')).toContainText(proposeDesc);
|
||||
await expect(page.locator('.badge:has-text("open")')).toBeVisible();
|
||||
|
||||
// Edit propose
|
||||
await page.click('button:has-text("Edit")');
|
||||
await page.waitForSelector('.modal', { timeout: 10000 });
|
||||
|
||||
const newTitle = `${proposeTitle} (edited)`;
|
||||
await page.fill('.modal input', newTitle);
|
||||
await page.click('.modal button:has-text("Save")');
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
// Verify edit
|
||||
await expect(page.locator('h2')).toContainText(newTitle);
|
||||
|
||||
console.log('✅ Propose CRUD test passed');
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Propose Lifecycle Flow', () => {
|
||||
test('accept propose -> creates feature story task', async ({ page }) => {
|
||||
const TS = Date.now();
|
||||
await login(page);
|
||||
const projectName = `Accept Propose Project ${TS}`;
|
||||
await createProject(page, projectName);
|
||||
|
||||
// Create milestone for accept
|
||||
await createMilestone(page, projectName, `Milestone for Accept ${TS}`);
|
||||
|
||||
// Create propose
|
||||
await page.goto(`${BASE_URL}/proposes`);
|
||||
await page.selectOption('select', { label: projectName });
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
const proposeTitle = `Accept Test Propose ${TS}`;
|
||||
await page.click('button:has-text("+ New Propose")');
|
||||
await page.fill('.modal input', proposeTitle);
|
||||
await page.fill('.modal textarea', 'To be accepted');
|
||||
await page.click('.modal button:has-text("Create")');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Open propose detail
|
||||
await page.click(`.milestone-card:has-text("${proposeTitle}")`);
|
||||
await page.waitForURL(/\/proposes\/\d+/, { timeout: 10000 });
|
||||
|
||||
// Accept propose
|
||||
await page.click('button:has-text("Accept")');
|
||||
await page.waitForSelector('.modal:has-text("Accept Propose")', { timeout: 10000 });
|
||||
|
||||
// Select milestone
|
||||
await page.selectOption('.modal select', { label: `Milestone for Accept ${TS}` });
|
||||
await page.click('.modal button:has-text("Confirm Accept")');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Verify status changed
|
||||
await expect(page.locator('.badge:has-text("accepted")')).toBeVisible({ timeout: 10000 });
|
||||
await expect(page.locator('button:has-text("View Generated Task")')).toBeVisible();
|
||||
|
||||
console.log('✅ Propose accept test passed');
|
||||
});
|
||||
|
||||
test('reject propose -> can reopen', async ({ page }) => {
|
||||
const TS = Date.now();
|
||||
await login(page);
|
||||
const projectName = `Reject Propose Project ${TS}`;
|
||||
await createProject(page, projectName);
|
||||
|
||||
// Create propose
|
||||
await page.goto(`${BASE_URL}/proposes`);
|
||||
await page.selectOption('select', { label: projectName });
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
const proposeTitle = `Reject Test Propose ${TS}`;
|
||||
await page.click('button:has-text("+ New Propose")');
|
||||
await page.fill('.modal input', proposeTitle);
|
||||
await page.click('.modal button:has-text("Create")');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Open propose detail
|
||||
await page.click(`.milestone-card:has-text("${proposeTitle}")`);
|
||||
await page.waitForURL(/\/proposes\/\d+/, { timeout: 10000 });
|
||||
|
||||
// Reject propose (current UI uses prompt, not modal)
|
||||
page.once('dialog', async (dialog) => {
|
||||
expect(dialog.type()).toBe('prompt');
|
||||
await dialog.accept('Rejected by automated test');
|
||||
});
|
||||
await page.click('button:has-text("Reject")');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Verify status changed
|
||||
await expect(page.locator('.badge:has-text("rejected")')).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// Reopen propose (current UI is direct action, no modal)
|
||||
await page.click('button:has-text("Reopen")');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Verify back to open
|
||||
await expect(page.locator('.badge:has-text("open")')).toBeVisible({ timeout: 10000 });
|
||||
|
||||
console.log('✅ Propose reject/reopen test passed');
|
||||
});
|
||||
|
||||
test('edit button hidden for accepted propose', async ({ page }) => {
|
||||
const TS = Date.now();
|
||||
await login(page);
|
||||
const projectName = `Edit Hidden Project ${TS}`;
|
||||
await createProject(page, projectName);
|
||||
await createMilestone(page, projectName, `Milestone ${TS}`);
|
||||
|
||||
// Create and accept propose
|
||||
await page.goto(`${BASE_URL}/proposes`);
|
||||
await page.selectOption('select', { label: projectName });
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
await page.click('button:has-text("+ New Propose")');
|
||||
await page.fill('.modal input', `Accept Test ${TS}`);
|
||||
await page.click('.modal button:has-text("Create")');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
await page.click(`.milestone-card:has-text("Accept Test")`);
|
||||
await page.waitForURL(/\/proposes\/\d+/, { timeout: 10000 });
|
||||
|
||||
// Accept
|
||||
await page.click('button:has-text("Accept")');
|
||||
await page.waitForSelector('.modal:has-text("Accept Propose")', { timeout: 10000 });
|
||||
await page.selectOption('.modal select', { label: `Milestone ${TS}` });
|
||||
await page.click('.modal button:has-text("Confirm Accept")');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Verify Edit button is hidden
|
||||
await expect(page.locator('button:has-text("Edit")')).not.toBeVisible();
|
||||
await expect(page.locator('.badge:has-text("accepted")')).toBeVisible();
|
||||
|
||||
console.log('✅ Edit button hidden test passed');
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Propose Permissions', () => {
|
||||
test('cannot create propose without project selection', async ({ page }) => {
|
||||
await login(page);
|
||||
await page.goto(`${BASE_URL}/proposes`);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Button should be disabled
|
||||
const button = page.locator('button:has-text("+ New Propose")');
|
||||
await expect(button).toBeDisabled();
|
||||
|
||||
console.log('✅ Propose create disabled test passed');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -52,10 +52,10 @@ test.describe('Task & Comment Flow', () => {
|
||||
|
||||
await page.waitForSelector('button:has-text("+ New")', { timeout: 10000 });
|
||||
await page.click('button:has-text("+ New")');
|
||||
await page.waitForSelector('input[placeholder="Project name"]', { timeout: 10000 });
|
||||
await page.fill('input[placeholder="Project name"]', projectName);
|
||||
await page.fill('input[placeholder="Description (optional)"]', 'Project for task & comment testing');
|
||||
await page.click('button:has-text("Create")');
|
||||
await page.waitForSelector('.modal', { timeout: 10000 });
|
||||
await page.getByTestId('project-name-input').fill(projectName);
|
||||
await page.getByTestId('project-description-input').fill('Project for task & comment testing');
|
||||
await page.click('.modal button.btn-primary:has-text("Create")');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
await page.waitForSelector(`.project-card:has-text("${projectName}")`, { timeout: 10000 });
|
||||
@@ -117,6 +117,19 @@ test.describe('Task & Comment Flow', () => {
|
||||
await expect(taskRow).toBeVisible({ timeout: 10000 });
|
||||
console.log('✅ Task created and verified');
|
||||
|
||||
// Edit the created task via task detail modal
|
||||
console.log('✏️ Editing created task...');
|
||||
await taskRow.click();
|
||||
await page.waitForURL(/\/tasks\/\d+$/, { timeout: 10000 });
|
||||
await page.click('button:has-text("Edit Task")');
|
||||
await page.waitForSelector('.modal.task-create-modal', { timeout: 10000 });
|
||||
const updatedTaskTitle = `${taskTitle} Updated`;
|
||||
await page.getByTestId('task-title-input').fill(updatedTaskTitle);
|
||||
await page.getByTestId('create-task-button').click();
|
||||
await page.waitForSelector('.modal.task-create-modal', { state: 'detached', timeout: 10000 });
|
||||
await expect(page.locator(`h2:has-text("${updatedTaskTitle}")`)).toBeVisible({ timeout: 10000 });
|
||||
console.log('✅ Task edited and verified');
|
||||
|
||||
// ── Step 5: Create a Task item (for comment testing) ───────────────
|
||||
// Milestone tasks don't have a detail page with comments, so we create
|
||||
// a Task item from the shared Tasks-page modal to test the comment flow.
|
||||
@@ -144,7 +157,7 @@ test.describe('Task & Comment Flow', () => {
|
||||
console.log('Milestone options:', msOptions);
|
||||
await milestoneSelect.selectOption({ label: milestoneName });
|
||||
|
||||
await page.getByTestId('task-type-select').selectOption('task');
|
||||
await page.getByTestId('task-type-select').selectOption('issue');
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
const createTaskResponsePromise = page.waitForResponse((response) => {
|
||||
|
||||
Reference in New Issue
Block a user