Files
gymflow/tests/active-session-quit-session-without-saving.spec.ts

42 lines
1.8 KiB
TypeScript

// spec: specs/gymflow-test-plan.md
// seed: tests/workout-tracking.spec.ts
import { test, expect } from '@playwright/test';
test.describe('III. Workout Tracking', () => {
test('C. Active Session - Quit Session Without Saving', async ({ page }) => {
// 1. Start a 'Free Workout' session.
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();
await page.getByRole('spinbutton').fill('83');
await page.getByRole('button', { name: 'Free Workout' }).click();
// 2. Log at least one set.
await page.getByRole('textbox', { name: '0' }).fill('Bench Press');
await page.getByRole('button', { name: 'Bench Press' }).click();
await page.getByPlaceholder('0').nth(1).fill('80');
await page.getByPlaceholder('0').nth(2).fill('5');
await page.getByRole('button', { name: 'Log Set' }).click();
// 3. Click 'More' (three dots) menu.
await page.getByRole('button').filter({ hasText: /^$/ }).first().click();
// 4. Select 'Quit Without Saving'.
await page.getByRole('button', { name: 'Quit without saving' }).click();
// 5. Confirm quitting.
await page.getByRole('button', { name: 'Confirm' }).click();
// Expected Results:
// - Session data is discarded.
// NOTE: This cannot be directly verified from the UI in this step, but implicitly tested if user returns to idle state without error.
// - User is returned to the 'Idle State' of the Tracker.
await expect(page.getByRole('heading', { name: 'Ready?' })).toBeVisible();
// - No error messages.
await expect(page.locator('text=Error')).not.toBeVisible();
});
});