Files
gymflow/tests/ai-coach-send-a-message.spec.ts

32 lines
1.4 KiB
TypeScript

// spec: specs/gymflow-test-plan.md
// seed: tests/user-system-management.spec.ts
import { test, expect } from '@playwright/test';
test.describe('V. User & System Management', () => {
test('B. AI Coach - Send a Message', 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. Navigate to the 'AI Coach' section.
await page.getByRole('button', { name: 'AI Coach' }).click();
// 3. Type a message into the input field (e.g., 'What's a good workout for chest?').
await page.getByRole('textbox', { name: 'Ask about workouts...' }).fill('What\'s a good workout for chest?');
// 4. Click 'Send' button.
await page.getByRole('button').filter({ hasText: /^$/ }).click();
// Expected Results:
// - User's message appears in the chat.
await expect(page.getByText('What\'s a good workout for chest?')).toBeVisible();
// - AI Coach responds with relevant advice.
await expect(page.getByText('Based on your workout history and personal records, a good chest workout could include Bench Press and Dips.')).toBeVisible();
// - No error messages.
await expect(page.locator('text=Error')).not.toBeVisible();
});
});