Files
Luncher/e2e/tests/helpers.ts
T
mates 3ed781d0cf
CI / Generate TypeScript types (push) Successful in 11s
CI / Server unit tests (push) Successful in 22s
CI / Build server (push) Successful in 23s
CI / Build client (push) Successful in 31s
CI / Playwright E2E tests (push) Successful in 1m15s
CI / Build and push Docker image (push) Has been skipped
CI / Notify (push) Successful in 2s
CI / Generate TypeScript types (pull_request) Successful in 13s
CI / Server unit tests (pull_request) Successful in 25s
CI / Build server (pull_request) Successful in 30s
CI / Build client (pull_request) Successful in 37s
CI / Playwright E2E tests (pull_request) Successful in 1m19s
CI / Build and push Docker image (pull_request) Has been skipped
CI / Notify (pull_request) Has been skipped
test: opravy Playwright testů
2026-04-29 22:55:23 +02:00

25 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { Page, APIRequestContext } from '@playwright/test';
/** Přihlásí uživatele přes POST /api/login a uloží JWT do localStorage. */
export async function loginViaApi(page: Page, login: string): Promise<void> {
const response = await page.request.post('/api/login', {
headers: { 'Content-Type': 'application/json', 'remote-user': login },
data: {},
});
const token = await response.json() as string;
await page.goto('/');
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;
await request.post('/api/dev/clear', {
headers: { Authorization: `Bearer ${token}` },
data: { dayIndex },
});
}