Ghosted memorial birds
Deploy / deploy-prod (push) Skipped
Deploy / deploy-dev (push) Successful in 3m0s

This commit is contained in:
blaisadmin committed 2026-10-07 21:51:25 -04:00
1 parent 270652f1a8
commit ff177dbaed
4 files changed
+94 -42

No files matched your search

@@ -0,0 +1,20 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { createFlockNote, deleteFlockNote } from './auditRepository.js';
import { mockDb } from '../test/mockDb.js';
test('bird notes require a current, non-memorialized bird in the workspace', async () => {
const { calls } = mockDb({ rows: [] });
const result = await createFlockNote({ workspaceId: 1, birdId: 'bird-1', body: 'Note', createdByUserId: 'user-1' });
assert.equal(result, null);
assert.match(calls[0].text, /birds.workspace_id = \$1\s+AND birds.memorialized_at IS NULL/);
assert.deepEqual(calls[0].params, [1, 'bird-1', 'Note', 'Note', 'user-1']);
});
test('deleting bird notes preserves memorialized and transferred bird history', async () => {
const { calls } = mockDb({ rows: [] });
assert.equal(await deleteFlockNote('note-1', 1), null);
assert.match(calls[0].text, /bird_id IS NULL OR EXISTS/);
assert.match(calls[0].text, /birds.id = flock_notes.bird_id/);
assert.match(calls[0].text, /birds.workspace_id = \$2\s+AND birds.memorialized_at IS NULL/);
});