diff --git a/src/app/models/__tests__/multirespondent-submission.server.model.spec.ts b/src/app/models/__tests__/multirespondent-submission.server.model.spec.ts index a236f44004..25a8863e99 100644 --- a/src/app/models/__tests__/multirespondent-submission.server.model.spec.ts +++ b/src/app/models/__tests__/multirespondent-submission.server.model.spec.ts @@ -30,12 +30,13 @@ describe('Multirespondent Submission Model', () => { // Arrange const validFormId = new ObjectId().toHexString() const createdDate = new Date() - // Add valid encrypt submission. + // Add valid multirespondent submission. const validSubmission = await MultirespondentSubmission.create({ form: validFormId, submissionType: SubmissionType.Multirespondent, form_fields: [], form_logics: [], + workflow: [], submissionPublicKey: MOCK_SUBMISSION_PUBLIC_KEY, encryptedSubmissionSecretKey: MOCK_ENCRYPTED_SUBMISSION_SECRET_KEY, encryptedContent: MOCK_ENCRYPTED_CONTENT, @@ -110,13 +111,14 @@ describe('Multirespondent Submission Model', () => { it('should return all metadata and count successfully when params are not provided', async () => { // Arrange - // Add 3 valid encrypt submission. + // Add 3 valid multirespondent submissions. const validSubmissionPromises = times(3, (idx) => MultirespondentSubmission.create({ form: VALID_FORM_ID, submissionType: SubmissionType.Multirespondent, form_fields: [], form_logics: [], + workflow: [], submissionPublicKey: MOCK_SUBMISSION_PUBLIC_KEY, encryptedSubmissionSecretKey: MOCK_ENCRYPTED_SUBMISSION_SECRET_KEY, encryptedContent: MOCK_ENCRYPTED_CONTENT, @@ -153,13 +155,14 @@ describe('Multirespondent Submission Model', () => { it('should return offset metadata with correct count when page number is provided', async () => { // Arrange - // Add 3 valid encrypt submission. + // Add 3 valid multirespondent submissions. const validSubmissionPromises = times(3, (idx) => MultirespondentSubmission.create({ form: VALID_FORM_ID, submissionType: SubmissionType.Multirespondent, form_fields: [], form_logics: [], + workflow: [], submissionPublicKey: MOCK_SUBMISSION_PUBLIC_KEY, encryptedSubmissionSecretKey: MOCK_ENCRYPTED_SUBMISSION_SECRET_KEY, encryptedContent: MOCK_ENCRYPTED_CONTENT, @@ -200,13 +203,14 @@ describe('Multirespondent Submission Model', () => { it('should return offset metadata with correct count when page size is provided', async () => { // Arrange - // Add 3 valid encrypt submission. + // Add 3 valid multirespondent submissions. const validSubmissionPromises = times(3, (idx) => MultirespondentSubmission.create({ form: VALID_FORM_ID, submissionType: SubmissionType.Multirespondent, form_fields: [], form_logics: [], + workflow: [], submissionPublicKey: MOCK_SUBMISSION_PUBLIC_KEY, encryptedSubmissionSecretKey: MOCK_ENCRYPTED_SUBMISSION_SECRET_KEY, encryptedContent: MOCK_ENCRYPTED_CONTENT, @@ -247,13 +251,14 @@ describe('Multirespondent Submission Model', () => { it('should return empty metadata array when given page has no metadata', async () => { // Arrange - // Add 3 valid encrypt submission. + // Add 3 valid multirespondent submissions. const validSubmissionPromises = times(3, (idx) => MultirespondentSubmission.create({ form: VALID_FORM_ID, submissionType: SubmissionType.Multirespondent, form_fields: [], form_logics: [], + workflow: [], submissionPublicKey: MOCK_SUBMISSION_PUBLIC_KEY, encryptedSubmissionSecretKey: MOCK_ENCRYPTED_SUBMISSION_SECRET_KEY, encryptedContent: MOCK_ENCRYPTED_CONTENT, @@ -310,6 +315,7 @@ describe('Multirespondent Submission Model', () => { submissionType: SubmissionType.Multirespondent, form_fields: [], form_logics: [], + workflow: [], submissionPublicKey: MOCK_SUBMISSION_PUBLIC_KEY, encryptedSubmissionSecretKey: MOCK_ENCRYPTED_SUBMISSION_SECRET_KEY, encryptedContent: MOCK_ENCRYPTED_CONTENT, @@ -380,6 +386,7 @@ describe('Multirespondent Submission Model', () => { submissionType: SubmissionType.Multirespondent, form_fields: [], form_logics: [], + workflow: [], submissionPublicKey: MOCK_SUBMISSION_PUBLIC_KEY, encryptedSubmissionSecretKey: MOCK_ENCRYPTED_SUBMISSION_SECRET_KEY, encryptedContent: MOCK_ENCRYPTED_CONTENT, diff --git a/src/app/models/__tests__/submission.server.model.spec.ts b/src/app/models/__tests__/submission.server.model.spec.ts index 50d183351e..3f0a7b9211 100644 --- a/src/app/models/__tests__/submission.server.model.spec.ts +++ b/src/app/models/__tests__/submission.server.model.spec.ts @@ -15,6 +15,7 @@ import { PaymentType, SubmissionType, WebhookResponse, + WorkflowType, } from '../../../../shared/types' import { ISubmissionSchema } from '../../../../src/types' import getPaymentModel from '../payment.server.model' @@ -80,8 +81,16 @@ describe('Submission Model', () => { // multirespondent schema params { submissionType: SubmissionType.Multirespondent, - form_fields: [{ _id: 'aaaaa', fieldType: BasicField.ShortText }], + form_fields: [{ _id: new ObjectId(), fieldType: BasicField.ShortText }], form_logics: [], + workflow: [ + { _id: new ObjectId(), workflow_type: WorkflowType.Static, emails: [] }, + { + _id: new ObjectId(), + workflow_type: WorkflowType.Dynamic, + field: new ObjectId(), + }, + ], submissionPublicKey: 'This is a public key', encryptedSubmissionSecretKey: 'This is an encrypted secret key', encryptedContent: MOCK_ENCRYPTED_CONTENT,