feat(api): complete M5 swap and dispatch backend slice
This commit is contained in:
@@ -39,6 +39,16 @@ function createMobileHandlers() {
|
||||
orderId: payload.orderId,
|
||||
status: 'CANCELLED',
|
||||
}),
|
||||
cancelShiftSwapRequest: async (_actor, payload) => ({
|
||||
swapRequestId: payload.swapRequestId,
|
||||
status: 'CANCELLED',
|
||||
}),
|
||||
createDispatchTeamMembership: async (_actor, payload) => ({
|
||||
membershipId: 'dispatch-team-1',
|
||||
staffId: payload.staffId,
|
||||
teamType: payload.teamType,
|
||||
status: 'ACTIVE',
|
||||
}),
|
||||
createHub: async (_actor, payload) => ({
|
||||
hubId: 'hub-1',
|
||||
name: payload.name,
|
||||
@@ -60,9 +70,18 @@ function createMobileHandlers() {
|
||||
platform: payload.platform,
|
||||
notificationsEnabled: payload.notificationsEnabled ?? true,
|
||||
}),
|
||||
removeDispatchTeamMembership: async (_actor, payload) => ({
|
||||
membershipId: payload.membershipId,
|
||||
status: 'INACTIVE',
|
||||
}),
|
||||
unregisterClientPushToken: async () => ({
|
||||
removedCount: 1,
|
||||
}),
|
||||
resolveShiftSwapRequest: async (_actor, payload) => ({
|
||||
swapRequestId: payload.swapRequestId,
|
||||
applicationId: payload.applicationId,
|
||||
status: 'RESOLVED',
|
||||
}),
|
||||
applyForShift: async (_actor, payload) => ({
|
||||
shiftId: payload.shiftId,
|
||||
status: 'APPLIED',
|
||||
@@ -390,3 +409,64 @@ test('POST /commands/staff/shifts/:shiftId/submit-for-approval injects shift id
|
||||
assert.equal(res.body.timesheetId, 'timesheet-1');
|
||||
assert.equal(res.body.submitted, true);
|
||||
});
|
||||
|
||||
test('POST /commands/client/coverage/swap-requests/:swapRequestId/resolve injects swap request id from params', async () => {
|
||||
const app = createApp({ mobileCommandHandlers: createMobileHandlers() });
|
||||
const res = await request(app)
|
||||
.post('/commands/client/coverage/swap-requests/11111111-1111-4111-8111-111111111111/resolve')
|
||||
.set('Authorization', 'Bearer test-token')
|
||||
.set('Idempotency-Key', 'swap-resolve-1')
|
||||
.send({
|
||||
applicationId: '22222222-2222-4222-8222-222222222222',
|
||||
});
|
||||
|
||||
assert.equal(res.status, 200);
|
||||
assert.equal(res.body.swapRequestId, '11111111-1111-4111-8111-111111111111');
|
||||
assert.equal(res.body.applicationId, '22222222-2222-4222-8222-222222222222');
|
||||
assert.equal(res.body.status, 'RESOLVED');
|
||||
});
|
||||
|
||||
test('POST /commands/client/coverage/swap-requests/:swapRequestId/cancel injects swap request id from params', async () => {
|
||||
const app = createApp({ mobileCommandHandlers: createMobileHandlers() });
|
||||
const res = await request(app)
|
||||
.post('/commands/client/coverage/swap-requests/33333333-3333-4333-8333-333333333333/cancel')
|
||||
.set('Authorization', 'Bearer test-token')
|
||||
.set('Idempotency-Key', 'swap-cancel-1')
|
||||
.send({
|
||||
reason: 'No longer needed',
|
||||
});
|
||||
|
||||
assert.equal(res.status, 200);
|
||||
assert.equal(res.body.swapRequestId, '33333333-3333-4333-8333-333333333333');
|
||||
assert.equal(res.body.status, 'CANCELLED');
|
||||
});
|
||||
|
||||
test('POST /commands/client/coverage/dispatch-teams/memberships returns injected dispatch team membership response', async () => {
|
||||
const app = createApp({ mobileCommandHandlers: createMobileHandlers() });
|
||||
const res = await request(app)
|
||||
.post('/commands/client/coverage/dispatch-teams/memberships')
|
||||
.set('Authorization', 'Bearer test-token')
|
||||
.set('Idempotency-Key', 'dispatch-team-create-1')
|
||||
.send({
|
||||
staffId: '44444444-4444-4444-8444-444444444444',
|
||||
hubId: '55555555-5555-4555-8555-555555555555',
|
||||
teamType: 'CERTIFIED_LOCATION',
|
||||
});
|
||||
|
||||
assert.equal(res.status, 200);
|
||||
assert.equal(res.body.membershipId, 'dispatch-team-1');
|
||||
assert.equal(res.body.teamType, 'CERTIFIED_LOCATION');
|
||||
assert.equal(res.body.status, 'ACTIVE');
|
||||
});
|
||||
|
||||
test('DELETE /commands/client/coverage/dispatch-teams/memberships/:membershipId injects membership id from params', async () => {
|
||||
const app = createApp({ mobileCommandHandlers: createMobileHandlers() });
|
||||
const res = await request(app)
|
||||
.delete('/commands/client/coverage/dispatch-teams/memberships/66666666-6666-4666-8666-666666666666?reason=cleanup')
|
||||
.set('Authorization', 'Bearer test-token')
|
||||
.set('Idempotency-Key', 'dispatch-team-delete-1');
|
||||
|
||||
assert.equal(res.status, 200);
|
||||
assert.equal(res.body.membershipId, '66666666-6666-4666-8666-666666666666');
|
||||
assert.equal(res.body.status, 'INACTIVE');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user