Add Prettier and ESLint tooling (Refs #77)
This commit is contained in:
@@ -7,14 +7,24 @@ beforeEach(async () => {
|
||||
fixture = await newFixture([]);
|
||||
vi.stubEnv('RCON_PASSWORD', 'fixture-rcon-secret');
|
||||
});
|
||||
afterEach(async () => { await fixture.cleanup(); vi.unstubAllEnvs(); });
|
||||
afterEach(async () => {
|
||||
await fixture.cleanup();
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
it('directs a fresh controller to host enrollment and verified game files', async () => {
|
||||
const { GET } = await import('../../src/routes/api/system-status/+server.js');
|
||||
const response = await GET();
|
||||
const body = await response.json();
|
||||
expect(response.headers.get('cache-control')).toBe('no-store');
|
||||
expect(body.checks.map((check: { id: string }) => check.id)).toEqual(['hosts', 'runtime', 'game-files', 'rcon', 'keys', 'first-server']);
|
||||
expect(body.checks.map((check: { id: string }) => check.id)).toEqual([
|
||||
'hosts',
|
||||
'runtime',
|
||||
'game-files',
|
||||
'rcon',
|
||||
'keys',
|
||||
'first-server'
|
||||
]);
|
||||
expect(body.checks[0]).toMatchObject({ state: 'unconfigured', href: '/hosts' });
|
||||
expect(body.checks[2].state).toBe('attention');
|
||||
expect(body.readyServers).toBe(0);
|
||||
@@ -22,16 +32,22 @@ it('directs a fresh controller to host enrollment and verified game files', asyn
|
||||
});
|
||||
|
||||
it('reports an enrolled but disconnected host as needing attention without issuing commands', async () => {
|
||||
const { createHost, createEnrollment, enrollHost } = await import('../../src/lib/server/hosts/index.js');
|
||||
const { createHost, createEnrollment, enrollHost } =
|
||||
await import('../../src/lib/server/hosts/index.js');
|
||||
const { db } = await import('../../src/lib/server/db/index.js');
|
||||
const host = createHost({ name: 'Game host' });
|
||||
const enrolled = enrollHost(createEnrollment(host.id).token, { protocolVersion: 1 });
|
||||
db().prepare('UPDATE ec_hosts SET last_heartbeat=? WHERE id=?').run('2000-01-01T00:00:00Z', host.id);
|
||||
db()
|
||||
.prepare('UPDATE ec_hosts SET last_heartbeat=? WHERE id=?')
|
||||
.run('2000-01-01T00:00:00Z', host.id);
|
||||
const { GET } = await import('../../src/routes/api/system-status/+server.js');
|
||||
const response = await GET();
|
||||
const text = await response.text();
|
||||
const body = JSON.parse(text);
|
||||
expect(body.checks[0]).toMatchObject({ state: 'attention', detail: expect.stringContaining('0 connected') });
|
||||
expect(body.checks[0]).toMatchObject({
|
||||
state: 'attention',
|
||||
detail: expect.stringContaining('0 connected')
|
||||
});
|
||||
expect(text).not.toContain(enrolled.credential);
|
||||
expect(db().prepare('SELECT id FROM ec_host_operations').all()).toEqual([]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user