Files
gymflow/tests/workout-plans-delete-plan.spec.ts

40 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('A. Workout Plans - Delete Plan', async ({ page }) => {
// 1. Log in as a regular user.
await page.goto('http://192.168.50.234: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 new plan (if none exist).
// This part is handled by the previous test, but we need to ensure a plan exists for this test.
// So, we create a new plan here.
await page.getByRole('button').filter({ hasText: /^$/ }).nth(2).click(); // Click FAB
await page.getByRole('textbox', { name: 'E.g. Full-body Routine' }).fill('Plan to delete');
await page.getByRole('textbox', { name: 'Describe preparation...' }).fill('Description for plan to delete');
await page.getByRole('button', { name: 'Save' }).click();
// 4. Click the 'Delete' icon for an existing plan.
// The delete button for "Plan to delete" is the one associated with the plan.
await page.getByRole('heading', { name: 'Plan to delete' }).locator('..').getByRole('button').first().click();
// 5. Confirm deletion when prompted.
page.on('dialog', dialog => dialog.accept());
// The previous action will trigger the dialog and the above line will accept it.
// Expected Results:
// - The plan is removed from the list.
await expect(page.getByRole('heading', { name: 'Plan to delete' })).not.toBeVisible();
// - No error messages are displayed.
await expect(page.locator('text=Error')).not.toBeVisible();
});
});