Files
gymflow/tests/session-history-delete-sporadic-set.spec.ts
2025-12-06 20:21:41 +02:00

39 lines
1.7 KiB
TypeScript

// spec: specs/gymflow-test-plan.md
// seed: tests/data-progress.spec.ts
import { test, expect } from '@playwright/test';
test.describe('IV. Data & Progress', () => {
test('A. Session History - Delete Sporadic Set', async ({ page }) => {
// 1. Log in as a regular user.
await page.goto('http://localhost:3000/');
await page.locator('input[type="email"]').fill('admin@gymflow.ai');
await page.locator('input[type="password"]').fill('admin123');
await page.getByRole('button', { name: 'Login' }).click();
// 2. Log at least one sporadic set.
await page.getByRole('button', { name: 'Quick Log' }).click();
await page.getByRole('textbox', { name: '0' }).fill('Bench Press');
await page.getByRole('button', { name: 'Bench Press' }).click();
await page.getByPlaceholder('0').nth(1).fill('80');
await page.getByPlaceholder('0').nth(2).fill('5');
await page.getByRole('button', { name: 'Log Set' }).first().click();
// 3. Navigate to the 'History' section.
await page.getByRole('button', { name: 'History' }).click();
// 4. Locate and click the 'Delete' icon for a sporadic set.
// The most recent sporadic set is displayed first.
await page.locator('.bg-surface-container-low > .flex > .p-2.text-on-surface-variant.hover\\:text-error').first().click();
// 5. Confirm deletion.
await page.getByRole('button', { name: 'Delete' }).click();
// Expected Results:
// - The sporadic set is permanently removed from the history.
await expect(page.locator('div').filter({ hasText: /^Bench Press80kg x 511:59 AM$/ })).not.toBeVisible();
// - No error messages.
await expect(page.locator('text=Error')).not.toBeVisible();
});
});