Files
gymflow/tests/performance-statistics-view-set-count-chart.spec.ts

50 lines
2.6 KiB
TypeScript

// spec: specs/gymflow-test-plan.md
// seed: tests/data-progress.spec.ts
import { test, expect } from '@playwright/test';
test.describe('IV. Data & Progress', () => {
test('B. Performance Statistics - View Set Count Chart', 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 two workout sessions with logged sets.
// Session 1
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();
// Session 2
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('90'); // Different weight for verification
await page.getByPlaceholder('0').nth(2).fill('6'); // Different reps for verification
await page.getByRole('button', { name: 'Log Set' }).click();
await page.getByRole('button', { name: 'Finish' }).click();
await page.getByRole('button', { name: 'Confirm' }).click();
// 3. Navigate to the 'Stats' section.
await page.getByRole('button', { name: 'Stats' }).click();
// Expected Results:
// - The 'Set Count' bar chart is displayed.
await expect(page.getByRole('heading', { name: 'Number of Sets' })).toBeVisible();
// - The chart accurately reflects the number of sets performed per session over time.
// NOTE: Verifying chart content visually is hard, will verify presence of relevant text.
await expect(page.getByText('0')).toBeVisible(); // Check for some values on the chart axis
await expect(page.getByText('3')).toBeVisible(); // Check for some values on the chart axis
await expect(page.getByText('6')).toBeVisible(); // Check for some values on the chart axis
});
});