Files
gymflow/tests/workout-plans-create-new-plan.spec.ts

42 lines
1.8 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 - Create New 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. Click the 'Add New Plan' or '+' FAB button.
await page.getByRole('button').filter({ hasText: /^$/ }).nth(2).click();
// 4. Enter a 'Plan Name' (e.g., 'My New Strength Plan').
await page.getByRole('textbox', { name: 'E.g. Full-body Routine' }).fill('My New Strength Plan');
// 5. Enter a 'Description' (e.g., 'Focus on compound lifts').
await page.getByRole('textbox', { name: 'Describe preparation...' }).fill('Focus on compound lifts');
// 6. Add an exercise to the plan.
await page.getByRole('button', { name: 'Add Exercise' }).click();
await page.getByRole('button', { name: 'Squats BODYWEIGHT' }).click();
// 7. Click 'Save'.
await page.getByRole('button', { name: 'Save' }).click();
// Expected Results:
// - A new plan with the specified name and description appears in the plans list.
await expect(page.getByRole('heading', { name: 'My New Strength Plan', exact: true })).toBeVisible();
// - The plan contains the added exercise.
await expect(page.locator('div').filter({ hasText: /^1 exercises$/ })).toBeVisible();
// - No error messages are displayed.
await expect(page.locator('text=Error')).not.toBeVisible();
});
});