Files
gymflow/tests/sporadic-logging-log-strength-sporadic-set.spec.ts

38 lines
1.6 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('D. Sporadic Logging - Log Strength Sporadic Set', 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 'Quick Log' mode.
await page.getByRole('button', { name: 'Quick Log' }).click();
// 3. Select a Strength exercise.
await page.getByRole('textbox', { name: '0' }).fill('Bench Press');
await page.getByRole('button', { name: 'Bench Press' }).click();
// 4. Enter 'Weight' and 'Reps'.
await page.getByPlaceholder('0').nth(1).fill('80');
await page.getByPlaceholder('0').nth(2).fill('5');
// 5. Click 'Log Set'.
await page.getByRole('button', { name: 'Log Set' }).first().click();
// Expected Results:
// - The sporadic set is added to today's history in the Sporadic Logging view.
await expect(page.locator('div').filter({ hasText: /^Bench Press80 Weight \(kg\) \/ 5 Reps$/ })).toBeVisible();
// - Input fields are cleared.
await expect(page.getByPlaceholder('0').nth(1)).toHaveValue('');
await expect(page.getByPlaceholder('0').nth(2)).toHaveValue('');
// - A success message is briefly displayed.
await expect(page.getByRole('button', { name: 'Saved' })).toBeVisible();
});
});