first-commit
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
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
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
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 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user