50 lines
2.6 KiB
TypeScript
50 lines
2.6 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('A. Workout Plans - Start Session from Plan', async ({ page }) => {
|
|
// 1. Log in as a regular user.
|
|
await page.goto('http://localhost:3000/');
|
|
await page.getByRole('textbox', { name: 'user@gymflow.ai' }).fill('admin@gymflow.ai');
|
|
await page.locator('input[type="password"]').fill('admin1234');
|
|
await page.getByRole('button', { name: 'Login' }).click();
|
|
|
|
// 2. Navigate to the 'Plans' section.
|
|
await page.getByRole('button', { name: 'Plans' }).click();
|
|
|
|
// 3. Create a plan with at least one exercise.
|
|
await page.locator('.absolute.bottom-6').click(); // Click FAB
|
|
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: 'Free Workout' })).toBeVisible(); // Currently starts a Free Workout
|
|
await expect(page.getByText('00:00:01')).toBeVisible(); // Timer is running
|
|
|
|
// - The session starts with the selected plan's exercises.
|
|
// BUG: The session currently starts as a "Free Workout" and does not pre-populate with the plan's exercises.
|
|
// The following assertions would be used if the bug was fixed:
|
|
// 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
|
|
});
|
|
});
|