Files
Zakaria a46764fb1b
ci / Validate workspace (push) Has been cancelled
landing-page-ci / Validate landing page (push) Has been cancelled
landing-page-deploy / Deploy landing page (push) Has been cancelled
github-metrics / Generate repository metrics SVG (push) Has been cancelled
refresh-contributors-wall / Refresh contributors wall cache bust (push) Waiting to run
first-commit
2026-05-04 14:58:14 -04:00

49 lines
1.5 KiB
TypeScript

import type http from 'node:http';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import { startServer } from '../src/server.js';
describe('/api/version', () => {
let server: http.Server;
let baseUrl: string;
beforeAll(async () => {
const started = await startServer({ port: 0, returnServer: true }) as {
url: string;
server: http.Server;
};
baseUrl = started.url;
server = started.server;
});
afterAll(() => new Promise<void>((resolve) => server.close(() => resolve())));
it('returns current app version info', async () => {
const res = await fetch(`${baseUrl}/api/version`);
const json = await res.json() as unknown;
expect(res.ok).toBe(true);
expect(json).toEqual({
version: {
version: expect.any(String),
channel: expect.any(String),
packaged: expect.any(Boolean),
platform: expect.any(String),
arch: expect.any(String),
},
});
});
it('keeps health version aligned with version endpoint', async () => {
const [healthRes, versionRes] = await Promise.all([
fetch(`${baseUrl}/api/health`),
fetch(`${baseUrl}/api/version`),
]);
const health = await healthRes.json() as { ok?: unknown; version?: unknown };
const version = await versionRes.json() as { version?: { version?: unknown } };
expect(healthRes.ok).toBe(true);
expect(versionRes.ok).toBe(true);
expect(health).toEqual({ ok: true, version: version.version?.version });
});
});