import { describe, it, expect } from 'vitest'; import { orderCards } from '../../public/views/cards/registry.js'; const defs = [{ id: 'clock' }, { id: 'weather' }, { id: 'host-perf' }]; describe('orderCards', () => { it('uses saved order first, then appends new cards in default order', () => { const out = orderCards(defs, { card_order: ['weather'], hidden: [] }); expect(out.map(c => c.id)).toEqual(['weather', 'clock', 'host-perf']); }); it('drops hidden cards', () => { const out = orderCards(defs, { card_order: [], hidden: ['clock'] }); expect(out.map(c => c.id)).toEqual(['weather', 'host-perf']); }); it('ignores stale ids in saved order', () => { const out = orderCards(defs, { card_order: ['gone', 'clock'], hidden: [] }); expect(out.map(c => c.id)).toEqual(['clock', 'weather', 'host-perf']); }); });