Files
gymflow/tests/workout-plans-start-session-from-plan.spec.ts
2025-12-03 18:01:36 +02:00

56 lines
3.1 KiB
TypeScript

// spec: specs/gymflow-test-plan.md
// seed: tests/workout-management.spec.ts
import { test, expect } from '@playwright/test';
test.describe('II. Workout Management', () => {
test.fixme('A. Workout Plans - Start Session from Plan', async ({ page }) => {
// This test is currently skipped because the application has a known bug:
// "The session currently starts as a "Free Workout" and does not pre-populate with the plan's exercises."
// This test correctly asserts the expected behavior (session starts with plan exercises),
// but the application itself is not behaving as expected.
// This test should only pass once the underlying application bug is resolved.
// 1. Log in as a regular user.
await page.goto('http://localhost:3000/');
await page.getByRole('textbox', { name: 'user@gymflow.ai' }).fill('test@e2e.com');
await page.locator('input[type="password"]').fill('e2e');
await page.getByRole('button', { name: 'Login' }).click();
// 2. Navigate to the 'Plans' section.
await page.getByRole('button', { name: 'Plans' }).click();
// Pre-cleanup: Delete "Start Session Test Plan" if it already exists
if (await page.getByRole('heading', { name: 'Start Session Test Plan', exact: true }).isVisible()) {
await page.locator('div').filter({ has: page.getByRole('heading', { name: 'Start Session Test Plan', exact: true }) }).locator('button[title="Delete"]').click();
await page.getByRole('button', { name: 'Delete' }).click(); // Confirm deletion
await expect(page.getByRole('heading', { name: 'Start Session Test Plan', exact: true })).not.toBeVisible();
}
// 3. Create a plan with at least one exercise.
await page.getByRole('button', { name: 'Add' }).click();
await page.getByRole('textbox', { name: 'E.g. Full-body Routine' }).fill('Start Session Test Plan');
await page.getByRole('textbox', { name: 'Describe preparation...' }).fill('Test plan for starting a session');
await page.getByRole('button', { name: 'Add Exercise' }).click();
await page.getByRole('button', { name: 'Squats BODYWEIGHT' }).click();
await page.getByRole('button', { name: 'Add Exercise' }).click();
await page.getByRole('button', { name: 'Pull-Ups BODYWEIGHT' }).click();
await page.getByRole('button', { name: 'Save' }).click();
// 4. Click 'Start' button for the created plan.
await page.getByRole('button', { name: 'Start' }).nth(2).click();
// 5. If a plan description is present, confirm the plan start.
// NOTE: The UI does not provide an explicit confirmation for starting a plan.
// The previous action directly starts a session.
// Expected Results:
// - The application transitions to the 'Active Session' view.
await expect(page.getByRole('heading', { name: 'Start Session Test Plan' })).toBeVisible();
await expect(page.locator('text=Squats')).toBeVisible();
await expect(page.locator('text=Pull-Ups')).toBeVisible();
// - The timer starts running.
await expect(page.getByText(/(\d{2}:){2}\d{2}/)).toBeVisible(); // Checks for a time format like HH:MM:SS
});
});