// spec: specs/gymflow-test-plan.md // seed: tests/data-progress.spec.ts import { test, expect } from '@playwright/test'; test.describe('IV. Data & Progress', () => { test('A. Session History - View Past Sessions', 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. Complete at least one workout session and log at least one sporadic set. // Start a Free Workout session, log a set, and finish it. await page.getByRole('spinbutton').fill('83'); await page.getByRole('button', { name: 'Free Workout' }).click(); 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(); await page.getByRole('button', { name: 'Finish' }).click(); await page.getByRole('button', { name: 'Confirm' }).click(); // Log a sporadic set. await page.getByRole('button', { name: 'Quick Log' }).click(); 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' }).first().click(); // 3. Navigate to the 'History' section. await page.getByRole('button', { name: 'History' }).click(); // Expected Results: // - All past workout sessions and sporadic sets are displayed, grouped by date. await expect(page.getByRole('heading', { name: 'History' })).toBeVisible(); await expect(page.locator('div').filter({ hasText: 'Bench Press' })).toBeVisible(); // Check for logged session await expect(page.locator('div').filter({ hasText: '80kg / 5 reps' })).toBeVisible(); // Check for logged sporadic set // - Each entry shows key summary information (date, duration, plan name, total work, exercise count). await expect(page.locator('div').filter({ hasText: /^\d{4}-\d{2}-\d{2} \d{2}:\d{2} [ap]m \d{1,2}m No plan 83kgSets: \d{1,2}0.\d{1,2}t$/ })).toBeVisible(); // Example check for a workout session summary await expect(page.locator('div').filter({ hasText: /^\d{4}-\d{2}-\d{2}Bench Press80 Weight \(kg\) \/ 5 Reps$/ })).toBeVisible(); // Example check for a sporadic set summary }); });