Expand e2e test coverage migrate to API-based data setup

This commit is contained in:
Gregor Vostrak
2026-02-09 15:41:53 +01:00
parent bbe05ca0d8
commit 1ecb332458
24 changed files with 3043 additions and 819 deletions

View File

@@ -2,13 +2,13 @@ import { expect } from '@playwright/test';
import type { Page } from '@playwright/test';
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
import { test } from '../playwright/fixtures';
import { createProjectViaApi, createTaskViaApi, createClientViaApi } from './utils/api';
async function goToProjectsOverview(page: Page) {
await page.goto(PLAYWRIGHT_BASE_URL + '/projects');
}
// Create new project via modal
test('test that creating and deleting a new tag in a new project works', async ({ page }) => {
test('test that creating and deleting a new task in a new project works', async ({ page }) => {
const newProjectName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
await goToProjectsOverview(page);
await page.getByRole('button', { name: 'Create Project' }).click();
@@ -28,11 +28,9 @@ test('test that creating and deleting a new tag in a new project works', async (
]);
await expect(page.getByTestId('project_table')).toContainText(newProjectName);
await page.getByText(newProjectName).click();
const newTaskName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
const newTaskName = 'New Task ' + Math.floor(1 + Math.random() * 10000);
await page.getByRole('button', { name: 'Create Task' }).click();
await page.getByPlaceholder('Task Name').fill(newTaskName);
@@ -84,23 +82,14 @@ test('test that creating and deleting a new tag in a new project works', async (
await expect(page.getByTestId('project_table')).not.toContainText(newProjectName);
});
test('test that archiving and unarchiving tasks works', async ({ page }) => {
test('test that archiving and unarchiving tasks works', async ({ page, ctx }) => {
const newProjectName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
const newTaskName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
const newTaskName = 'New Task ' + Math.floor(1 + Math.random() * 10000);
await goToProjectsOverview(page);
await page.getByRole('button', { name: 'Create Project' }).click();
await page.getByLabel('Project Name').fill(newProjectName);
await page.getByRole('button', { name: 'Create Project' }).click();
await expect(page.getByText(newProjectName)).toBeVisible();
await page.getByText(newProjectName).click();
await page.getByRole('button', { name: 'Create Task' }).click();
await page.getByPlaceholder('Task Name').fill(newTaskName);
await page.getByRole('button', { name: 'Create Task' }).click();
const project = await createProjectViaApi(ctx, { name: newProjectName });
await createTaskViaApi(ctx, { name: newTaskName, project_id: project.id });
await page.goto(PLAYWRIGHT_BASE_URL + '/projects/' + project.id);
await expect(page.getByRole('table')).toContainText(newTaskName);
await page.getByRole('row').first().getByRole('button').click();
@@ -124,14 +113,78 @@ test('test that archiving and unarchiving tasks works', async ({ page }) => {
]);
});
// Create new project with new Client
test('test that editing a task name works', async ({ page, ctx }) => {
const projectName = 'TaskEdit Project ' + Math.floor(1 + Math.random() * 10000);
const originalTaskName = 'Original Task ' + Math.floor(1 + Math.random() * 10000);
const updatedTaskName = 'Updated Task ' + Math.floor(1 + Math.random() * 10000);
// Create new project with existing Client
const project = await createProjectViaApi(ctx, { name: projectName });
await createTaskViaApi(ctx, { name: originalTaskName, project_id: project.id });
// Delete project via More Options
await page.goto(PLAYWRIGHT_BASE_URL + '/projects/' + project.id);
await expect(page.getByTestId('task_table')).toContainText(originalTaskName);
// Test that project task count is displayed correctly
// Open actions menu and click Edit
const moreButton = page.locator("[aria-label='Actions for Task " + originalTaskName + "']");
await moreButton.click();
await page.getByRole('menuitem').getByText('Edit').click();
// Test that active / archive / all filter works (once implemented)
// Update the task name
await expect(page.getByRole('dialog')).toBeVisible();
await page.getByPlaceholder('Task Name').fill(updatedTaskName);
await Promise.all([
page.getByRole('button', { name: 'Update Task' }).click(),
page.waitForResponse(
(response) =>
response.url().includes('/tasks') &&
response.request().method() === 'PUT' &&
response.status() === 200
),
]);
// Test update task name
await expect(page.getByTestId('task_table')).toContainText(updatedTaskName);
await expect(page.getByTestId('task_table')).not.toContainText(originalTaskName);
});
test('test that creating a project with an existing client works', async ({ page, ctx }) => {
const clientName = 'Existing Client ' + Math.floor(1 + Math.random() * 10000);
const projectName = 'Project With Client ' + Math.floor(1 + Math.random() * 10000);
await createClientViaApi(ctx, { name: clientName });
await goToProjectsOverview(page);
await page.getByRole('button', { name: 'Create Project' }).click();
await page.getByLabel('Project Name').fill(projectName);
// Select the existing client
await page.getByRole('dialog').getByRole('button', { name: 'No Client' }).click();
await page.getByRole('option', { name: clientName }).click();
await Promise.all([
page.getByRole('dialog').getByRole('button', { name: 'Create Project' }).click(),
page.waitForResponse(
async (response) =>
response.url().includes('/projects') &&
response.request().method() === 'POST' &&
response.status() === 201 &&
(await response.json()).data.client_id !== null
),
]);
await expect(page.getByTestId('project_table')).toContainText(projectName);
await expect(page.getByTestId('project_table')).toContainText(clientName);
});
test('test that multiple tasks are displayed on project detail page', async ({ page, ctx }) => {
const projectName = 'TaskCount Project ' + Math.floor(1 + Math.random() * 10000);
const taskName1 = 'CountTask A ' + Math.floor(1 + Math.random() * 10000);
const taskName2 = 'CountTask B ' + Math.floor(1 + Math.random() * 10000);
const project = await createProjectViaApi(ctx, { name: projectName });
await createTaskViaApi(ctx, { name: taskName1, project_id: project.id });
await createTaskViaApi(ctx, { name: taskName2, project_id: project.id });
await page.goto(PLAYWRIGHT_BASE_URL + '/projects/' + project.id);
await expect(page.getByText(taskName1)).toBeVisible();
await expect(page.getByText(taskName2)).toBeVisible();
});