Merge branch 'dev'
Deploy / deploy-dev (push) Skipped
Deploy / deploy-prod (push) Successful in 3m3s

# Conflicts:
#	backend/src/app.ts
#	backend/src/db/schema.ts
#	backend/src/queues/adoptionReportQueue.ts
#	backend/src/reports/adoptionReport.ts
#	backend/src/reports/adoptionReportJob.ts
#	backend/src/repositories/birdRepository.ts
#	backend/src/types.ts
#	frontend/src/App.tsx
#	frontend/src/index.css
This commit is contained in:
blaisadmin
2026-07-21 22:25:29 -04:00
19 changed files with 2150 additions and 992 deletions
+55 -12
View File
@@ -7,7 +7,6 @@ import {
createPendingBirdTransfer,
getBirdById,
getOpenBirdTransferCode,
getOpenBirdTransferCodeForBird,
listWeightsForBird,
markBirdTransferCodeCompleted,
transferBirdToWorkspace,
@@ -191,6 +190,46 @@ test('completePendingBirdTransfersForOwner moves pending birds and marks complet
],
},
{ rowCount: 1, rows: [] },
{
rowCount: 1,
rows: [
{
workspace_id: 10,
workspace_name: 'Original Flock',
owner_email: 'sender@example.com',
},
],
},
{
rowCount: 1,
rows: [
{
workspace_id: 22,
workspace_name: 'Receiving Flock',
owner_email: 'receiver@example.com',
},
],
},
{
rowCount: 1,
rows: [
{
id: 'timeline-1',
bird_id: 'bird-1',
event_type: 'transferred',
from_workspace_id: 10,
to_workspace_id: 22,
from_workspace_name: 'Original Flock',
to_workspace_name: 'Receiving Flock',
from_owner_email: 'sender@example.com',
to_owner_email: 'receiver@example.com',
location_label: 'Receiving Flock',
location_details: null,
created_by_user_id: 'user-1',
created_at: '2026-04-15T00:00:00.000Z',
},
],
},
);
const result = await completePendingBirdTransfersForOwner('receiver@example.com', 22);
@@ -200,6 +239,21 @@ test('completePendingBirdTransfersForOwner moves pending birds and marks complet
assert.deepEqual(calls[1].params, ['bird-1', 10, 22]);
assert.deepEqual(calls[2].params, ['transfer-1', 22]);
assert.match(calls[2].text, /completed_at = CURRENT_TIMESTAMP/);
assert.deepEqual(calls[5].params, [
'bird-1',
'transferred',
10,
22,
'Original Flock',
'Receiving Flock',
'sender@example.com',
'receiver@example.com',
null,
null,
null,
'user-1',
null,
]);
});
test('getOpenBirdTransferCode only returns unconsumed codes', async () => {
@@ -214,17 +268,6 @@ test('getOpenBirdTransferCode only returns unconsumed codes', async () => {
assert.match(calls[0].text, /birds\.workspace_id = bird_transfer_codes\.source_workspace_id/);
});
test('getOpenBirdTransferCodeForBird ignores consumed codes', async () => {
const { calls } = mockDb({ rowCount: 0, rows: [] });
const transferCode = await getOpenBirdTransferCodeForBird('bird-1', 10);
assert.equal(transferCode, null);
assert.deepEqual(calls[0].params, ['bird-1', 10]);
assert.match(calls[0].text, /completed_at IS NULL/);
assert.match(calls[0].text, /revoked_at IS NULL/);
});
test('markBirdTransferCodeCompleted consumes a code for the receiving workspace', async () => {
const { calls } = mockDb({ rowCount: 1, rows: [] });