// 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 - Log Cardio Set', async ({ page }) => { // 1. Start a 'Free Workout' session. 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(); await page.getByRole('spinbutton').fill('83'); await page.getByRole('button', { name: 'Free Workout' }).click(); // Ensure Running exercise exists for selection // (This part would ideally be handled by seed data or a setup step) // For now, assuming "Running" is available from previous manual creation or seed. // 2. Select a Cardio exercise (e.g., 'Running'). await page.getByRole('textbox', { name: '0' }).fill('Running'); await page.getByRole('button', { name: 'Running' }).click(); // 3. Enter 'Time (sec)' (e.g., '300') and 'Distance (m)' (e.g., '1000'). await page.getByPlaceholder('0').nth(1).fill('300'); await page.getByPlaceholder('0').nth(2).fill('1000'); // 4. Click 'Log Set'. await page.getByRole('button', { name: 'Log Set' }).click(); // Expected Results: // - The set is added to the session history. await expect(page.locator('div').filter({ hasText: /^1Running300s \/ 1000m$/ }).getByText('Running')).toBeVisible(); // - Input fields are cleared. await expect(page.getByPlaceholder('0').nth(1)).toHaveValue(''); await expect(page.getByPlaceholder('0').nth(2)).toHaveValue(''); // - No error messages are displayed. await expect(page.locator('text=Error')).not.toBeVisible(); }); });