Merge branch 'dev'
# 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:
@@ -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: [] });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user