Files
gymflow/tests/exercise-library-edit-exercise-name.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('B. Exercise Library - Edit Exercise Name', 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();
// Create a new exercise to edit if it doesn't exist
await page.getByRole('button', { name: 'New Exercise' }).click();
await page.getByRole('textbox', { name: '0' }).fill('Exercise to Edit');
await page.getByRole('button', { name: 'Free Weights & Machines' }).click();
await page.getByRole('button', { name: 'Create' }).nth(1).click();
// 4. Click the 'Edit' icon for an existing exercise.
await page.locator('div').filter({ hasText: /^Exercise to EditFree Weights & Machines$/ }).getByRole('button').first().click();
// 5. Change the exercise name.
await page.getByRole('textbox').nth(5).fill('Edited Exercise Name');
// 6. Click 'Save'.
await page.getByRole('button', { name: 'Save', exact: true }).click();
// Expected Results:
// - The exercise name is updated in the list.
await expect(page.getByText('Edited Exercise Name')).toBeVisible();
// - No error messages.
await expect(page.locator('text=Error')).not.toBeVisible();
});
});