feat(dashboard): dashboard_layout table + repo

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-02 22:17:27 +10:00
parent 629b42f502
commit c67ac27545
3 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
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: {} });
});
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']);
});
});