ecbbeb2cec
CI / Generate TypeScript types (push) Successful in 9s
CI / Generate TypeScript types (pull_request) Successful in 11s
CI / Server unit tests (push) Successful in 22s
CI / Build server (push) Successful in 29s
CI / Server unit tests (pull_request) Successful in 25s
CI / Build client (push) Successful in 34s
CI / Build server (pull_request) Successful in 30s
CI / Build client (pull_request) Successful in 32s
CI / Playwright E2E tests (push) Failing after 1m48s
CI / Build and push Docker image (push) Has been skipped
CI / Notify (push) Successful in 4s
CI / Playwright E2E tests (pull_request) Failing after 1m48s
CI / Build and push Docker image (pull_request) Has been skipped
CI / Notify (pull_request) Has been skipped
74 lines
3.6 KiB
TypeScript
74 lines
3.6 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
||
|
||
// Pizza day testy musí běžet sekvenčně (sdílejí stav mock dne)
|
||
test.describe.serial('pizza day životní cyklus', () => {
|
||
|
||
test.beforeEach(async ({ request }) => {
|
||
// Vyčistíme data mock dne před každým testem
|
||
await request.post('/api/dev/clear', { data: { dayIndex: 4 } });
|
||
});
|
||
|
||
test('zobrazí sekci Pizza Day bez aktivního dne', async ({ page }) => {
|
||
await page.goto('/');
|
||
await page.waitForLoadState('networkidle');
|
||
// Sekce pizza-section se zobrazí jen pokud má uživatel zvolenou možnost "Pizza day"
|
||
await page.locator('select').selectOption({ label: 'Pizza day' });
|
||
await page.waitForLoadState('networkidle');
|
||
const pizzaSection = page.locator('.pizza-section');
|
||
await expect(pizzaSection).toBeVisible({ timeout: 10_000 });
|
||
await expect(pizzaSection.locator('text=není aktuálně založen')).toBeVisible();
|
||
});
|
||
|
||
test('vytvoří, uzamkne a dokončí pizza day', async ({ page }) => {
|
||
await page.goto('/');
|
||
await page.waitForLoadState('networkidle');
|
||
// Sekce pizza-section se zobrazí jen pokud má uživatel zvolenou možnost "Pizza day"
|
||
await page.locator('select').selectOption({ label: 'Pizza day' });
|
||
await page.waitForLoadState('networkidle');
|
||
|
||
// --- CREATED ---
|
||
const createBtn = page.locator('.pizza-section button', { hasText: 'Založit Pizza day' });
|
||
await expect(createBtn).toBeVisible({ timeout: 10_000 });
|
||
await createBtn.click();
|
||
// Reload zajistí aktuální stav – aktualizace přichází přes WebSocket, který networkidle nečeká
|
||
await page.reload();
|
||
await page.waitForLoadState('networkidle');
|
||
await expect(page.locator('.pizza-section')).toContainText('spravován uživatelem', { timeout: 5_000 });
|
||
|
||
// Přidáme pizzu přes API (obejde komplex SelectSearch)
|
||
const token = await page.evaluate(() => localStorage.getItem('token'));
|
||
const addResp = await page.request.post('/api/pizza/add', {
|
||
headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' },
|
||
data: { pizzaIndex: 0, pizzaSizeIndex: 0 },
|
||
});
|
||
expect(addResp.ok()).toBeTruthy();
|
||
|
||
// Reload – server aktualizoval data přes WebSocket, ale reload je jistější
|
||
await page.reload();
|
||
await page.waitForLoadState('networkidle');
|
||
|
||
// --- LOCK ---
|
||
const lockBtn = page.locator('.pizza-section button', { hasText: 'Uzamknout' });
|
||
await expect(lockBtn).toBeEnabled({ timeout: 5_000 });
|
||
await lockBtn.click();
|
||
await page.waitForLoadState('networkidle');
|
||
await expect(page.locator('.pizza-section')).toContainText('uzamčeny', { timeout: 5_000 });
|
||
|
||
// --- ORDERED ---
|
||
const orderBtn = page.locator('.pizza-section button', { hasText: 'Objednáno' });
|
||
await expect(orderBtn).toBeEnabled({ timeout: 5_000 });
|
||
await orderBtn.click();
|
||
await page.waitForLoadState('networkidle');
|
||
await expect(page.locator('.pizza-section')).toContainText('objednány', { timeout: 5_000 });
|
||
|
||
// --- DELIVERED ---
|
||
const deliverBtn = page.locator('.pizza-section button', { hasText: 'Doručeno' });
|
||
await expect(deliverBtn).toBeVisible({ timeout: 5_000 });
|
||
// window.confirm dialog − Playwright automaticky potvrdí
|
||
page.on('dialog', dialog => dialog.accept());
|
||
await deliverBtn.click();
|
||
await page.waitForLoadState('networkidle');
|
||
await expect(page.locator('.pizza-section')).toContainText('doručeny', { timeout: 5_000 });
|
||
});
|
||
});
|