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
34 changed files with 152 additions and 1256 deletions
+5 -5
View File
@@ -24,7 +24,7 @@ jobs:
with: with:
node-version: "22" node-version: "22"
- run: corepack enable - run: npm install -g yarn
- 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: corepack enable - run: npm install -g yarn
- 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: corepack enable - run: npm install -g yarn
- 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: corepack enable - run: npm install -g yarn
- 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: corepack enable - run: npm install -g yarn
- uses: actions/download-artifact@v3 - uses: actions/download-artifact@v3
with: with:
+9 -35
View File
@@ -12,12 +12,9 @@ Luncher is a lunch management app for teams — daily restaurant menus, food ord
types/ → Shared OpenAPI-generated TypeScript types (source of truth: types/api.yml) types/ → Shared OpenAPI-generated TypeScript types (source of truth: types/api.yml)
server/ → Express 5 backend (Node.js 22, ts-node) server/ → Express 5 backend (Node.js 22, ts-node)
client/ → React 19 frontend (Vite 7, React Bootstrap) client/ → React 19 frontend (Vite 7, React Bootstrap)
e2e/ → Playwright E2E tests (separate package)
``` ```
Each of the four directories has its own `package.json`. Package manager: **Yarn Classic**. Each directory has its own `package.json` and `tsconfig.json`. Package manager: **Yarn Classic**.
Deployment files at repo root: `Dockerfile`, `Dockerfile-Woodpecker`, `compose.yml`, `compose-traefik.yml`.
## Development Commands ## Development Commands
@@ -26,7 +23,6 @@ Deployment files at repo root: `Dockerfile`, `Dockerfile-Woodpecker`, `compose.y
cd types && yarn install && yarn openapi-ts # Generate API types first cd types && yarn install && yarn openapi-ts # Generate API types first
cd ../server && yarn install cd ../server && yarn install
cd ../client && yarn install cd ../client && yarn install
cd ../e2e && yarn install
``` ```
### Running dev environment ### Running dev environment
@@ -48,30 +44,11 @@ cd client && yarn build # tsc --noEmit + vite build → client/dist
### Tests ### Tests
```bash ```bash
# Server unit tests (Jest) cd server && yarn test # Jest (tests in server/src/tests/)
cd server && yarn test # All tests in server/src/tests/ cd server && yarn test dates # Run one test file
cd server && yarn test dates # Run one file by name
cd server && yarn test -t "name" # Run by test name pattern cd server && yarn test -t "name" # Run by test name pattern
# E2E (Playwright) — requires prebuilt server
cd server && yarn build
cd e2e && yarn test # chromium + firefox, baseURL 127.0.0.1:3001
cd e2e && yarn test:ui # interactive UI mode
cd e2e && yarn report # open last HTML report
``` ```
Jest setup (`server/src/tests/setupEnv.ts`) forces `STORAGE=memory`, deletes `MOCK_DATA`, and sets a fixed `JWT_SECRET`. Playwright auto-starts the prebuilt server and authenticates via the `remote-user: e2e-user` trusted-header path; locally uses `STORAGE=json` + `MOCK_DATA=true`, CI uses `STORAGE=redis`.
### CI pipeline
Gitea Actions — `.gitea/workflows/ci.yaml` (no `.github/` equivalent):
1. `generate-types` — runs `yarn openapi-ts`, uploads artifact
2. `server-test` — Jest
3. `server-build` + `client-build` — parallel tsc/vite builds
4. `e2e` — Playwright in `mcr.microsoft.com/playwright:v1.59.1-jammy` with a Redis service container; only Firefox installed in CI
5. `docker-build` — master branch only, uses `Dockerfile-Woodpecker`
6. `notify` — Discord + ntfy webhooks
### Formatting ### Formatting
Prettier is installed in `client/` (devDependency only, no script or config) — invoke via `yarn prettier <path>` with defaults. Prettier is installed in `client/` (devDependency only, no script or config) — invoke via `yarn prettier <path>` with defaults.
@@ -86,11 +63,10 @@ Prettier is installed in `client/` (devDependency only, no script or config) —
### Server (server/src/) ### Server (server/src/)
- **Entry:** `index.ts` — Express app + Socket.io setup - **Entry:** `index.ts` — Express app + Socket.io setup
- **Routes:** `routes/` 9 modular Express route handlers (food, pizzaDay, voting, notifications, qr, stats, easterEgg, dev, changelog) - **Routes:** `routes/` — modular Express route handlers (food, pizzaDay, voting, notifications, qr, stats, easterEgg, dev)
- **Services:** domain logic files at root level (`service.ts`, `pizza.ts`, `restaurants.ts`, `chefie.ts`, `voting.ts`, `stats.ts`, `qr.ts`, `notifikace.ts`) - **Services:** domain logic files at root level (`service.ts`, `pizza.ts`, `restaurants.ts`, `chefie.ts`, `voting.ts`, `stats.ts`, `qr.ts`, `notifikace.ts`)
- **Helpers:** `mock.ts` (fake menu data for `MOCK_DATA=true`), `pushReminder.ts` (push notification reminders), `utils.ts` (shared utilities)
- **Auth:** `auth.ts` — JWT + optional trusted-header authentication - **Auth:** `auth.ts` — JWT + optional trusted-header authentication
- **Storage:** `storage/index.ts` factory selects implementation; backends: `json.ts` (file-based, dev), `redis.ts` (production), `memory.ts` (tests). Data keyed by date (YYYY-MM-DD). - **Storage:** `storage/StorageInterface.ts` defines the interface; implementations in `storage/json.ts` (file-based, dev) and `storage/redis.ts` (production). Data keyed by date (YYYY-MM-DD).
- **Restaurant scrapers:** Cheerio-based HTML parsing for daily menus from multiple restaurants - **Restaurant scrapers:** Cheerio-based HTML parsing for daily menus from multiple restaurants
- **Pizza Chefie integration:** `chefie.ts` scrapes pizzachefie.cz for Pizza day menus and salads (only active when a Pizza day is open) - **Pizza Chefie integration:** `chefie.ts` scrapes pizzachefie.cz for Pizza day menus and salads (only active when a Pizza day is open)
- **WebSocket:** `websocket.ts` — Socket.io for real-time client updates - **WebSocket:** `websocket.ts` — Socket.io for real-time client updates
@@ -98,12 +74,10 @@ Prettier is installed in `client/` (devDependency only, no script or config) —
- **Config:** `.env.development` / `.env.production` (see `.env.template` for all options) - **Config:** `.env.development` / `.env.production` (see `.env.template` for all options)
### Client (client/src/) ### Client (client/src/)
- **Entry:** `index.tsx``App.tsx``AppRoutes.tsx`; `Login.tsx` is the auth screen; `FallingLeaves.tsx` is a seasonal visual effect - **Entry:** `index.tsx``App.tsx``AppRoutes.tsx`
- **Pages:** `pages/` (StatsPage) - **Pages:** `pages/` (StatsPage)
- **Components:** `components/` (Header, Footer, Loader, PizzaOrderList, PizzaOrderRow, and modals in `components/modals/`) - **Components:** `components/` (Header, Footer, Loader, modals/, PizzaOrderList, PizzaOrderRow)
- **Context providers:** `context/``auth.tsx`, `settings.tsx`, `socket.js`, `eggs.tsx` (note: `socket.js` is the only non-TSX context file) - **Context providers:** `context/`AuthContext, SettingsContext, SocketContext, EasterEggContext
- **Hooks:** `hooks/` (`usePushReminder.ts`)
- **Utils:** `utils/` (`parsePrice.ts`)
- **Styling:** Bootstrap 5 + React Bootstrap + custom SCSS files (co-located with components) - **Styling:** Bootstrap 5 + React Bootstrap + custom SCSS files (co-located with components)
- **API calls:** use OpenAPI-generated SDK from `types/gen/` - **API calls:** use OpenAPI-generated SDK from `types/gen/`
- **Routing:** React Router DOM v7 - **Routing:** React Router DOM v7
@@ -117,7 +91,7 @@ Prettier is installed in `client/` (devDependency only, no script or config) —
## Environment ## Environment
- **Server env files:** `server/.env.development`, `server/.env.production` (see `server/.env.template`) - **Server env files:** `server/.env.development`, `server/.env.production` (see `server/.env.template`)
- Key vars: `JWT_SECRET`, `STORAGE` (json/redis/memory), `MOCK_DATA`, `REDIS_HOST`, `REDIS_PORT` - Key vars: `JWT_SECRET`, `STORAGE` (json/redis), `MOCK_DATA`, `REDIS_HOST`, `REDIS_PORT`
- **Docker:** multi-stage Dockerfile, `compose.yml` for app + Redis. Timezone: Europe/Prague. - **Docker:** multi-stage Dockerfile, `compose.yml` for app + Redis. Timezone: Europe/Prague.
## Conventions ## Conventions
+3 -2
View File
@@ -21,8 +21,9 @@ COPY ./client/dist ./public
# Zkopírování changelogů (seznamu novinek) # Zkopírování changelogů (seznamu novinek)
COPY ./server/changelogs ./server/changelogs COPY ./server/changelogs ./server/changelogs
# Zkopírování konfigurace easter eggů # Zkopírování konfigurace easter eggů a changelogů
RUN if [ -f ./server/.easter-eggs.json ]; then cp ./server/.easter-eggs.json ./server/; fi RUN if [ -f ./server/.easter-eggs.json ]; then cp ./server/.easter-eggs.json ./server/; fi \
&& if [ -d ./server/changelogs ]; then cp -r ./server/changelogs ./server/changelogs; fi
EXPOSE 3000 EXPOSE 3000
+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); 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. /** Vyčistí stav pizza 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 clearPizzaDay(request: APIRequestContext): Promise<void> {
*/ 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: { Authorization: `Bearer ${token}` }, headers: { 'Content-Type': 'application/json', 'remote-user': 'e2e-user' },
data: { dayIndex }, data: { dayIndex: 4 },
}); });
} }
+4 -2
View File
@@ -1,9 +1,11 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { clearDay } from './helpers'; import { clearPizzaDay } 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 clearDay(request); await request.post('/api/dev/clear', {
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í
+4 -12
View File
@@ -1,12 +1,11 @@
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 clearDay(request); await request.post('/api/dev/clear', { data: { dayIndex: 4 } });
}); });
test('zobrazí sekci Pizza Day bez aktivního dne', async ({ page }) => { 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 }) => { 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
// 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'));
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();
@@ -76,6 +66,8 @@ 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 });
-1
View File
@@ -2,7 +2,6 @@
/dist /dist
/resources/easterEggs /resources/easterEggs
/src/gen /src/gen
/coverage
.env.production .env.production
.env.development .env.development
.easter-eggs.json .easter-eggs.json
+2 -3
View File
@@ -1,6 +1,5 @@
module.exports = { module.exports = {
testEnvironment: 'node', testEnvironment: 'node',
testMatch: ['<rootDir>/src/**/*.test.ts'], testMatch: ['<rootDir>/src/tests/**/*.test.ts'],
testPathIgnorePatterns: ['/node_modules/', '/dist/'], setupFiles: ['<rootDir>/src/tests/helpers/setupEnv.ts'],
setupFiles: ['<rootDir>/src/tests/setupEnv.ts'],
}; };
-2
View File
@@ -19,12 +19,10 @@
"@types/jsonwebtoken": "^9.0.10", "@types/jsonwebtoken": "^9.0.10",
"@types/node": "^24.10.0", "@types/node": "^24.10.0",
"@types/request-promise": "^4.1.48", "@types/request-promise": "^4.1.48",
"@types/supertest": "^6.0.0",
"@types/web-push": "^3.6.4", "@types/web-push": "^3.6.4",
"babel-jest": "^30.2.0", "babel-jest": "^30.2.0",
"jest": "^30.2.0", "jest": "^30.2.0",
"nodemon": "^3.1.10", "nodemon": "^3.1.10",
"supertest": "^7.0.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^5.9.3" "typescript": "^5.9.3"
}, },
+2 -2
View File
@@ -14,7 +14,7 @@ const storage = getStorage();
* *
* @param bankAccountNumber číslo účtu ve formátu BBAN (123456-0123456789/0100) * @param bankAccountNumber číslo účtu ve formátu BBAN (123456-0123456789/0100)
*/ */
export function convertBbanToIban(bankAccountNumber: string): string { function convertBbanToIban(bankAccountNumber: string): string {
// TODO validovat číslo účtu stejně jako na klientovi, pro případ že sem někdo pošle nesmysl // TODO validovat číslo účtu stejně jako na klientovi, pro případ že sem někdo pošle nesmysl
let prefix: string = ''; let prefix: string = '';
let accountNumber: string = bankAccountNumber; let accountNumber: string = bankAccountNumber;
@@ -58,7 +58,7 @@ function createStorageKey(customerName: string, id: string): string {
export async function generateQr(customerName: string, bankAccountNumber: string, bankAccountHolder: string, amount: number, message: string, id: string): Promise<void> { export async function generateQr(customerName: string, bankAccountNumber: string, bankAccountHolder: string, amount: number, message: string, id: string): Promise<void> {
// Zpráva pro příjemce nesmí dle standardu obsahovat '*' a být delší než 60 znaků // Zpráva pro příjemce nesmí dle standardu obsahovat '*' a být delší než 60 znaků
if (message.indexOf('*') >= 0) { if (message.indexOf('*') >= 0) {
message = message.replace(/\*/g, ''); message = message.replace('*', '');
} }
if (message.length > 60) { if (message.length > 60) {
message = message.substring(0, 60); message = message.substring(0, 60);
+1 -2
View File
@@ -141,9 +141,8 @@ 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 i aktivní pizza day // Vymažeme všechny volby
data.choices = {}; data.choices = {};
delete data.pizzaDay;
await storage.setData(dateKey, data); await storage.setData(dateKey, data);
+1 -5
View File
@@ -3,24 +3,20 @@ import path from 'path';
import { StorageInterface } from "./StorageInterface"; import { StorageInterface } from "./StorageInterface";
import JsonStorage from "./json"; import JsonStorage from "./json";
import RedisStorage from "./redis"; import RedisStorage from "./redis";
import MemoryStorage from "./memory";
const ENVIRONMENT = process.env.NODE_ENV ?? 'production'; const ENVIRONMENT = process.env.NODE_ENV ?? 'production';
dotenv.config({ path: path.resolve(__dirname, `../../.env.${ENVIRONMENT}`) }); dotenv.config({ path: path.resolve(__dirname, `../../.env.${ENVIRONMENT}`) });
const JSON_KEY = 'json'; const JSON_KEY = 'json';
const REDIS_KEY = 'redis'; const REDIS_KEY = 'redis';
const MEMORY_KEY = 'memory';
let storage: StorageInterface; let storage: StorageInterface;
if (!process.env.STORAGE || process.env.STORAGE?.toLowerCase() === JSON_KEY) { if (!process.env.STORAGE || process.env.STORAGE?.toLowerCase() === JSON_KEY) {
storage = new JsonStorage(); storage = new JsonStorage();
} else if (process.env.STORAGE?.toLowerCase() === REDIS_KEY) { } else if (process.env.STORAGE?.toLowerCase() === REDIS_KEY) {
storage = new RedisStorage(); storage = new RedisStorage();
} else if (process.env.STORAGE?.toLowerCase() === MEMORY_KEY) {
storage = new MemoryStorage();
} else { } else {
throw Error("Nepodporovaná hodnota proměnné STORAGE: " + process.env.STORAGE + ", podporované jsou 'json', 'redis' nebo 'memory'"); throw Error("Nepodporovaná hodnota proměnné STORAGE: " + process.env.STORAGE + ", podporované jsou 'json' nebo 'redis'");
} }
export const storageReady: Promise<void> = storage.initialize export const storageReady: Promise<void> = storage.initialize
-27
View File
@@ -1,27 +0,0 @@
import { StorageInterface } from "./StorageInterface";
const store = new Map<string, unknown>();
/** Vymaže všechna data z in-memory úložiště. Slouží k resetu mezi testy. */
export function resetMemoryStorage(): void {
store.clear();
}
/**
* In-memory implementace úložiště. Používá se výhradně v testovacím prostředí.
*/
export default class MemoryStorage implements StorageInterface {
hasData(key: string): Promise<boolean> {
return Promise.resolve(store.has(key));
}
getData<Type>(key: string): Promise<Type | undefined> {
return Promise.resolve(store.get(key) as Type | undefined);
}
setData<Type>(key: string, data: Type): Promise<void> {
store.set(key, data);
return Promise.resolve();
}
}
+2 -6
View File
@@ -1,7 +1,6 @@
import { generateToken, verify, getLogin, getTrusted } from '../auth'; import { generateToken, verify, getLogin, getTrusted } from '../auth';
const VALID_SECRET = 'test-jwt-secret-ktery-ma-alespon-32-znaku'; const VALID_SECRET = 'test-secret-min-32-chars-aaaaaaa!';
const SHORT_SECRET = 'kratky';
beforeEach(() => { beforeEach(() => {
process.env.JWT_SECRET = VALID_SECRET; process.env.JWT_SECRET = VALID_SECRET;
@@ -24,15 +23,12 @@ describe('generateToken', () => {
}); });
test('vyhodí chybu pro příliš krátký JWT_SECRET', () => { test('vyhodí chybu pro příliš krátký JWT_SECRET', () => {
process.env.JWT_SECRET = SHORT_SECRET; process.env.JWT_SECRET = 'short';
expect(() => generateToken('alice')).toThrow('32'); expect(() => generateToken('alice')).toThrow('32');
}); });
test('vyhodí chybu pro prázdný login', () => { test('vyhodí chybu pro prázdný login', () => {
expect(() => generateToken('')).toThrow('login'); expect(() => generateToken('')).toThrow('login');
});
test('vyhodí chybu pro login obsahující jen mezery', () => {
expect(() => generateToken(' ')).toThrow('login'); expect(() => generateToken(' ')).toThrow('login');
}); });
-38
View File
@@ -1,38 +0,0 @@
import * as fs from 'fs';
import * as path from 'path';
import axios from 'axios';
import { downloadSalaty } from '../chefie';
jest.mock('axios');
const mockedAxios = axios as jest.Mocked<typeof axios>;
const fixturesDir = path.join(__dirname, 'fixtures');
const loadFixture = (name: string) => fs.readFileSync(path.join(fixturesDir, name), 'utf-8');
beforeEach(() => {
jest.resetAllMocks();
// První volání = stránka se seznamem salátů, následující volání = jednotlivé stránky salátů
mockedAxios.get = jest.fn()
.mockResolvedValueOnce({ data: loadFixture('chefie-salaty.html') })
.mockResolvedValueOnce({ data: loadFixture('chefie-salat-caesar.html') })
.mockResolvedValueOnce({ data: loadFixture('chefie-salat-recky.html') });
});
test('downloadSalaty vrátí seznam salátů', async () => {
const salaty = await downloadSalaty(false);
expect(salaty).toHaveLength(2);
});
test('saláty mají name a ingredients', async () => {
const salaty = await downloadSalaty(false);
expect(salaty[0].name).toBe('Caesar salát');
expect(salaty[0].ingredients).toContain('Kuřecí maso');
});
test('cena salátu zahrnuje pevný příplatek 13 Kč za obal', async () => {
const salaty = await downloadSalaty(false);
// Caesar sticker price = 129, box = 13
expect(salaty[0].price).toBe(129 + 13);
// Řecký sticker price = 119, box = 13
expect(salaty[1].price).toBe(119 + 13);
});
-16
View File
@@ -1,16 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<div class="produkt">
<h2>Caesar salát</h2>
</div>
<ul class="prisady">
<li>Ledový salát</li>
<li>Kuřecí maso</li>
<li>Parmazán</li>
</ul>
<div class="cena">
<span>129 Kč</span>
</div>
</body>
</html>
-16
View File
@@ -1,16 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<div class="produkt">
<h2>Řecký salát</h2>
</div>
<ul class="prisady">
<li>Rajčata</li>
<li>Okurka</li>
<li>Feta sýr</li>
</ul>
<div class="cena">
<span>119 Kč</span>
</div>
</body>
</html>
-13
View File
@@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<div class="vypisproduktu">
<div>
<h4><a href="salat-caesar.html">Caesar salát</a></h4>
</div>
<div>
<h4><a href="salat-recky.html">Řecký salát</a></h4>
</div>
</div>
</body>
</html>
-33
View File
@@ -1,33 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<div class="menicka">
<ul class="popup-gallery">
<li class="polevka">
<div class="polozka">Polévka dne</div>
<div class="cena">35&nbsp;</div>
</li>
<li>
<div class="polozka">1. Svíčková na smetaně s knedlíkem</div>
<div class="cena">149&nbsp;</div>
</li>
<li>
<div class="polozka">2. Smažený sýr s bramborovým salátem</div>
<div class="cena">135&nbsp;</div>
</li>
</ul>
</div>
<div class="menicka">
<ul class="popup-gallery">
<li class="polevka">
<div class="polozka">Česnečka se smetanou</div>
<div class="cena">35&nbsp;</div>
</li>
<li>
<div class="polozka">1. Vepřový guláš s knedlíkem</div>
<div class="cena">145&nbsp;</div>
</li>
</ul>
</div>
</body>
</html>
-55
View File
@@ -1,55 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<ul id="daily-menu-tab-list">
<button id="daily-menu-tab-0"><span class="daily-menu-tab__day">pondělí</span></button>
<button id="daily-menu-tab-1"><span class="daily-menu-tab__day">úterý</span></button>
<button id="daily-menu-tab-2"><span class="daily-menu-tab__day">středa</span></button>
<button id="daily-menu-tab-3"><span class="daily-menu-tab__day">čtvrtek</span></button>
<button id="daily-menu-tab-4"><span class="daily-menu-tab__day">pátek</span></button>
</ul>
<ul id="daily-menu-content-list">
<div class="daily-menu-content__content">
<div class="daily-menu-content__item">
<table class="daily-menu-content__table"><tbody>
<tr><td>250ml</td><td>Polévka dne 1, 9</td><td>35&nbsp;</td></tr>
<tr><td>150g</td><td>Svíčková na smetaně s knedlíkem 1, 3, 7</td><td>149&nbsp;</td></tr>
<tr><td>120g</td><td>Kuřecí řízek s bramborami 1</td><td>139&nbsp;</td></tr>
</tbody></table>
</div>
</div>
<div class="daily-menu-content__content">
<div class="daily-menu-content__item">
<table class="daily-menu-content__table"><tbody>
<tr><td>250ml</td><td>Česnečka 1</td><td>35&nbsp;</td></tr>
<tr><td>150g</td><td>Vepřový guláš s houskovým knedlíkem 1, 3</td><td>145&nbsp;</td></tr>
</tbody></table>
</div>
</div>
<div class="daily-menu-content__content">
<div class="daily-menu-content__item">
<table class="daily-menu-content__table"><tbody>
<tr><td>250ml</td><td>Hovězí vývar s nudlemi 1</td><td>35&nbsp;</td></tr>
<tr><td>150g</td><td>Smažený sýr s bramborovým salátem 1, 3, 7</td><td>135&nbsp;</td></tr>
</tbody></table>
</div>
</div>
<div class="daily-menu-content__content">
<div class="daily-menu-content__item">
<table class="daily-menu-content__table"><tbody>
<tr><td>250ml</td><td>Rajská polévka 1</td><td>35&nbsp;</td></tr>
<tr><td>150g</td><td>Rizoto s kuřecím masem 1</td><td>139&nbsp;</td></tr>
</tbody></table>
</div>
</div>
<div class="daily-menu-content__content">
<div class="daily-menu-content__item">
<table class="daily-menu-content__table"><tbody>
<tr><td>250ml</td><td>Dršťková polévka 1</td><td>35&nbsp;</td></tr>
<tr><td>150g</td><td>Segedínský guláš s knedlíkem 1, 3</td><td>145&nbsp;</td></tr>
</tbody></table>
</div>
</div>
</ul>
</body>
</html>
-29
View File
@@ -1,29 +0,0 @@
<!DOCTYPE html>
<html>
<body>
<div class="outer-container">
<div class="header-section"><!-- font.parent().parent() -->
<p><!-- font.parent() -->
<font class="wsw-41">Obědy 12.5.-16.5.2025</font>
</p>
</div>
<!-- níže jsou sourozenci .header-section = výsledek $(font).parent().parent().siblings() -->
<p>Pondělí</p>
<p>• Polévka dne 1</p>
<p>• Svíčková na smetaně s knedlíkem 1, 3, 7 149&nbsp;</p>
<p>• Smažený sýr s bramborami 1, 3 139&nbsp;</p>
<p>Úterý</p>
<p>• Česnečka 1</p>
<p>• Vepřový guláš s houskovým knedlíkem 1, 3 145&nbsp;</p>
<p>Středa</p>
<p>• Hovězí vývar s nudlemi 1</p>
<p>• Kuřecí řízek s bramborami 1 139&nbsp;</p>
<p>Čtvrtek</p>
<p>• Dršťková polévka 1</p>
<p>• Segedínský guláš s knedlíkem 1, 3 145&nbsp;</p>
<p>Pátek</p>
<p>• Rajská polévka s rýží 1</p>
<p>• Rizoto s kuřecím masem a zeleninou 1 139&nbsp;</p>
</div>
</body>
</html>
-47
View File
@@ -1,47 +0,0 @@
import axios from 'axios';
import { generateQr, getQr } from '../qr';
import { resetMemoryStorage } from '../storage/memory';
jest.mock('axios');
const mockedAxios = axios as jest.Mocked<typeof axios>;
const FAKE_IMAGE = Buffer.from('fake-png-data');
beforeEach(() => {
resetMemoryStorage();
jest.resetAllMocks();
mockedAxios.get = jest.fn().mockResolvedValue({ data: FAKE_IMAGE });
});
test('generateQr zavolá Paylibo API se správnými parametry', async () => {
await generateQr('jannovak', '19-2000145399/0800', 'Jan Novák', 149, 'Pizza Margherita', 'test-uuid-1');
expect(mockedAxios.get).toHaveBeenCalledTimes(1);
const [url, config] = (mockedAxios.get as jest.Mock).mock.calls[0];
expect(url).toContain('paylibo.com');
expect(config.params.amount).toBe(149);
expect(config.params.iban).toBeDefined();
});
test('generateQr uloží base64 obrázek do storage', async () => {
await generateQr('jannovak', '19-2000145399/0800', 'Jan Novák', 149, 'Pizza', 'test-uuid-2');
const img = await getQr('jannovak', 'test-uuid-2');
expect(Buffer.isBuffer(img)).toBe(true);
expect(img).toEqual(FAKE_IMAGE);
});
test('generateQr ořeže zprávu delší než 60 znaků', async () => {
const dlouhaZprava = 'Pizza ' + 'x'.repeat(60);
await generateQr('jannovak', '19-2000145399/0800', 'Jan Novák', 149, dlouhaZprava, 'test-uuid-3');
const [, config] = (mockedAxios.get as jest.Mock).mock.calls[0];
expect(config.params.message.length).toBeLessThanOrEqual(60);
});
test('generateQr odstraní hvězdičku ze zprávy', async () => {
await generateQr('jannovak', '19-2000145399/0800', 'Jan Novák', 149, 'Pizza *Margherita*', 'test-uuid-4');
const [, config] = (mockedAxios.get as jest.Mock).mock.calls[0];
expect(config.params.message).not.toContain('*');
});
test('getQr hodí chybu pro neexistující ID', async () => {
await expect(getQr('jannovak', 'neexistuje')).rejects.toThrow('nebyl nalezen');
});
+77 -164
View File
@@ -1,27 +1,18 @@
import { resetMemoryStorage } from '../storage/memory'; import { PizzaDayState, PizzaSize } from '../../../types/gen/types.gen';
import getStorage from '../storage';
import { formatDate } from '../utils';
import { getToday } from '../service';
import {
createPizzaDay,
deletePizzaDay,
addPizzaOrder,
removePizzaOrder,
removeAllUserPizzas,
updatePizzaFee,
lockPizzaDay,
unlockPizzaDay,
finishPizzaOrder,
finishPizzaDelivery,
} from '../pizza';
import { ClientData, PizzaDayState } from '../../../types/gen/types.gen';
jest.mock('../notifikace', () => ({ const mockStorageData = new Map<string, any>();
callNotifikace: jest.fn().mockResolvedValue([]), jest.mock('../storage', () => ({
})); __esModule: true,
jest.mock('../qr', () => ({ default: () => ({
generateQr: jest.fn().mockResolvedValue(undefined), hasData: async (key: string) => mockStorageData.has(key),
getData: async <T>(key: string) => mockStorageData.get(key) as T,
setData: async <T>(key: string, val: T) => void mockStorageData.set(key, val),
}),
storageReady: Promise.resolve(),
})); }));
jest.mock('../notifikace', () => ({ callNotifikace: jest.fn() }));
jest.mock('../qr', () => ({ generateQr: jest.fn().mockResolvedValue(undefined) }));
jest.mock('../chefie', () => ({ jest.mock('../chefie', () => ({
downloadPizzy: jest.fn().mockResolvedValue([ downloadPizzy: jest.fn().mockResolvedValue([
{ id: 1, name: 'Margherita', variants: [{ varId: 10, size: 'střední', price: 150 }] }, { id: 1, name: 'Margherita', variants: [{ varId: 10, size: 'střední', price: 150 }] },
@@ -29,207 +20,129 @@ jest.mock('../chefie', () => ({
downloadSalaty: jest.fn().mockResolvedValue([]), downloadSalaty: jest.fn().mockResolvedValue([]),
})); }));
const CREATOR = 'kreator'; import {
const USER = 'uzivatel'; createPizzaDay,
deletePizzaDay,
lockPizzaDay,
unlockPizzaDay,
finishPizzaOrder,
finishPizzaDelivery,
addPizzaOrder,
removeAllUserPizzas,
} from '../pizza';
const PIZZA: any = { id: 1, name: 'Margherita', ingredients: [], variants: [], sizes: [] }; const PIZZA: any = { id: 1, name: 'Margherita', variants: [] };
const SIZE_M = { varId: 1, size: '30cm', price: 179, boxPrice: 13, pizzaPrice: 166 }; const SIZE: PizzaSize = { varId: 10, size: 'střední', price: 150 };
const SIZE_L = { varId: 2, size: '35cm', price: 219, boxPrice: 15, pizzaPrice: 204 };
const SIZE: any = { varId: 10, size: 'střední', price: 150 };
async function seedPizzaDay(state: PizzaDayState = PizzaDayState.CREATED): Promise<void> { beforeEach(() => mockStorageData.clear());
const today = formatDate(getToday());
const storage = getStorage();
const data: ClientData = {
todayDayIndex: 0,
date: today,
isWeekend: false,
dayIndex: 0,
choices: {},
pizzaDay: {
state,
creator: CREATOR,
orders: [],
},
pizzaList: [],
salatList: [],
};
await storage.setData(today, data);
}
beforeEach(() => {
resetMemoryStorage();
});
describe('createPizzaDay', () => { describe('createPizzaDay', () => {
test('vytvoří pizza day ve stavu CREATED', async () => { test('vytvoří pizza day ve stavu CREATED', async () => {
const data = await createPizzaDay(CREATOR); const data = await createPizzaDay('alice');
expect(data.pizzaDay?.state).toBe(PizzaDayState.CREATED); expect(data.pizzaDay?.state).toBe(PizzaDayState.CREATED);
expect(data.pizzaDay?.creator).toBe(CREATOR); expect(data.pizzaDay?.creator).toBe('alice');
}); });
test('vyhodí chybu, pokud pizza day již existuje', async () => { test('vyhodí chybu, pokud pizza day již existuje', async () => {
await createPizzaDay(CREATOR); await createPizzaDay('alice');
await expect(createPizzaDay(CREATOR)).rejects.toThrow('existuje'); await expect(createPizzaDay('alice')).rejects.toThrow('existuje');
}); });
}); });
describe('deletePizzaDay', () => { describe('deletePizzaDay', () => {
test('smaže pizza day tvůrcem', async () => { test('smaže pizza day tvůrcem', async () => {
await createPizzaDay(CREATOR); await createPizzaDay('alice');
const data = await deletePizzaDay(CREATOR); const data = await deletePizzaDay('alice');
expect(data.pizzaDay).toBeUndefined(); expect(data.pizzaDay).toBeUndefined();
}); });
test('vyhodí chybu pro jiného uživatele', async () => { test('vyhodí chybu pro jiného uživatele', async () => {
await createPizzaDay(CREATOR); await createPizzaDay('alice');
await expect(deletePizzaDay(USER)).rejects.toThrow(); await expect(deletePizzaDay('bob')).rejects.toThrow();
}); });
}); });
describe('addPizzaOrder', () => { describe('addPizzaOrder', () => {
test('přidá objednávku pizzy', async () => { test('přidá objednávku pizzy', async () => {
await seedPizzaDay(); await createPizzaDay('alice');
const data = await addPizzaOrder(USER, PIZZA, SIZE); const data = await addPizzaOrder('bob', PIZZA, SIZE);
const order = data.pizzaDay?.orders?.find(o => o.customer === USER); const bobOrder = data.pizzaDay?.orders?.find(o => o.customer === 'bob');
expect(order?.pizzaList?.length).toBe(1); expect(bobOrder?.pizzaList?.length).toBe(1);
expect(order?.totalPrice).toBe(SIZE.price); expect(bobOrder?.totalPrice).toBe(150);
});
test('přičte cenu další pizzy ke stejné objednávce', async () => {
await seedPizzaDay();
await addPizzaOrder(USER, PIZZA, SIZE_M);
const data = await addPizzaOrder(USER, { ...PIZZA, name: 'Quattro' }, SIZE_L);
const order = data.pizzaDay?.orders?.find(o => o.customer === USER);
expect(order?.totalPrice).toBe(SIZE_M.price + SIZE_L.price);
expect(order?.pizzaList).toHaveLength(2);
}); });
test('vyhodí chybu bez aktivního pizza day', async () => { test('vyhodí chybu bez aktivního pizza day', async () => {
await expect(addPizzaOrder(USER, PIZZA, SIZE)).rejects.toThrow('neexistuje'); await expect(addPizzaOrder('bob', PIZZA, SIZE)).rejects.toThrow('neexistuje');
});
test('vyhodí chybu pro pizza day ve stavu LOCKED', async () => {
await seedPizzaDay(PizzaDayState.LOCKED);
await expect(addPizzaOrder(USER, PIZZA, SIZE_M)).rejects.toThrow(PizzaDayState.CREATED);
});
});
describe('removePizzaOrder', () => {
test('odečte cenu a odstraní položku z objednávky', async () => {
await seedPizzaDay();
await addPizzaOrder(USER, PIZZA, SIZE_M);
await addPizzaOrder(USER, { ...PIZZA, name: 'Diavola' }, SIZE_L);
const variant = { varId: SIZE_M.varId, name: PIZZA.name, size: SIZE_M.size, price: SIZE_M.price };
const data = await removePizzaOrder(USER, variant);
const order = data.pizzaDay?.orders?.find(o => o.customer === USER);
expect(order?.totalPrice).toBe(SIZE_L.price);
expect(order?.pizzaList).toHaveLength(1);
});
test('odstraní celou objednávku, pokud je prázdná', async () => {
await seedPizzaDay();
await addPizzaOrder(USER, PIZZA, SIZE_M);
const variant = { varId: SIZE_M.varId, name: PIZZA.name, size: SIZE_M.size, price: SIZE_M.price };
const data = await removePizzaOrder(USER, variant);
const order = data.pizzaDay?.orders?.find(o => o.customer === USER);
expect(order).toBeUndefined();
});
});
describe('removeAllUserPizzas', () => {
test('odstraní objednávku uživatele', async () => {
await seedPizzaDay();
await addPizzaOrder(USER, PIZZA, SIZE);
const data = await removeAllUserPizzas(USER);
const order = data.pizzaDay?.orders?.find(o => o.customer === USER);
expect(order).toBeUndefined();
});
test('je no-op bez pizza day', async () => {
const data = await removeAllUserPizzas(USER);
expect(data.pizzaDay).toBeUndefined();
});
});
describe('updatePizzaFee', () => {
test('přidá příplatek a přepočítá celkovou cenu', async () => {
await seedPizzaDay();
await addPizzaOrder(USER, PIZZA, SIZE_M);
const data = await updatePizzaFee(CREATOR, USER, 'Balné', 20);
const order = data.pizzaDay?.orders?.find(o => o.customer === USER);
expect(order?.fee).toEqual({ text: 'Balné', price: 20 });
expect(order?.totalPrice).toBe(SIZE_M.price + 20);
});
test('s cenou undefined odstraní příplatek', async () => {
await seedPizzaDay();
await addPizzaOrder(USER, PIZZA, SIZE_M);
await updatePizzaFee(CREATOR, USER, 'Balné', 20);
const data = await updatePizzaFee(CREATOR, USER, undefined, undefined);
const order = data.pizzaDay?.orders?.find(o => o.customer === USER);
expect(order?.fee).toBeUndefined();
expect(order?.totalPrice).toBe(SIZE_M.price);
});
test('vyhodí chybu, pokud volá jiný uživatel než tvůrce', async () => {
await seedPizzaDay();
await addPizzaOrder(USER, PIZZA, SIZE_M);
await expect(updatePizzaFee(USER, USER, 'Balné', 20)).rejects.toThrow('zakladatel');
}); });
}); });
describe('lockPizzaDay / unlockPizzaDay', () => { describe('lockPizzaDay / unlockPizzaDay', () => {
test('tvůrce může zamknout pizza day', async () => { test('tvůrce může zamknout pizza day', async () => {
await seedPizzaDay(); await createPizzaDay('alice');
const data = await lockPizzaDay(CREATOR); const data = await lockPizzaDay('alice');
expect(data.pizzaDay?.state).toBe(PizzaDayState.LOCKED); expect(data.pizzaDay?.state).toBe(PizzaDayState.LOCKED);
}); });
test('jiný uživatel nemůže zamknout pizza day', async () => { test('jiný uživatel nemůže zamknout pizza day', async () => {
await seedPizzaDay(); await createPizzaDay('alice');
await expect(lockPizzaDay(USER)).rejects.toThrow(USER); // chybová zpráva obsahuje login volajícího (bob), nikoli tvůrce
await expect(lockPizzaDay('bob')).rejects.toThrow('bob');
}); });
test('zamčený pizza day lze odemknout', async () => { test('zamčený pizza day lze odemknout', async () => {
await seedPizzaDay(); await createPizzaDay('alice');
await lockPizzaDay(CREATOR); await lockPizzaDay('alice');
const data = await unlockPizzaDay(CREATOR); const data = await unlockPizzaDay('alice');
expect(data.pizzaDay?.state).toBe(PizzaDayState.CREATED); expect(data.pizzaDay?.state).toBe(PizzaDayState.CREATED);
}); });
test('nelze odemknout nezamčený pizza day', async () => { test('nelze odemknout nezamčený pizza day', async () => {
await seedPizzaDay(); await createPizzaDay('alice');
await expect(unlockPizzaDay(CREATOR)).rejects.toThrow(PizzaDayState.LOCKED); await expect(unlockPizzaDay('alice')).rejects.toThrow(PizzaDayState.LOCKED);
}); });
}); });
describe('finishPizzaOrder', () => { describe('finishPizzaOrder', () => {
test('přesune pizza day do stavu ORDERED', async () => { test('přesune pizza day do stavu ORDERED', async () => {
await seedPizzaDay(); await createPizzaDay('alice');
await lockPizzaDay(CREATOR); await lockPizzaDay('alice');
const data = await finishPizzaOrder(CREATOR); const data = await finishPizzaOrder('alice');
expect(data.pizzaDay?.state).toBe(PizzaDayState.ORDERED); expect(data.pizzaDay?.state).toBe(PizzaDayState.ORDERED);
}); });
test('vyhodí chybu v nesprávném stavu (CREATED)', async () => { test('vyhodí chybu v nesprávném stavu (CREATED)', async () => {
await seedPizzaDay(); await createPizzaDay('alice');
await expect(finishPizzaOrder(CREATOR)).rejects.toThrow(PizzaDayState.LOCKED); await expect(finishPizzaOrder('alice')).rejects.toThrow(PizzaDayState.LOCKED);
}); });
}); });
describe('finishPizzaDelivery', () => { describe('finishPizzaDelivery', () => {
test('přesune pizza day do stavu DELIVERED', async () => { test('přesune pizza day do stavu DELIVERED', async () => {
await seedPizzaDay(); await createPizzaDay('alice');
await lockPizzaDay(CREATOR); await lockPizzaDay('alice');
await finishPizzaOrder(CREATOR); await finishPizzaOrder('alice');
const data = await finishPizzaDelivery(CREATOR); const data = await finishPizzaDelivery('alice');
expect(data.pizzaDay?.state).toBe(PizzaDayState.DELIVERED); expect(data.pizzaDay?.state).toBe(PizzaDayState.DELIVERED);
}); });
test('vyhodí chybu v nesprávném stavu (LOCKED)', async () => { test('vyhodí chybu v nesprávném stavu (LOCKED)', async () => {
await seedPizzaDay(); await createPizzaDay('alice');
await lockPizzaDay(CREATOR); await lockPizzaDay('alice');
await expect(finishPizzaDelivery(CREATOR)).rejects.toThrow(PizzaDayState.ORDERED); await expect(finishPizzaDelivery('alice')).rejects.toThrow(PizzaDayState.ORDERED);
});
});
describe('removeAllUserPizzas', () => {
test('odstraní objednávku uživatele', async () => {
await createPizzaDay('alice');
await addPizzaOrder('bob', PIZZA, SIZE);
const data = await removeAllUserPizzas('bob');
const bobOrder = data.pizzaDay?.orders?.find(o => o.customer === 'bob');
expect(bobOrder).toBeUndefined();
});
test('je no-op bez pizza day', async () => {
const data = await removeAllUserPizzas('bob');
expect(data.pizzaDay).toBeUndefined();
}); });
}); });
-36
View File
@@ -1,36 +0,0 @@
import { convertBbanToIban } from '../qr';
test('konverze BBAN s prefixem na IBAN', () => {
// Číslo účtu 19-2000145399/0800 (Česká spořitelna) → CZ6508000000192000145399
const iban = convertBbanToIban('19-2000145399/0800');
expect(iban).toBe('CZ6508000000192000145399');
expect(iban).toHaveLength(24);
});
test('konverze BBAN bez prefixu na IBAN', () => {
// Číslo účtu 2000145399/0800 (bez prefixu) → prefix se doplní jako 000000
const iban = convertBbanToIban('2000145399/0800');
expect(iban).toBe('CZ7908000000002000145399');
expect(iban).toHaveLength(24);
});
test('konverze BBAN s krátkým číslem účtu zero-padding', () => {
// Krátké číslo účtu 123456/0100 → prefix 000000, account 0000123456
const iban = convertBbanToIban('123456/0100');
expect(iban).toHaveLength(24);
// bankCode(4) + prefix(6) + account(10) = 20 číslic za CZ+checkdigits
expect(iban).toMatch(/^CZ\d{2}01000000000000123456$/);
});
test('kontrolní číslice jsou platné (mod 97)', () => {
const iban = convertBbanToIban('19-2000145399/0800');
// Přesuneme první 4 znaky na konec, nahradíme písmena čísly a mod 97 musí dát 1
const rearranged = iban.slice(4) + iban.slice(0, 4);
const numeric = rearranged.replace(/[A-Z]/g, (c) => (c.charCodeAt(0) - 55).toString());
expect(BigInt(numeric) % BigInt(97)).toBe(BigInt(1));
});
test('výsledek vždy začíná CZ', () => {
expect(convertBbanToIban('100-2000145399/0300')).toMatch(/^CZ/);
expect(convertBbanToIban('2000145399/0100')).toMatch(/^CZ/);
});
-103
View File
@@ -1,103 +0,0 @@
import express from 'express';
import request from 'supertest';
import bodyParser from 'body-parser';
import axios from 'axios';
import { generateToken } from '../auth';
import { resetMemoryStorage } from '../storage/memory';
import qrRouter from '../routes/qrRoutes';
jest.mock('axios');
const mockedAxios = axios as jest.Mocked<typeof axios>;
function buildApp() {
const app = express();
app.use(bodyParser.json());
app.use('/api/qr', qrRouter);
app.use((err: any, _req: any, res: any, _next: any) => {
res.status(400).json({ error: err.message });
});
return app;
}
const TOKEN = `Bearer ${generateToken('kreator')}`;
beforeEach(() => {
resetMemoryStorage();
mockedAxios.get = jest.fn().mockResolvedValue({ data: Buffer.from('fake-png') });
});
const VALID_BODY = {
recipients: [
{ login: 'uzivatel1', purpose: 'Pizza Margherita', amount: 149 },
{ login: 'uzivatel2', purpose: 'Pizza Diavola', amount: 179 },
],
bankAccount: '19-2000145399/0800',
bankAccountHolder: 'Jan Novák',
};
test('POST /generate vrátí 200 s počtem vygenerovaných QR kódů', async () => {
const res = await request(buildApp())
.post('/api/qr/generate')
.set('Authorization', TOKEN)
.send(VALID_BODY);
expect(res.status).toBe(200);
expect(res.body.count).toBe(2);
});
test('POST /generate vrátí 400 pro prázdné recipients', async () => {
const res = await request(buildApp())
.post('/api/qr/generate')
.set('Authorization', TOKEN)
.send({ ...VALID_BODY, recipients: [] });
expect(res.status).toBe(400);
expect(res.body.error).toContain('příjemců');
});
test('POST /generate vrátí 400 pro chybějící bankAccount', async () => {
const { bankAccount: _, ...body } = VALID_BODY;
const res = await request(buildApp())
.post('/api/qr/generate')
.set('Authorization', TOKEN)
.send(body);
expect(res.status).toBe(400);
expect(res.body.error).toContain('účtu');
});
test('POST /generate vrátí 400 pro zápornou částku', async () => {
const body = {
...VALID_BODY,
recipients: [{ login: 'uzivatel1', purpose: 'Pizza', amount: -1 }],
};
const res = await request(buildApp())
.post('/api/qr/generate')
.set('Authorization', TOKEN)
.send(body);
expect(res.status).toBe(400);
expect(res.body.error).toContain('částku');
});
test('POST /generate vrátí 400 pro částku s více než 2 desetinnými místy', async () => {
const body = {
...VALID_BODY,
recipients: [{ login: 'uzivatel1', purpose: 'Pizza', amount: 149.999 }],
};
const res = await request(buildApp())
.post('/api/qr/generate')
.set('Authorization', TOKEN)
.send(body);
expect(res.status).toBe(400);
expect(res.body.error).toContain('desetinná');
});
test('POST /generate vrátí 400 pro příjemce bez login', async () => {
const body = {
...VALID_BODY,
recipients: [{ purpose: 'Pizza', amount: 149 }],
};
const res = await request(buildApp())
.post('/api/qr/generate')
.set('Authorization', TOKEN)
.send(body);
expect(res.status).toBe(400);
expect(res.body.error).toContain('login');
});
@@ -1,73 +0,0 @@
import { parseAllergens, isTextSoupName, sanitizeText, capitalize } from '../restaurants';
// parseAllergens
test('parseAllergens rozpozná alergeny na konci názvu', () => {
const result = parseAllergens('Svíčková na smetaně 1, 3, 7');
expect(result.cleanName).toBe('Svíčková na smetaně');
expect(result.allergens).toEqual([1, 3, 7]);
});
test('parseAllergens vrátí prázdné pole alergenů, pokud žádné nejsou', () => {
const result = parseAllergens('Svíčková na smetaně');
expect(result.cleanName).toBe('Svíčková na smetaně');
expect(result.allergens).toEqual([]);
});
test('parseAllergens zpracuje jednočíselný alergen', () => {
const result = parseAllergens('Polévka dne 1');
expect(result.cleanName).toBe('Polévka dne');
expect(result.allergens).toEqual([1]);
});
test('parseAllergens neodstraní čísla uvnitř názvu', () => {
const result = parseAllergens('Pizza č. 4 Quattro formaggi 1, 7');
expect(result.allergens).toEqual([1, 7]);
expect(result.cleanName).toContain('4');
});
// isTextSoupName
test('isTextSoupName vrátí true pro "polévka"', () => {
expect(isTextSoupName('Polévka dne')).toBe(true);
});
test('isTextSoupName vrátí true pro "česnečka"', () => {
expect(isTextSoupName('Česnečka se sýrem')).toBe(true);
});
test('isTextSoupName vrátí true pro "vývar"', () => {
expect(isTextSoupName('Hovězí vývar s nudlemi')).toBe(true);
});
test('isTextSoupName vrátí false pro hlavní jídlo', () => {
expect(isTextSoupName('Svíčková na smetaně s knedlíkem')).toBe(false);
});
test('isTextSoupName není case-sensitive', () => {
expect(isTextSoupName('POLÉVKA DNE')).toBe(true);
});
// sanitizeText
test('sanitizeText odstraní tabulátor (nenahradí mezerou)', () => {
expect(sanitizeText('\ttext')).toBe('text');
});
test('sanitizeText opraví mezery kolem čárky', () => {
expect(sanitizeText('jídlo , příloha')).toBe('jídlo, příloha');
});
test('sanitizeText ořeže mezery ze začátku a konce', () => {
expect(sanitizeText(' text ')).toBe('text');
});
// capitalize
test('capitalize převede první písmeno na velké', () => {
expect(capitalize('pondělí')).toBe('Pondělí');
});
test('capitalize nezmění zbytek řetězce', () => {
expect(capitalize('pÁTEK')).toBe('PÁTEK');
});
test('capitalize vrátí prázdný řetězec pro prázdný vstup', () => {
expect(capitalize('')).toBe('');
});
-117
View File
@@ -1,117 +0,0 @@
import * as fs from 'fs';
import * as path from 'path';
import axios from 'axios';
import { getMenuSladovnicka, getMenuTechTower, getMenuSenkSerikova, StaleWeekError } from '../restaurants';
jest.mock('axios');
const mockedAxios = axios as jest.Mocked<typeof axios>;
const fixturesDir = path.join(__dirname, 'fixtures');
const loadFixture = (name: string) => fs.readFileSync(path.join(fixturesDir, name), 'utf-8');
// Pondělí 12.5.2025
const MONDAY = new Date('2025-05-12');
beforeEach(() => {
jest.resetAllMocks();
});
describe('Sladovnicka parser', () => {
beforeEach(() => {
mockedAxios.get = jest.fn().mockResolvedValue({ data: loadFixture('sladovnicka.html') });
});
test('vrátí pole o délce 5 (jeden záznam na každý pracovní den)', async () => {
const menu = await getMenuSladovnicka(MONDAY);
expect(menu).toHaveLength(5);
});
test('pondělní menu obsahuje aspoň jedno jídlo', async () => {
const menu = await getMenuSladovnicka(MONDAY);
expect(menu[0].length).toBeGreaterThan(0);
});
test('první položka pondělního dne je polévka (isSoup=true)', async () => {
const menu = await getMenuSladovnicka(MONDAY);
expect(menu[0][0].isSoup).toBe(true);
});
test('jídla mají name, price a amount', async () => {
const menu = await getMenuSladovnicka(MONDAY);
const jidlo = menu[0][1];
expect(jidlo.name).toBeTruthy();
expect(jidlo.price).toBeTruthy();
expect(jidlo.amount).toBeTruthy();
});
test('alergeny jsou naparsovány jako čísla', async () => {
const menu = await getMenuSladovnicka(MONDAY);
const polievka = menu[0][0];
expect(Array.isArray(polievka.allergens)).toBe(true);
expect(polievka.allergens!.length).toBeGreaterThan(0);
expect(typeof polievka.allergens![0]).toBe('number');
});
});
describe('TechTower parser', () => {
beforeEach(() => {
mockedAxios.get = jest.fn().mockResolvedValue({ data: loadFixture('techtower.html') });
});
test('vrátí pole o délce 5', async () => {
const menu = await getMenuTechTower(MONDAY);
expect(menu).toHaveLength(5);
});
test('pondělní menu obsahuje polévku a hlavní jídla', async () => {
const menu = await getMenuTechTower(MONDAY);
expect(menu[0].some(f => f.isSoup)).toBe(true);
expect(menu[0].some(f => !f.isSoup)).toBe(true);
});
test('TechTower hodí StaleWeekError, pokud datum v hlavičce neodpovídá', async () => {
// Fixture obsahuje "12.5.-16.5.2025" jiný týden = stale
const jinaStreda = new Date('2025-04-14');
await expect(getMenuTechTower(jinaStreda)).rejects.toBeInstanceOf(StaleWeekError);
});
test('StaleWeekError obsahuje naparsovaná data', async () => {
const jinaStreda = new Date('2025-04-14');
try {
await getMenuTechTower(jinaStreda);
} catch (e) {
expect(e).toBeInstanceOf(StaleWeekError);
const err = e as StaleWeekError;
expect(err.food).toHaveLength(5);
}
});
});
describe('SenkSerikova parser', () => {
beforeEach(() => {
// SenkSerikova parsuje arraybuffer musíme vrátit Buffer, ne string
mockedAxios.get = jest.fn().mockResolvedValue({
data: Buffer.from(loadFixture('senkserikova.html')),
headers: {}
});
});
test('parser provede HTTP request a vrátí pole', async () => {
const menu = await getMenuSenkSerikova(MONDAY);
expect(mockedAxios.get).toHaveBeenCalledTimes(1);
expect(Array.isArray(menu)).toBe(true);
});
test('výsledné dny s obsahem mají správnou strukturu (name, price, isSoup)', async () => {
const menu = await getMenuSenkSerikova(MONDAY);
// Protože MONDAY je v minulosti, parser vrátí placeholdery pro všechny pracovní
// dny a .menicka elementy přidá za ně hledáme aspoň jeden den s reálnými daty
const denSJidlem = menu.find(den =>
den.length > 0 && den[0].name !== 'Pro tento den není uveřejněna nabídka jídel'
);
if (denSJidlem) {
expect(typeof denSJidlem[0].name).toBe('string');
expect(typeof denSJidlem[0].isSoup).toBe('boolean');
}
});
});
+1 -9
View File
@@ -12,18 +12,10 @@ jest.mock('../storage', () => ({
import { getDateForWeekIndex, getMenuKey, getEmptyData } from '../service'; import { getDateForWeekIndex, getMenuKey, getEmptyData } from '../service';
import { formatDate } from '../utils'; import { formatDate } from '../utils';
// Pin "today" to 2025-01-10 (Friday, week 2) for deterministic tests // MOCK_DATA=true pins "today" to 2025-01-10 (Friday, week 2)
// Monday of that week = 2025-01-06, ..., Friday = 2025-01-10 // Monday of that week = 2025-01-06, ..., Friday = 2025-01-10
describe('getDateForWeekIndex', () => { describe('getDateForWeekIndex', () => {
beforeAll(() => {
jest.useFakeTimers();
jest.setSystemTime(new Date('2025-01-10'));
});
afterAll(() => {
jest.useRealTimers();
});
test('index 0 (pondělí) vrátí 2025-01-06', () => { test('index 0 (pondělí) vrátí 2025-01-06', () => {
expect(formatDate(getDateForWeekIndex(0))).toBe('2025-01-06'); expect(formatDate(getDateForWeekIndex(0))).toBe('2025-01-06');
}); });
-5
View File
@@ -1,5 +0,0 @@
process.env.NODE_ENV = 'test';
process.env.STORAGE = 'memory';
process.env.JWT_SECRET = 'test-jwt-secret-ktery-ma-alespon-32-znaku';
process.env.LOGOUT_URL = 'http://localhost/logout';
delete process.env.MOCK_DATA;
-60
View File
@@ -1,60 +0,0 @@
import express from 'express';
import request from 'supertest';
import bodyParser from 'body-parser';
import { generateToken } from '../auth';
import { resetMemoryStorage } from '../storage/memory';
import statsRouter from '../routes/statsRoutes';
function buildApp() {
const app = express();
app.use(bodyParser.json());
app.use('/api/stats', statsRouter);
return app;
}
const TOKEN = `Bearer ${generateToken('testuser')}`;
beforeEach(() => {
resetMemoryStorage();
});
test('GET /stats bez parametrů vrátí 400', async () => {
const res = await request(buildApp())
.get('/api/stats')
.set('Authorization', TOKEN);
expect(res.status).toBe(400);
});
test('GET /stats s rozsahem 4 dní vrátí 200', async () => {
const res = await request(buildApp())
.get('/api/stats')
.query({ startDate: '2024-01-08', endDate: '2024-01-12' })
.set('Authorization', TOKEN);
expect(res.status).toBe(200);
expect(Array.isArray(res.body)).toBe(true);
});
test('GET /stats s rozsahem nad 4 dní vrátí 400', async () => {
const res = await request(buildApp())
.get('/api/stats')
.query({ startDate: '2024-01-01', endDate: '2024-01-10' })
.set('Authorization', TOKEN);
expect(res.status).toBe(400);
});
test('GET /stats s budoucím datem vrátí 400', async () => {
const futureStart = '2099-01-01';
const futureEnd = '2099-01-05';
const res = await request(buildApp())
.get('/api/stats')
.query({ startDate: futureStart, endDate: futureEnd })
.set('Authorization', TOKEN);
expect(res.status).toBe(400);
});
test('GET /stats bez tokenu vrátí chybu', async () => {
const res = await request(buildApp())
.get('/api/stats')
.query({ startDate: '2024-01-08', endDate: '2024-01-12' });
expect(res.status).toBeGreaterThanOrEqual(400);
});
-85
View File
@@ -1,85 +0,0 @@
import * as os from 'os';
import * as path from 'path';
import * as fs from 'fs';
import { StorageInterface } from '../storage/StorageInterface';
import { resetMemoryStorage } from '../storage/memory';
import MemoryStorage from '../storage/memory';
import JsonStorage from '../storage/json';
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'luncher-test-'));
const tempDbPath = path.join(tempDir, 'test-db.json');
// Parametrické spuštění stejné sady testů pro obě implementace
const implementations: [string, () => StorageInterface, () => void][] = [
['MemoryStorage', () => new MemoryStorage(), resetMemoryStorage],
['JsonStorage', () => {
// Zajistíme čistý stav souboru před každým testem
if (fs.existsSync(tempDbPath)) {
fs.unlinkSync(tempDbPath);
}
// JsonStorage načte/vytvoří soubor při inicializaci, musíme obalit
const JsonStorageDynamic = require('../storage/json').default;
// Přepíšeme dbPath přes prototyp pro testy použijeme tmpdir
const inst = Object.create(JsonStorageDynamic.prototype);
const JSONdb = require('simple-json-db');
(inst as any).db = new JSONdb(tempDbPath);
inst.hasData = async (key: string) => Promise.resolve((inst as any).db.has(key));
inst.getData = async (key: string) => (inst as any).db.get(key);
inst.setData = async (key: string, data: any) => { (inst as any).db.set(key, data); return Promise.resolve(); };
return inst;
}, () => {
if (fs.existsSync(tempDbPath)) {
fs.unlinkSync(tempDbPath);
}
}],
];
describe.each(implementations)('%s splňuje StorageInterface kontrakt', (name, factory, reset) => {
let storage: StorageInterface;
beforeEach(() => {
reset();
storage = factory();
});
test('hasData vrátí false pro neexistující klíč', async () => {
expect(await storage.hasData('neexistujici')).toBe(false);
});
test('setData + hasData vrátí true', async () => {
await storage.setData('klic', { value: 1 });
expect(await storage.hasData('klic')).toBe(true);
});
test('setData + getData vrátí uložená data', async () => {
const data = { name: 'Jan', score: 42 };
await storage.setData('testkey', data);
const result = await storage.getData('testkey');
expect(result).toEqual(data);
});
test('getData pro neexistující klíč vrátí undefined', async () => {
const result = await storage.getData('neexistujici');
expect(result).toBeUndefined();
});
test('setData přepíše existující data', async () => {
await storage.setData('klic', { version: 1 });
await storage.setData('klic', { version: 2 });
const result = await storage.getData<{ version: number }>('klic');
expect(result?.version).toBe(2);
});
test('různé klíče jsou nezávislé', async () => {
await storage.setData('a', { val: 'A' });
await storage.setData('b', { val: 'B' });
expect((await storage.getData<{ val: string }>('a'))?.val).toBe('A');
expect((await storage.getData<{ val: string }>('b'))?.val).toBe('B');
});
});
afterAll(() => {
if (fs.existsSync(tempDir)) {
fs.rmSync(tempDir, { recursive: true });
}
});
+32 -43
View File
@@ -1,73 +1,62 @@
import { getUserVotes, updateFeatureVote, getVotingStats } from '../voting';
import { resetMemoryStorage } from '../storage/memory';
import { FeatureRequest } from '../../../types/gen/types.gen'; import { FeatureRequest } from '../../../types/gen/types.gen';
const OPT_A = FeatureRequest.STATISTICS; const mockStorageData = new Map<string, any>();
const OPT_B = FeatureRequest.UI; jest.mock('../storage', () => ({
__esModule: true,
default: () => ({
hasData: async (key: string) => mockStorageData.has(key),
getData: async <T>(key: string) => mockStorageData.get(key) as T,
setData: async <T>(key: string, val: T) => void mockStorageData.set(key, val),
}),
storageReady: Promise.resolve(),
}));
beforeEach(() => { import { updateFeatureVote, getVotingStats } from '../voting';
resetMemoryStorage();
}); beforeEach(() => mockStorageData.clear());
describe('updateFeatureVote', () => { describe('updateFeatureVote', () => {
const feat = 'FEATURE_A' as FeatureRequest;
test('přidá hlas pro nového uživatele', async () => { test('přidá hlas pro nového uživatele', async () => {
const result = await updateFeatureVote('alice', OPT_A, true); const result = await updateFeatureVote('alice', feat, true);
expect(result['alice']).toContain(OPT_A); expect(result['alice']).toContain(feat);
}); });
test('vyhodí chybu při duplicitním hlasování', async () => { test('vyhodí chybu při duplicitním hlasování', async () => {
await updateFeatureVote('alice', OPT_A, true); await updateFeatureVote('alice', feat, true);
await expect(updateFeatureVote('alice', OPT_A, true)).rejects.toThrow('hlasovali'); await expect(updateFeatureVote('alice', feat, true)).rejects.toThrow('hlasovali');
}); });
test('odebere hlas', async () => { test('odebere hlas', async () => {
await updateFeatureVote('alice', OPT_A, true); await updateFeatureVote('alice', feat, true);
await updateFeatureVote('alice', OPT_A, false); await updateFeatureVote('alice', feat, false);
const stats = await getVotingStats(); const stats = await getVotingStats();
expect(stats[OPT_A] ?? 0).toBe(0); expect(stats[feat] ?? 0).toBe(0);
}); });
test('odebrání neexistujícího hlasu je no-op', async () => { test('odebrání neexistujícího hlasu je no-op', async () => {
await expect(updateFeatureVote('alice', OPT_A, false)).resolves.not.toThrow(); await expect(updateFeatureVote('alice', feat, false)).resolves.not.toThrow();
});
test('odebrání posledního hlasu odstraní login ze storage', async () => {
await updateFeatureVote('alice', OPT_A, true);
const data = await updateFeatureVote('alice', OPT_A, false);
expect('alice' in data).toBe(false);
}); });
test('vyhodí chybu po 4 hlasech', async () => { test('vyhodí chybu po 4 hlasech', async () => {
const options = Object.values(FeatureRequest); const features = ['FA', 'FB', 'FC', 'FD'] as FeatureRequest[];
for (let i = 0; i < 4; i++) { for (const f of features) {
await updateFeatureVote('alice', options[i], true); await updateFeatureVote('alice', f, true);
} }
await expect(updateFeatureVote('alice', options[4], true)).rejects.toThrow('4'); await expect(updateFeatureVote('alice', 'FE' as FeatureRequest, true)).rejects.toThrow('4');
});
});
describe('getUserVotes', () => {
test('vrátí hlasy uživatele', async () => {
await updateFeatureVote('alice', OPT_A, true);
const votes = await getUserVotes('alice');
expect(votes).toContain(OPT_A);
});
test('vrátí prázdné pole pro uživatele bez hlasů', async () => {
const votes = await getUserVotes('neexistujici');
expect(votes).toEqual([]);
}); });
}); });
describe('getVotingStats', () => { describe('getVotingStats', () => {
test('vrátí agregované počty hlasů', async () => { test('vrátí agregované počty hlasů', async () => {
await updateFeatureVote('alice', OPT_A, true); await updateFeatureVote('alice', 'FA' as FeatureRequest, true);
await updateFeatureVote('bob', OPT_A, true); await updateFeatureVote('bob', 'FA' as FeatureRequest, true);
await updateFeatureVote('bob', OPT_B, true); await updateFeatureVote('bob', 'FB' as FeatureRequest, true);
const stats = await getVotingStats(); const stats = await getVotingStats();
expect(stats[OPT_A]).toBe(2); expect(stats['FA']).toBe(2);
expect(stats[OPT_B]).toBe(1); expect(stats['FB']).toBe(1);
}); });
test('vrátí prázdný objekt bez hlasů', async () => { test('vrátí prázdný objekt bez hlasů', async () => {
-76
View File
@@ -1,76 +0,0 @@
import express from 'express';
import request from 'supertest';
import bodyParser from 'body-parser';
import { generateToken } from '../auth';
import { resetMemoryStorage } from '../storage/memory';
import { FeatureRequest } from '../../../types/gen/types.gen';
import votingRouter from '../routes/votingRoutes';
const VALID_OPTION = FeatureRequest.STATISTICS;
function buildApp() {
const app = express();
app.use(bodyParser.json());
app.use('/api/voting', votingRouter);
app.use((err: any, _req: any, res: any, _next: any) => {
res.status(400).json({ error: err.message });
});
return app;
}
const TOKEN = `Bearer ${generateToken('testuser')}`;
beforeEach(() => {
resetMemoryStorage();
});
test('GET /getVotes vrátí 200 s prázdným polem pro nového uživatele', async () => {
const res = await request(buildApp())
.get('/api/voting/getVotes')
.set('Authorization', TOKEN);
expect(res.status).toBe(200);
expect(res.body).toEqual([]);
});
test('GET /getVotes vrátí 401 bez tokenu', async () => {
const res = await request(buildApp()).get('/api/voting/getVotes');
expect(res.status).toBeGreaterThanOrEqual(400);
});
test('POST /updateVote přidá hlas a vrátí 200', async () => {
const res = await request(buildApp())
.post('/api/voting/updateVote')
.set('Authorization', TOKEN)
.send({ option: VALID_OPTION, active: true });
expect(res.status).toBe(200);
});
test('POST /updateVote vrátí 400 pro chybějící parametry', async () => {
const res = await request(buildApp())
.post('/api/voting/updateVote')
.set('Authorization', TOKEN)
.send({});
expect(res.status).toBe(400);
});
test('POST /updateVote vrátí 400 při duplicitním hlasu', async () => {
const app = buildApp();
await request(app)
.post('/api/voting/updateVote')
.set('Authorization', TOKEN)
.send({ option: VALID_OPTION, active: true });
const res = await request(app)
.post('/api/voting/updateVote')
.set('Authorization', TOKEN)
.send({ option: VALID_OPTION, active: true });
expect(res.status).toBe(400);
expect(res.body.error).toContain('hlasovali');
});
test('GET /stats vrátí 200 s objektem', async () => {
const res = await request(buildApp())
.get('/api/voting/stats')
.set('Authorization', TOKEN);
expect(res.status).toBe(200);
expect(typeof res.body).toBe('object');
});
+2 -124
View File
@@ -1448,18 +1448,6 @@
"@emnapi/runtime" "^1.4.3" "@emnapi/runtime" "^1.4.3"
"@tybys/wasm-util" "^0.10.0" "@tybys/wasm-util" "^0.10.0"
"@noble/hashes@^1.1.5":
version "1.8.0"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.8.0.tgz#cee43d801fcef9644b11b8194857695acd5f815a"
integrity sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==
"@paralleldrive/cuid2@^2.2.2":
version "2.3.1"
resolved "https://registry.yarnpkg.com/@paralleldrive/cuid2/-/cuid2-2.3.1.tgz#3d62ea9e7be867d3fa94b9897fab5b0ae187d784"
integrity sha512-XO7cAxhnTZl0Yggq6jOgjiOHhbgcO4NqFqwSmQpjK3b6TEE6Uj/jfSk6wzYyemh3+I0sHirKSetjQwn5cZktFw==
dependencies:
"@noble/hashes" "^1.1.5"
"@pkgjs/parseargs@^0.11.0": "@pkgjs/parseargs@^0.11.0":
version "0.11.0" version "0.11.0"
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
@@ -1606,11 +1594,6 @@
dependencies: dependencies:
"@types/node" "*" "@types/node" "*"
"@types/cookiejar@^2.1.5":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@types/cookiejar/-/cookiejar-2.1.5.tgz#14a3e83fa641beb169a2dd8422d91c3c345a9a78"
integrity sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==
"@types/cors@^2.8.12": "@types/cors@^2.8.12":
version "2.8.19" version "2.8.19"
resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.19.tgz#d93ea2673fd8c9f697367f5eeefc2bbfa94f0342" resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.19.tgz#d93ea2673fd8c9f697367f5eeefc2bbfa94f0342"
@@ -1677,11 +1660,6 @@
"@types/ms" "*" "@types/ms" "*"
"@types/node" "*" "@types/node" "*"
"@types/methods@^1.1.4":
version "1.1.4"
resolved "https://registry.yarnpkg.com/@types/methods/-/methods-1.1.4.tgz#d3b7ac30ac47c91054ea951ce9eed07b1051e547"
integrity sha512-ymXWVrDiCxTBE3+RIrrP533E70eA+9qu7zdWoHuOmGujkYtzf4HQF96b8nwHLqhuf4ykX61IGRIB38CC6/sImQ==
"@types/ms@*": "@types/ms@*":
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/@types/ms/-/ms-2.1.0.tgz#052aa67a48eccc4309d7f0191b7e41434b90bb78" resolved "https://registry.yarnpkg.com/@types/ms/-/ms-2.1.0.tgz#052aa67a48eccc4309d7f0191b7e41434b90bb78"
@@ -1749,24 +1727,6 @@
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8"
integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw== integrity sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==
"@types/superagent@^8.1.0":
version "8.1.9"
resolved "https://registry.yarnpkg.com/@types/superagent/-/superagent-8.1.9.tgz#28bfe4658e469838ed0bf66d898354bcab21f49f"
integrity sha512-pTVjI73witn+9ILmoJdajHGW2jkSaOzhiFYF1Rd3EQ94kymLqB9PjD9ISg7WaALC7+dCHT0FGe9T2LktLq/3GQ==
dependencies:
"@types/cookiejar" "^2.1.5"
"@types/methods" "^1.1.4"
"@types/node" "*"
form-data "^4.0.0"
"@types/supertest@^6.0.0":
version "6.0.3"
resolved "https://registry.yarnpkg.com/@types/supertest/-/supertest-6.0.3.tgz#d736f0e994b195b63e1c93e80271a2faf927388c"
integrity sha512-8WzXq62EXFhJ7QsH3Ocb/iKQ/Ty9ZVWnVzoTKc9tyyFRRF3a74Tk2+TLFgaFFw364Ere+npzHKEJ6ga2LzIL7w==
dependencies:
"@types/methods" "^1.1.4"
"@types/superagent" "^8.1.0"
"@types/tough-cookie@*": "@types/tough-cookie@*":
version "4.0.5" version "4.0.5"
resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.5.tgz#cb6e2a691b70cb177c6e3ae9c1d2e8b2ea8cd304" resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.5.tgz#cb6e2a691b70cb177c6e3ae9c1d2e8b2ea8cd304"
@@ -1980,11 +1940,6 @@ argparse@^1.0.7:
dependencies: dependencies:
sprintf-js "~1.0.2" sprintf-js "~1.0.2"
asap@^2.0.0:
version "2.0.6"
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
integrity sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==
asn1.js@^5.3.0: asn1.js@^5.3.0:
version "5.4.1" version "5.4.1"
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07"
@@ -2339,11 +2294,6 @@ combined-stream@^1.0.6, combined-stream@^1.0.8:
dependencies: dependencies:
delayed-stream "~1.0.0" delayed-stream "~1.0.0"
component-emitter@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.1.tgz#ef1d5796f7d93f135ee6fb684340b26403c97d17"
integrity sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==
concat-map@0.0.1: concat-map@0.0.1:
version "0.0.1" version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
@@ -2364,7 +2314,7 @@ convert-source-map@^2.0.0:
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a"
integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==
cookie-signature@^1.2.1, cookie-signature@^1.2.2: cookie-signature@^1.2.1:
version "1.2.2" version "1.2.2"
resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.2.2.tgz#57c7fc3cc293acab9fec54d73e15690ebe4a1793" resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.2.2.tgz#57c7fc3cc293acab9fec54d73e15690ebe4a1793"
integrity sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg== integrity sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==
@@ -2374,11 +2324,6 @@ cookie@^0.7.1, cookie@~0.7.2:
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.7.2.tgz#556369c472a2ba910f2979891b526b3436237ed7" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.7.2.tgz#556369c472a2ba910f2979891b526b3436237ed7"
integrity sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w== integrity sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==
cookiejar@^2.1.4:
version "2.1.4"
resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.4.tgz#ee669c1fea2cf42dc31585469d193fef0d65771b"
integrity sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==
core-js-compat@^3.43.0: core-js-compat@^3.43.0:
version "3.47.0" version "3.47.0"
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.47.0.tgz#698224bbdbb6f2e3f39decdda4147b161e3772a3" resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.47.0.tgz#698224bbdbb6f2e3f39decdda4147b161e3772a3"
@@ -2424,7 +2369,7 @@ css-what@^6.1.0:
resolved "https://registry.yarnpkg.com/css-what/-/css-what-6.1.0.tgz#fb5effcf76f1ddea2c81bdfaa4de44e79bac70f4" resolved "https://registry.yarnpkg.com/css-what/-/css-what-6.1.0.tgz#fb5effcf76f1ddea2c81bdfaa4de44e79bac70f4"
integrity sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw== integrity sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==
debug@4, debug@^4, debug@^4.1.0, debug@^4.3.1, debug@^4.3.7, debug@^4.4.0, debug@^4.4.1, debug@^4.4.3, debug@~4.4.1: debug@4, debug@^4, debug@^4.1.0, debug@^4.3.1, debug@^4.4.0, debug@^4.4.1, debug@^4.4.3, debug@~4.4.1:
version "4.4.3" version "4.4.3"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.3.tgz#c6ae432d9bd9662582fce08709b038c58e9e3d6a" resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.3.tgz#c6ae432d9bd9662582fce08709b038c58e9e3d6a"
integrity sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA== integrity sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==
@@ -2463,14 +2408,6 @@ detect-newline@^3.1.0:
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA== integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==
dezalgo@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/dezalgo/-/dezalgo-1.0.4.tgz#751235260469084c132157dfa857f386d4c33d81"
integrity sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==
dependencies:
asap "^2.0.0"
wrappy "1"
diff@^4.0.1: diff@^4.0.1:
version "4.0.2" version "4.0.2"
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
@@ -2744,11 +2681,6 @@ fast-json-stable-stringify@^2.1.0:
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
fast-safe-stringify@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz#c406a83b6e70d9e35ce3b30a81141df30aeba884"
integrity sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==
fb-watchman@^2.0.2: fb-watchman@^2.0.2:
version "2.0.2" version "2.0.2"
resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.2.tgz#e9524ee6b5c77e9e5001af0f85f3adbb8623255c" resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.2.tgz#e9524ee6b5c77e9e5001af0f85f3adbb8623255c"
@@ -2806,17 +2738,6 @@ form-data@^2.5.0:
mime-types "^2.1.12" mime-types "^2.1.12"
safe-buffer "^5.2.1" safe-buffer "^5.2.1"
form-data@^4.0.0, form-data@^4.0.5:
version "4.0.5"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.5.tgz#b49e48858045ff4cbf6b03e1805cebcad3679053"
integrity sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
es-set-tostringtag "^2.1.0"
hasown "^2.0.2"
mime-types "^2.1.12"
form-data@^4.0.4: form-data@^4.0.4:
version "4.0.4" version "4.0.4"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.4.tgz#784cdcce0669a9d68e94d11ac4eea98088edd2c4" resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.4.tgz#784cdcce0669a9d68e94d11ac4eea98088edd2c4"
@@ -2828,15 +2749,6 @@ form-data@^4.0.4:
hasown "^2.0.2" hasown "^2.0.2"
mime-types "^2.1.12" mime-types "^2.1.12"
formidable@^3.5.4:
version "3.5.4"
resolved "https://registry.yarnpkg.com/formidable/-/formidable-3.5.4.tgz#ac9a593b951e829b3298f21aa9a2243932f32ed9"
integrity sha512-YikH+7CUTOtP44ZTnUhR7Ic2UASBPOqmaRkRKxRbywPTe5VxF7RRCck4af9wutiZ/QKM5nME9Bie2fFaPz5Gug==
dependencies:
"@paralleldrive/cuid2" "^2.2.2"
dezalgo "^1.0.4"
once "^1.4.0"
forwarded@0.2.0: forwarded@0.2.0:
version "0.2.0" version "0.2.0"
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811"
@@ -3712,11 +3624,6 @@ merge-stream@^2.0.0:
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==
methods@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==
micromatch@^4.0.8: micromatch@^4.0.8:
version "4.0.8" version "4.0.8"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202"
@@ -3749,11 +3656,6 @@ mime-types@^3.0.0, mime-types@^3.0.2:
dependencies: dependencies:
mime-db "^1.54.0" mime-db "^1.54.0"
mime@2.6.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367"
integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==
mimic-fn@^2.1.0: mimic-fn@^2.1.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
@@ -4435,30 +4337,6 @@ strip-json-comments@^3.1.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
superagent@^10.3.0:
version "10.3.0"
resolved "https://registry.yarnpkg.com/superagent/-/superagent-10.3.0.tgz#ff1e39e7976b63f8084291d65f5bfbbbbd156989"
integrity sha512-B+4Ik7ROgVKrQsXTV0Jwp2u+PXYLSlqtDAhYnkkD+zn3yg8s/zjA2MeGayPoY/KICrbitwneDHrjSotxKL+0XQ==
dependencies:
component-emitter "^1.3.1"
cookiejar "^2.1.4"
debug "^4.3.7"
fast-safe-stringify "^2.1.1"
form-data "^4.0.5"
formidable "^3.5.4"
methods "^1.1.2"
mime "2.6.0"
qs "^6.14.1"
supertest@^7.0.0:
version "7.2.2"
resolved "https://registry.yarnpkg.com/supertest/-/supertest-7.2.2.tgz#dac3ee25a2aa59942a7f641e50c838a7c8819204"
integrity sha512-oK8WG9diS3DlhdUkcFn4tkNIiIbBx9lI2ClF8K+b2/m8Eyv47LSawxUzZQSNKUrVb2KsqeTDCcjAAVPYaSLVTA==
dependencies:
cookie-signature "^1.2.2"
methods "^1.1.2"
superagent "^10.3.0"
supports-color@^5.5.0: supports-color@^5.5.0:
version "5.5.0" version "5.5.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"