feat(repos): tags, polymorphic entity_links, attachments

This commit is contained in:
root
2026-05-31 11:02:58 +10:00
parent 1b51c3c18d
commit 47ea0768fd
6 changed files with 190 additions and 0 deletions

27
tests/repos/links.test.js Normal file
View File

@@ -0,0 +1,27 @@
import { describe, it, expect, beforeEach } from 'vitest';
import { resetDb } from '../helpers/db.js';
import { migrateUp } from '../../lib/db/migrate.js';
import * as links from '../../lib/db/repos/links.js';
beforeEach(async () => { await resetDb(); await migrateUp(); });
describe('links repo', () => {
it('create + listFrom + listTo + remove', async () => {
const a = '11111111-1111-1111-1111-111111111111';
const b = '22222222-2222-2222-2222-222222222222';
const link = await links.create('project', a, 'page', b, 'mentions');
expect(link.relation).toBe('mentions');
expect(await links.listFrom('project', a)).toHaveLength(1);
expect(await links.listTo('page', b)).toHaveLength(1);
await links.remove(link.id);
expect(await links.listFrom('project', a)).toHaveLength(0);
});
it('idempotent on the unique tuple', async () => {
const a = '11111111-1111-1111-1111-111111111111';
const b = '22222222-2222-2222-2222-222222222222';
const l1 = await links.create('project', a, 'page', b, 'mentions');
const l2 = await links.create('project', a, 'page', b, 'mentions');
expect(l2.id).toBe(l1.id);
});
});