Files
kochwas/tests/e2e/remote/preview.spec.ts

30 lines
1.2 KiB
TypeScript
Raw Normal View History

import { test, expect } from '@playwright/test';
test.describe('Preview-Route', () => {
test('ohne ?url= zeigt Guard-Fehlermeldung', async ({ page }) => {
await page.goto('/preview');
await expect(page.getByText(/Kein \?url=-Parameter/)).toBeVisible();
await expect(page.getByRole('heading', { name: /kein Rezept/i })).toBeVisible();
});
test('mit echter URL laedt Vorschau + Speichern-Button', async ({ page }) => {
const u = encodeURIComponent('https://emmikochteinfach.de/chicken-teriyaki/');
await page.goto(`/preview?url=${u}`);
await expect(page.getByText('Vorschau — noch nicht gespeichert')).toBeVisible({
timeout: 20000
});
await expect(page.getByRole('button', { name: /speichern/i })).toBeVisible();
// Zutaten aus dem JSON-LD sollten geparst sein.
await expect(page.getByText(/Hähnchenbrustfilet/i).first()).toBeVisible();
});
test('mit unparsbarer URL zeigt error-box', async ({ page }) => {
// google.com hat kein Recipe-JSON-LD -> Parser-Fehler.
const u = encodeURIComponent('https://www.google.com');
await page.goto(`/preview?url=${u}`);
await expect(page.getByRole('heading', { name: /kein Rezept/i })).toBeVisible({
timeout: 20000
});
});
});