Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ed781d0cf | |||
| 70ed59ab9d | |||
| 6b2deff215 | |||
| ace4130171 | |||
| 9383cd7d4c | |||
| db1fe473cd |
@@ -24,7 +24,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "22"
|
node-version: "22"
|
||||||
|
|
||||||
- run: npm install -g yarn
|
- run: corepack enable
|
||||||
|
|
||||||
- run: cd types && yarn install --frozen-lockfile && yarn openapi-ts
|
- run: cd types && yarn install --frozen-lockfile && yarn openapi-ts
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "22"
|
node-version: "22"
|
||||||
|
|
||||||
- run: npm install -g yarn
|
- run: corepack enable
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -73,7 +73,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "22"
|
node-version: "22"
|
||||||
|
|
||||||
- run: npm install -g yarn
|
- run: corepack enable
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -102,7 +102,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "22"
|
node-version: "22"
|
||||||
|
|
||||||
- run: npm install -g yarn
|
- run: corepack enable
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
@@ -189,7 +189,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "22"
|
node-version: "22"
|
||||||
|
|
||||||
- run: npm install -g yarn
|
- run: corepack enable
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -11,11 +11,14 @@ export async function loginViaApi(page: Page, login: string): Promise<void> {
|
|||||||
await page.evaluate((t) => localStorage.setItem('token', t), token);
|
await page.evaluate((t) => localStorage.setItem('token', t), token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Vyčistí stav pizza dne pro zadaný dayIndex (0=pondělí…4=pátek) přes dev API. */
|
/** Vyčistí stav dne pro zadaný dayIndex (0=pondělí…4=pátek) přes dev API.
|
||||||
export async function clearPizzaDay(request: APIRequestContext): Promise<void> {
|
* /api/dev/* vyžaduje JWT – nejdřív získáme token přes /api/login.
|
||||||
const today = new Date('2025-01-10'); // MOCK_DATA pins to Friday = dayIndex 4
|
*/
|
||||||
|
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;
|
||||||
await request.post('/api/dev/clear', {
|
await request.post('/api/dev/clear', {
|
||||||
headers: { 'Content-Type': 'application/json', 'remote-user': 'e2e-user' },
|
headers: { Authorization: `Bearer ${token}` },
|
||||||
data: { dayIndex: 4 },
|
data: { dayIndex },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
import { clearPizzaDay } from './helpers';
|
import { clearDay } from './helpers';
|
||||||
|
|
||||||
test.beforeEach(async ({ page, request }) => {
|
test.beforeEach(async ({ page, request }) => {
|
||||||
// Vyčistíme volby dne, aby testy neovlivnily navzájem
|
// Vyčistíme volby dne, aby testy neovlivnily navzájem
|
||||||
await request.post('/api/dev/clear', {
|
await clearDay(request);
|
||||||
data: { dayIndex: 4 },
|
|
||||||
});
|
|
||||||
await page.goto('/');
|
await page.goto('/');
|
||||||
await page.waitForLoadState('networkidle');
|
await page.waitForLoadState('networkidle');
|
||||||
// Počkáme, až se zobrazí volba stravování
|
// Počkáme, až se zobrazí volba stravování
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
|
import { clearDay } from './helpers';
|
||||||
|
|
||||||
// Pizza day testy musí běžet sekvenčně (sdílejí stav mock dne)
|
// Pizza day testy musí běžet sekvenčně (sdílejí stav mock dne)
|
||||||
test.describe.serial('pizza day životní cyklus', () => {
|
test.describe.serial('pizza day životní cyklus', () => {
|
||||||
|
|
||||||
test.beforeEach(async ({ request }) => {
|
test.beforeEach(async ({ request }) => {
|
||||||
// Vyčistíme data mock dne před každým testem
|
// Vyčistíme data mock dne před každým testem
|
||||||
await request.post('/api/dev/clear', { data: { dayIndex: 4 } });
|
await clearDay(request);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('zobrazí sekci Pizza Day bez aktivního dne', async ({ page }) => {
|
test('zobrazí sekci Pizza Day bez aktivního dne', async ({ page }) => {
|
||||||
@@ -20,17 +21,26 @@ test.describe.serial('pizza day životní cyklus', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('vytvoří, uzamkne a dokončí pizza day', async ({ page }) => {
|
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.goto('/');
|
||||||
await page.waitForLoadState('networkidle');
|
await page.waitForLoadState('networkidle');
|
||||||
// Sekce pizza-section se zobrazí jen pokud má uživatel zvolenou možnost "Pizza day"
|
// 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.locator('select').selectOption({ label: 'Pizza day' });
|
||||||
await page.waitForLoadState('networkidle');
|
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 ---
|
// --- CREATED ---
|
||||||
const createBtn = page.locator('.pizza-section button', { hasText: 'Založit Pizza day' });
|
const createBtn = page.locator('.pizza-section button', { hasText: 'Založit Pizza day' });
|
||||||
await expect(createBtn).toBeVisible({ timeout: 10_000 });
|
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
|
// Čekáme na odpověď API před reloadem – jinak by reload přerušil probíhající request
|
||||||
const createResponse = page.waitForResponse(resp => resp.url().includes('/api/pizzaDay/create'));
|
// 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 },
|
||||||
|
);
|
||||||
await createBtn.click();
|
await createBtn.click();
|
||||||
await createResponse;
|
await createResponse;
|
||||||
await page.reload();
|
await page.reload();
|
||||||
@@ -66,8 +76,6 @@ test.describe.serial('pizza day životní cyklus', () => {
|
|||||||
// --- DELIVERED ---
|
// --- DELIVERED ---
|
||||||
const deliverBtn = page.locator('.pizza-section button', { hasText: 'Doručeno' });
|
const deliverBtn = page.locator('.pizza-section button', { hasText: 'Doručeno' });
|
||||||
await expect(deliverBtn).toBeVisible({ timeout: 5_000 });
|
await expect(deliverBtn).toBeVisible({ timeout: 5_000 });
|
||||||
// window.confirm dialog − Playwright automaticky potvrdí
|
|
||||||
page.on('dialog', dialog => dialog.accept());
|
|
||||||
await deliverBtn.click();
|
await deliverBtn.click();
|
||||||
await page.waitForLoadState('networkidle');
|
await page.waitForLoadState('networkidle');
|
||||||
await expect(page.locator('.pizza-section')).toContainText('doručeny', { timeout: 5_000 });
|
await expect(page.locator('.pizza-section')).toContainText('doručeny', { timeout: 5_000 });
|
||||||
|
|||||||
@@ -141,8 +141,9 @@ router.post("/clear", async (req: Request<{}, any, any>, res, next) => {
|
|||||||
const dateKey = formatDate(date);
|
const dateKey = formatDate(date);
|
||||||
const data = await storage.getData<any>(dateKey);
|
const data = await storage.getData<any>(dateKey);
|
||||||
|
|
||||||
// Vymažeme všechny volby
|
// Vymažeme všechny volby i aktivní pizza day
|
||||||
data.choices = {};
|
data.choices = {};
|
||||||
|
delete data.pizzaDay;
|
||||||
|
|
||||||
await storage.setData(dateKey, data);
|
await storage.setData(dateKey, data);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user