-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: enable pdf attachment for encrypt mode forms (#7523)
* fix: enable pdf attachment for encrypt mode forms * fix: remove unnecessary import * fix: fix wrong condition * fix: remove unnecessary comment * fix: fix failing test case * fix: do not toggle off if payment enabled form * fix: remove includeFormSummary watch and remove useMemo * docs: add comment for why isVisible is stripped out * tests: add jest test for includeFormSummary toggle on mrf * tests: should not send pdf response if encrypt form with payment activated * fix: remove focused jest tests * fix: update mail service to check for active payment field * fix: update mail service to not render email if active payment field * fix: remove unused var * tests: add tests for autoReplyData * fix: should parse responses using the form def * tests: add test to ensure isVisible is still present * Revert "fix: should parse responses using the form def" This reverts commit 1762b25.
- Loading branch information
Showing
12 changed files
with
338 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { ObjectId } from 'bson' | |
import { merge } from 'lodash' | ||
import mongoose from 'mongoose' | ||
import { ok, okAsync } from 'neverthrow' | ||
import { FormAuthType, MyInfoAttribute } from 'shared/types' | ||
import { BasicField, FormAuthType, MyInfoAttribute } from 'shared/types' | ||
|
||
import { getEncryptSubmissionModel } from 'src/app/models/submission.server.model' | ||
import * as OidcService from 'src/app/modules/spcp/spcp.oidc.service/index' | ||
|
@@ -19,6 +19,8 @@ import MailService from 'src/app/services/mail/mail.service' | |
import { FormFieldSchema, IPopulatedEncryptedForm } from 'src/types' | ||
import { EncryptSubmissionDto, FormCompleteDto } from 'src/types/api' | ||
|
||
import { SubmissionEmailObj } from '../../email-submission/email-submission.util' | ||
import { ProcessedFieldResponse } from '../../submission.types' | ||
import { | ||
generateHashedSubmitterId, | ||
getCookieNameByAuthType, | ||
|
@@ -756,4 +758,78 @@ describe('encrypt-submission.controller', () => { | |
).toEqual(MOCK_MASKED_NRIC) | ||
}) | ||
}) | ||
|
||
describe('emailData', () => { | ||
it('should have the isVisible field set to true for form fields', async () => { | ||
// Arrange | ||
const performEncryptPostSubmissionActionsSpy = jest.spyOn( | ||
EncryptSubmissionService, | ||
'performEncryptPostSubmissionActions', | ||
) | ||
const mockFormId = new ObjectId() | ||
const mockEncryptForm = { | ||
_id: mockFormId, | ||
title: 'some form', | ||
authType: FormAuthType.NIL, | ||
isNricMaskEnabled: false, | ||
form_fields: [ | ||
{ | ||
_id: new ObjectId(), | ||
fieldType: BasicField.ShortText, | ||
title: 'Long answer', | ||
description: '', | ||
required: false, | ||
disabled: false, | ||
}, | ||
] as FormFieldSchema[], | ||
emails: ['[email protected]'], | ||
getUniqueMyInfoAttrs: () => [] as MyInfoAttribute[], | ||
} as IPopulatedEncryptedForm | ||
|
||
const mockResponses = [ | ||
{ | ||
_id: new ObjectId(), | ||
question: 'Long answer', | ||
answer: 'this is an answer', | ||
fieldType: 'textarea', | ||
isVisible: true, | ||
}, | ||
] | ||
|
||
const mockReq = merge( | ||
expressHandler.mockRequest({ | ||
params: { formId: 'some id' }, | ||
body: { | ||
responses: mockResponses, | ||
}, | ||
}), | ||
{ | ||
formsg: { | ||
encryptedPayload: { | ||
encryptedContent: 'encryptedContent', | ||
version: 1, | ||
}, | ||
formDef: {}, | ||
encryptedFormDef: mockEncryptForm, | ||
} as unknown as EncryptSubmissionDto, | ||
} as unknown as FormCompleteDto, | ||
) as unknown as SubmitEncryptModeFormHandlerRequest | ||
const mockRes = expressHandler.mockResponse() | ||
|
||
// Setup the SubmissionEmailObj | ||
const emailData = new SubmissionEmailObj( | ||
mockResponses as any as ProcessedFieldResponse[], | ||
new Set(), | ||
FormAuthType.NIL, | ||
) | ||
|
||
// Act | ||
await submitEncryptModeFormForTest(mockReq, mockRes) | ||
|
||
// Assert | ||
expect(performEncryptPostSubmissionActionsSpy.mock.calls[0][2]).toEqual( | ||
emailData, | ||
) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.