Simplify host overview and move enrollment into drawer
This commit is contained in:
@@ -31,6 +31,14 @@ describe('host detail instances', () => {
|
||||
.run(host.id, now, now);
|
||||
db().prepare("UPDATE servers SET container_state='exited' WHERE name='unavailable'").run();
|
||||
|
||||
const { hostOverview } = await import('../../src/lib/server/hosts/overview.js');
|
||||
const overview = hostOverview();
|
||||
expect(overview.find(row => row.id === host.id)?.serverCount).toBe(2);
|
||||
expect(overview.find(row => row.id === other.id)?.serverCount).toBe(1);
|
||||
const { GET: list } = await import('../../src/routes/api/hosts/+server.js');
|
||||
const listed = await list({ request: new Request('https://ec.test/api/hosts') }).json();
|
||||
expect(listed.serverNow).toEqual(expect.any(Number));
|
||||
expect(listed.hosts.find((row: { id: string }) => row.id === host.id)).toMatchObject({ serverCount: 2 });
|
||||
const { GET } = await import('../../src/routes/api/hosts/[id]/+server.js');
|
||||
const read = async (id: string) => (await GET({ request: new Request(`https://ec.test/api/hosts/${id}`), params: { id } }).json());
|
||||
const body = await read(host.id);
|
||||
@@ -42,6 +50,8 @@ describe('host detail instances', () => {
|
||||
db().prepare("UPDATE servers SET last_players=0 WHERE name='running'").run();
|
||||
expect((await read(host.id)).instances[0].last_players).toBe(0);
|
||||
expect((await read(other.id)).instances.map((instance: { name: string }) => instance.name)).toEqual(['other-host']);
|
||||
expect((await read(createHost({ name: 'Empty host' }).id)).instances).toEqual([]);
|
||||
const empty = createHost({ name: 'Empty host' });
|
||||
expect((await read(empty.id)).instances).toEqual([]);
|
||||
expect(hostOverview().find(row => row.id === empty.id)?.serverCount).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user