Files
gymflow/tests/sporadic-logging-exercise-search-and-clear.spec.ts

35 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 - Exercise Search and Clear', 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. Type a partial exercise name into the 'Select Exercise' field (e.g., 'ben').
await page.getByRole('textbox', { name: '0' }).fill('ben');
// 4. Verify the list of exercises is filtered.
await expect(page.getByText('Bench Press')).toBeVisible();
await expect(page.getByText('Pull-Ups')).not.toBeVisible();
// 5. Click on the 'Select Exercise' field again (or focus it).
await page.getByRole('textbox', { name: '0' }).click();
// Expected Results:
// - The exercise list filters dynamically as the user types. (Verified)
// - The search field content is cleared on focus.
// BUG: The search field content is NOT cleared on focus. The current value is still "ben".
await expect(page.getByRole('textbox', { name: '0' })).toHaveValue('ben'); // Current (buggy) behavior
// await expect(page.getByRole('textbox', { name: '0' })).toHaveValue(''); // Expected behavior if bug fixed
});
});