Files
Void-Homelab/tests/repos/pages_position.test.js
root 3f77f3faad feat(pages): explicit position ordering + sectioned space view
Add position column to pages (migration 020), update listBySpace to ORDER BY position, title,
expose position in update(), add to patchSchema, and replace the space view flat table with a
tree renderer grouping pages by parent_id under h4 section headers.

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

23 lines
993 B
JavaScript

import { describe, it, expect, beforeEach } from 'vitest';
import { resetDb } from '../helpers/db.js';
import { migrateUp } from '../../lib/db/migrate.js';
import { create, listBySpace, update } from '../../lib/db/repos/pages.js';
import { create as createSpace } from '../../lib/db/repos/spaces.js';
const actor = { kind: 'user', id: null };
beforeEach(async () => { await resetDb(); await migrateUp(); });
describe('page ordering', () => {
it('orders by position then title', async () => {
const space = await createSpace({ slug: 'ord-test', name: 'Ord' }, actor);
const sid = space.id;
const a = await create({ space_id: sid, slug: 'a', title: 'Zzz', body_md: '' }, actor);
const b = await create({ space_id: sid, slug: 'b', title: 'Aaa', body_md: '' }, actor);
await update(a.id, { position: 1 }, actor);
await update(b.id, { position: 9 }, actor);
const list = await listBySpace(sid);
expect(list.map(p => p.title)).toEqual(['Zzz', 'Aaa']);
});
});