Files
Luncher/e2e/tests/notification-settings.spec.ts
T
batmanisko 5c048fe1f1
CI / Generate TypeScript types (push) Successful in 13s
CI / Server unit tests (push) Successful in 25s
CI / Build server (push) Successful in 28s
CI / Build client (push) Successful in 41s
CI / Playwright E2E tests (push) Successful in 1m47s
CI / Build and push Docker image (push) Successful in 53s
CI / Notify (push) Successful in 2s
feat: sledování objednávek přes Wolt
Vedle Bolt Food jde nově sledovat i objednávka z Woltu — stačí u objednané
skupiny vložit odkaz z track.wolt.com. Logika sledování je zobecněná do
registru rozvozových služeb (trackingProviders.ts): každá služba umí vytáhnout
kód ze sdílecího odkazu a dotázat se svého API, scheduler i stepper jsou společné.

- pole skupiny bolt* přejmenována na tracking* + nové trackingProvider
- endpoint /groups/setBoltTracking → /groups/setTracking
- Wolt: čas doručení z delivery_eta v časové zóně objednávky, 404 ukončí
  sledování, stav kurýra odvozen z is_delivering/is_delivering_other_order
- DEV simulace zůstává jen pro Bolt Food
2026-08-24 11:27:56 +02:00

78 lines
3.4 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { loginViaApi } from './helpers';
const DELIVERY_LABEL = 'Upozornění na doručení objednávky (Bolt Food / Wolt)';
test.beforeEach(async ({ page }) => {
await loginViaApi(page, 'e2e-user');
await page.reload();
await page.waitForLoadState('networkidle');
});
async function openSettings(page: import('@playwright/test').Page) {
await page.locator('#basic-nav-dropdown').click();
await page.locator('text=Nastavení').click();
await expect(page.locator('.modal-title')).toContainText('Nastavení', { timeout: 5_000 });
}
test('Přepínač doručení objednávky je pod výběrem času připomínky', async ({ page }) => {
await openSettings(page);
const reminderGroup = page.locator('.modal-body .mb-3').filter({ hasText: 'Připomínka výběru oběda' });
const deliveryGroup = page.locator('.modal-body .mb-3').filter({ hasText: DELIVERY_LABEL });
await expect(reminderGroup).toBeVisible();
await expect(deliveryGroup).toBeVisible();
// Přepínač musí v DOM následovat až za skupinou s časem připomínky
const order = await page.evaluate((label) => {
const groups = Array.from(document.querySelectorAll('.modal-body .mb-3'));
return {
reminder: groups.findIndex(g => g.textContent?.includes('Připomínka výběru oběda')),
delivery: groups.findIndex(g => g.textContent?.includes(label)),
};
}, DELIVERY_LABEL);
expect(order.reminder).toBeGreaterThanOrEqual(0);
expect(order.delivery).toBe(order.reminder + 1);
// Výchozí stav je vypnuto
await expect(page.locator('#boltDeliveredCheckbox')).not.toBeChecked();
});
test('Zapnutí přepínače se uloží na server a přežije znovuotevření', async ({ page }) => {
await openSettings(page);
await page.locator('#boltDeliveredCheckbox').check();
await page.locator('.modal-footer button', { hasText: 'Uložit' }).click();
await expect(page.locator('.modal')).not.toBeVisible({ timeout: 5_000 });
// Server má nastavení uložené
const token = await page.evaluate(() => localStorage.getItem('token'));
const resp = await page.request.get('/api/notifications/settings', {
headers: { Authorization: `Bearer ${token}` },
});
expect(await resp.json()).toMatchObject({ boltDeliveredPush: true });
// Po znovunačtení stránky je přepínač stále zapnutý
await page.reload();
await page.waitForLoadState('networkidle');
await openSettings(page);
await expect(page.locator('#boltDeliveredCheckbox')).toBeChecked();
});
test('Vypnutí přepínače se uloží zpět', async ({ page }) => {
await openSettings(page);
await page.locator('#boltDeliveredCheckbox').check();
await page.locator('.modal-footer button', { hasText: 'Uložit' }).click();
await expect(page.locator('.modal')).not.toBeVisible({ timeout: 5_000 });
await openSettings(page);
await page.locator('#boltDeliveredCheckbox').uncheck();
await page.locator('.modal-footer button', { hasText: 'Uložit' }).click();
await expect(page.locator('.modal')).not.toBeVisible({ timeout: 5_000 });
const token = await page.evaluate(() => localStorage.getItem('token'));
const resp = await page.request.get('/api/notifications/settings', {
headers: { Authorization: `Bearer ${token}` },
});
expect(await resp.json()).toMatchObject({ boltDeliveredPush: false });
});