WIP: feat: přidání testů – Jest unit testy + Playwright E2E + CI pipeline #54
@@ -11,6 +11,9 @@ test.describe.serial('pizza day životní cyklus', () => {
|
|||||||
test('zobrazí sekci Pizza Day bez aktivního dne', async ({ page }) => {
|
test('zobrazí sekci Pizza Day bez aktivního dne', async ({ page }) => {
|
||||||
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"
|
||||||
|
await page.locator('select').selectOption({ label: 'Pizza day' });
|
||||||
|
await page.waitForLoadState('networkidle');
|
||||||
const pizzaSection = page.locator('.pizza-section');
|
const pizzaSection = page.locator('.pizza-section');
|
||||||
await expect(pizzaSection).toBeVisible({ timeout: 10_000 });
|
await expect(pizzaSection).toBeVisible({ timeout: 10_000 });
|
||||||
await expect(pizzaSection.locator('text=není aktuálně založen')).toBeVisible();
|
await expect(pizzaSection.locator('text=není aktuálně založen')).toBeVisible();
|
||||||
@@ -19,6 +22,9 @@ 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 }) => {
|
||||||
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"
|
||||||
|
await page.locator('select').selectOption({ label: 'Pizza day' });
|
||||||
|
await page.waitForLoadState('networkidle');
|
||||||
|
|
||||||
// --- 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' });
|
||||||
|
|||||||
@@ -23,18 +23,19 @@ test('Nastavení ukládají číslo účtu a jméno do localStorage', async ({ p
|
|||||||
// Modal musí být viditelný
|
// Modal musí být viditelný
|
||||||
await expect(page.locator('.modal-title')).toContainText('Nastavení', { timeout: 5_000 });
|
await expect(page.locator('.modal-title')).toContainText('Nastavení', { timeout: 5_000 });
|
||||||
|
|
||||||
// Změníme číslo účtu
|
// Změníme číslo účtu – pressSequentially zajistí spuštění React onChange na každý znak
|
||||||
const accountInput = page.getByPlaceholder('123456-1234567890/1234');
|
const accountInput = page.getByPlaceholder('123456-1234567890/1234');
|
||||||
await accountInput.clear();
|
await accountInput.click({ clickCount: 3 });
|
||||||
await accountInput.fill('1234567890/5500');
|
await accountInput.pressSequentially('1234567890/5500');
|
||||||
|
|
||||||
// Změníme jméno
|
// Změníme jméno
|
||||||
const nameInput = page.getByPlaceholder('Jan Novák');
|
const nameInput = page.getByPlaceholder('Jan Novák');
|
||||||
await nameInput.clear();
|
await nameInput.click({ clickCount: 3 });
|
||||||
await nameInput.fill('Nové Jméno');
|
await nameInput.pressSequentially('Nové Jméno');
|
||||||
|
|
||||||
// Uložíme
|
// Uložíme a počkáme na zavření modalu
|
||||||
await page.locator('.modal-footer button', { hasText: 'Uložit' }).click();
|
await page.locator('.modal-footer button', { hasText: 'Uložit' }).click();
|
||||||
|
await expect(page.locator('.modal')).not.toBeVisible({ timeout: 5_000 });
|
||||||
|
|
||||||
// Ověříme v localStorage
|
// Ověříme v localStorage
|
||||||
const bankAccount = await page.evaluate(() => localStorage.getItem('bank_account_number'));
|
const bankAccount = await page.evaluate(() => localStorage.getItem('bank_account_number'));
|
||||||
|
|||||||
Reference in New Issue
Block a user