1 Commits

Author SHA1 Message Date
mates 1e13a1d02b test: opravy Playwright testů
CI / Generate TypeScript types (pull_request) Failing after 7s
CI / Server unit tests (pull_request) Has been skipped
CI / Build server (pull_request) Has been skipped
CI / Build client (pull_request) Has been skipped
CI / Playwright E2E tests (pull_request) Has been skipped
CI / Build and push Docker image (pull_request) Has been skipped
CI / Notify (pull_request) Has been skipped
CI / Generate TypeScript types (push) Successful in 10s
CI / Build server (push) Failing after 7s
CI / Build client (push) Failing after 8s
CI / Playwright E2E tests (push) Has been skipped
CI / Server unit tests (push) Successful in 20s
CI / Build and push Docker image (push) Has been skipped
CI / Notify (push) Successful in 3s
2026-04-29 20:56:48 +02:00
5 changed files with 19 additions and 29 deletions
+5 -5
View File
@@ -24,7 +24,7 @@ jobs:
with:
node-version: "22"
- run: corepack enable
- run: npm install -g yarn
- run: cd types && yarn install --frozen-lockfile && yarn openapi-ts
@@ -51,7 +51,7 @@ jobs:
with:
node-version: "22"
- run: corepack enable
- run: npm install -g yarn
- uses: actions/download-artifact@v3
with:
@@ -73,7 +73,7 @@ jobs:
with:
node-version: "22"
- run: corepack enable
- run: npm install -g yarn
- uses: actions/download-artifact@v3
with:
@@ -102,7 +102,7 @@ jobs:
with:
node-version: "22"
- run: corepack enable
- run: npm install -g yarn
- uses: actions/download-artifact@v3
with:
@@ -189,7 +189,7 @@ jobs:
with:
node-version: "22"
- run: corepack enable
- run: npm install -g yarn
- uses: actions/download-artifact@v3
with:
+5 -8
View File
@@ -11,14 +11,11 @@ export async function loginViaApi(page: Page, login: string): Promise<void> {
await page.evaluate((t) => localStorage.setItem('token', t), token);
}
/** Vyčistí stav dne pro zadaný dayIndex (0=pondělí…4=pátek) přes dev API.
* /api/dev/* vyžaduje JWT nejdřív získáme token přes /api/login.
*/
export async function clearDay(request: APIRequestContext, dayIndex = 4): Promise<void> {
const loginResp = await request.post('/api/login', { data: {} });
const token = await loginResp.json() as string;
/** Vyčistí stav pizza dne pro zadaný dayIndex (0=pondělí…4=pátek) přes dev API. */
export async function clearPizzaDay(request: APIRequestContext): Promise<void> {
const today = new Date('2025-01-10'); // MOCK_DATA pins to Friday = dayIndex 4
await request.post('/api/dev/clear', {
headers: { Authorization: `Bearer ${token}` },
data: { dayIndex },
headers: { 'Content-Type': 'application/json', 'remote-user': 'e2e-user' },
data: { dayIndex: 4 },
});
}
+4 -2
View File
@@ -1,9 +1,11 @@
import { test, expect } from '@playwright/test';
import { clearDay } from './helpers';
import { clearPizzaDay } from './helpers';
test.beforeEach(async ({ page, request }) => {
// Vyčistíme volby dne, aby testy neovlivnily navzájem
await clearDay(request);
await request.post('/api/dev/clear', {
data: { dayIndex: 4 },
});
await page.goto('/');
await page.waitForLoadState('networkidle');
// Počkáme, až se zobrazí volba stravování
+4 -12
View File
@@ -1,12 +1,11 @@
import { test, expect } from '@playwright/test';
import { clearDay } from './helpers';
// 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 clearDay(request);
await request.post('/api/dev/clear', { data: { dayIndex: 4 } });
});
test('zobrazí sekci Pizza Day bez aktivního dne', async ({ page }) => {
@@ -21,26 +20,17 @@ test.describe.serial('pizza day životní cyklus', () => {
});
test('vytvoří, uzamkne a dokončí pizza day', async ({ page }) => {
// Tento test má více kroků a server při MOCK_DATA=true záměrně zpožďuje scraping pizz o 3s
test.setTimeout(60_000);
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');
// Přijmeme všechny window.confirm() dialogy v celém testu (vytvoření i doručení pizza dne)
page.on('dialog', dialog => dialog.accept());
// --- CREATED ---
const createBtn = page.locator('.pizza-section button', { hasText: 'Založit Pizza day' });
await expect(createBtn).toBeVisible({ timeout: 10_000 });
// Čekáme na odpověď API před reloadem jinak by reload přerušil probíhající request
// Server s MOCK_DATA=true záměrně zpožďuje stahování pizz o 3s, proto velkorysý timeout
const createResponse = page.waitForResponse(
resp => resp.url().includes('/api/pizzaDay/create'),
{ timeout: 15_000 },
);
const createResponse = page.waitForResponse(resp => resp.url().includes('/api/pizzaDay/create'));
await createBtn.click();
await createResponse;
await page.reload();
@@ -76,6 +66,8 @@ test.describe.serial('pizza day životní cyklus', () => {
// --- 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 });
+1 -2
View File
@@ -141,9 +141,8 @@ router.post("/clear", async (req: Request<{}, any, any>, res, next) => {
const dateKey = formatDate(date);
const data = await storage.getData<any>(dateKey);
// Vymažeme všechny volby i aktivní pizza day
// Vymažeme všechny volby
data.choices = {};
delete data.pizzaDay;
await storage.setData(dateKey, data);