Files
Void-Homelab/tests/repos/dashboard_layout.test.js
root 262be3e332 test: update dashboard_layout defaults to include geom/extras (2.8.0 follow-up)
These two assertions asserted the pre-2.8.0 shape; the canvas feature
added geom+extras to the repo/route defaults. push.sh doesn't run unit
tests, so they went red unnoticed until the full vitest run.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 00:17:48 +10:00

28 lines
1.0 KiB
JavaScript

import { describe, it, expect, beforeAll } from 'vitest';
import { resetDb } from '../helpers/db.js';
import { migrateUp } from '../../lib/db/migrate.js';
import * as repo from '../../lib/db/repos/dashboard_layout.js';
beforeAll(async () => { await resetDb(); await migrateUp(); });
describe('dashboard_layout repo', () => {
it('returns defaults when unset', async () => {
const l = await repo.get();
expect(l).toEqual({ card_order: [], hidden: [], sizes: {}, geom: {}, extras: [] });
});
it('upserts and reads back', async () => {
await repo.put({ card_order: ['clock', 'weather'], hidden: ['jobs'], sizes: { weather: 's' } });
const l = await repo.get();
expect(l.card_order).toEqual(['clock', 'weather']);
expect(l.hidden).toEqual(['jobs']);
expect(l.sizes).toEqual({ weather: 's' });
});
it('second put overwrites the same single row', async () => {
await repo.put({ card_order: ['host-perf'], hidden: [], sizes: {} });
const l = await repo.get();
expect(l.card_order).toEqual(['host-perf']);
});
});