Files
Flight-Ops/e2e/api.spec.ts
T
kamilkrzywda 8a12f07703
CI / build + unit + e2e (pull_request) Failing after 12m34s
Ignore a job: dismiss an open package so it leaves the market (ISS-047 part B, v0.29.0)
New terminal status 'ignored' + ignorePackage action + POST /api/packages/{packageId}/ignore
(no body, no penalty; top-up logic refills the market). Ignore button per open-package row in
the Jobs tab. OpenAPI gains the 13th endpoint; unit tests for the action (happy/409x5/404),
engine terminal-status coverage, and a new e2e spec test.
2026-09-20 14:28:47 +00:00

40 lines
1.7 KiB
TypeScript

import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { test, expect } from '@playwright/test';
// Read at test time so the assertions track package.json automatically.
const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8')) as { version: string };
test('GET /api/version returns the app version from package.json', async ({ page }) => {
const res = await page.request.get('/api/version');
expect(res.status()).toBe(200);
expect(res.headers()['content-type']).toContain('application/json');
const body = (await res.json()) as { version: string };
expect(body.version).toBe(pkg.version);
});
test('GET /api/openapi serves the spec with all thirteen endpoints and the package.json version', async ({ page }) => {
const res = await page.request.get('/api/openapi');
expect(res.status()).toBe(200);
expect(res.headers()['content-type']).toContain('application/json');
const spec = (await res.json()) as { info: { title: string; version: string }; paths: Record<string, unknown> };
expect(spec.info.title).toBe('Flight Ops API');
expect(spec.info.version).toBe(pkg.version);
// v0.12.0 swaps the contract accept/dispatch pair for package load/abandon + plane fly.
expect(Object.keys(spec.paths).sort()).toEqual([
'/api/airports',
'/api/market/buy-plane',
'/api/market/sell-plane',
'/api/packages/{id}/abandon',
'/api/packages/{id}/load',
'/api/packages/{packageId}/ignore', // v0.29.0 (ISS-047 part B)
'/api/planes/{planeId}/fly',
'/api/planes/{planeId}/queue',
'/api/planes/{planeId}/queue/cancel',
'/api/planes/{planeId}/refuel',
'/api/sim',
'/api/state',
'/api/version',
]);
});