Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/queue/consumers/utils/validateProposalMessage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,49 @@ describe('Validate messages', () => {
})
).not.toThrow();
});

it('should accept a false submitted status', () => {
expect(() =>
validateProposalMessage({
title: 'Test proposal',
abstract: 'Test abstract',
members: [],
proposalPk: 1,
shortCode: '123123',
instruments: [{ id: 1, shortCode: 'TEST', allocatedTime: 1 }],
newStatus: 'REVIEW',
callId: 123,
submitted: false,
proposer: {
id: 1,
firstName: 'Test',
lastName: 'User',
email: 'test.user@email.com',
oidcSub: 'testOidcSub',
},
})
).not.toThrow();
});

it('should throw when submitted status is missing', () => {
expect(() =>
validateProposalMessage({
title: 'Test proposal',
abstract: 'Test abstract',
members: [],
proposalPk: 1,
shortCode: '123123',
instruments: [{ id: 1, shortCode: 'TEST', allocatedTime: 1 }],
newStatus: 'REVIEW',
callId: 123,
proposer: {
id: 1,
firstName: 'Test',
lastName: 'User',
email: 'test.user@email.com',
oidcSub: 'testOidcSub',
},
})
).toThrow('Proposal Submitted status is missing');
});
});
2 changes: 1 addition & 1 deletion src/queue/consumers/utils/validateProposalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function validateProposalMessage(
throw new Error('Proposal CallId is missing');
}

if (!proposalMessage.submitted) {
if (typeof proposalMessage.submitted !== 'boolean') {
throw new Error('Proposal Submitted status is missing');
}

Expand Down
Loading