Files
gymflow/tests/exercise-library-create-custom-exercise-bodyweight-with-percentage.spec.ts

45 lines
1.9 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('B. Exercise Library - Create Custom Exercise (Bodyweight with %)', 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 'Profile' section.
await page.getByRole('button', { name: 'Profile' }).click();
// 3. Expand 'Exercise Manager'.
await page.getByRole('button', { name: 'Manage Exercises' }).click();
// 4. Click 'Create Exercise'.
await page.getByRole('button', { name: 'New Exercise' }).click();
// 5. Enter an exercise name (e.g., 'Advanced Push-up').
await page.getByRole('textbox', { name: '0' }).fill('Advanced Push-up');
// 6. Select 'Bodyweight' as the type.
await page.getByRole('button', { name: 'Bodyweight' }).click();
// 7. Enter '50' for 'Body Weight Percentage'.
await page.getByPlaceholder('0').nth(1).fill('50');
// 8. Click 'Create'.
await page.getByRole('button', { name: 'Create' }).nth(1).click();
// Expected Results:
// - The new exercise appears in the exercise list.
await expect(page.getByText('Advanced Push-up')).toBeVisible();
// - The exercise type is correctly displayed as Bodyweight with 50% body weight percentage.
// NOTE: The UI does not explicitly show the percentage in the list view, but it should be saved correctly.
await expect(page.locator('div').filter({ hasText: /^Advanced Push-upBodyweight$/ }).getByText('Bodyweight')).toBeVisible();
// - No error messages.
await expect(page.locator('text=Error')).not.toBeVisible();
});
});