41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
|
|
import { test, expect } from '@playwright/test';
|
||
|
|
import { clearActiveProfile, setActiveProfile, HENDRIK_ID } from './fixtures/profile';
|
||
|
|
|
||
|
|
test.describe('Profil', () => {
|
||
|
|
test('Switcher zeigt alle 3 Profile', async ({ page }) => {
|
||
|
|
await clearActiveProfile(page);
|
||
|
|
await page.goto('/');
|
||
|
|
await page.getByRole('button', { name: 'Profil wechseln' }).click();
|
||
|
|
await expect(page.getByText('Wer kocht heute?')).toBeVisible();
|
||
|
|
for (const name of ['Hendrik', 'Verena', 'Leana']) {
|
||
|
|
await expect(
|
||
|
|
page.locator('.profile-btn', { hasText: name })
|
||
|
|
).toBeVisible();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
test('Profil-Auswahl persistiert im Header', async ({ page }) => {
|
||
|
|
await clearActiveProfile(page);
|
||
|
|
await page.goto('/');
|
||
|
|
await page.getByRole('button', { name: 'Profil wechseln' }).click();
|
||
|
|
await page.locator('.profile-btn', { hasText: 'Hendrik' }).click();
|
||
|
|
await expect(page.getByRole('button', { name: 'Profil wechseln' })).toContainText('Hendrik');
|
||
|
|
});
|
||
|
|
|
||
|
|
test('mit aktivem Profil: "Deine Favoriten"-Sektion erscheint', async ({ page }) => {
|
||
|
|
await setActiveProfile(page, HENDRIK_ID);
|
||
|
|
await page.goto('/');
|
||
|
|
await expect(
|
||
|
|
page.getByRole('heading', { level: 2, name: 'Deine Favoriten' })
|
||
|
|
).toBeVisible();
|
||
|
|
});
|
||
|
|
|
||
|
|
test('ohne Profil: Rating-Klick oeffnet Standard-Hinweis', async ({ page }) => {
|
||
|
|
await clearActiveProfile(page);
|
||
|
|
await page.goto('/recipes/66');
|
||
|
|
await page.getByRole('button', { name: '5 Sterne' }).click();
|
||
|
|
await expect(page.getByText('Kein Profil gewählt')).toBeVisible();
|
||
|
|
await expect(page.getByText(/klappt die Aktion/)).toBeVisible();
|
||
|
|
});
|
||
|
|
});
|