Skip to content

Commit

Permalink
Merge pull request #7473 from opengovsg/release_v6.132.0
Browse files Browse the repository at this point in the history
build: release v6.132.0
  • Loading branch information
KenLSM authored Jul 4, 2024
2 parents 2cfcda8 + 82da6ac commit bfa5421
Show file tree
Hide file tree
Showing 22 changed files with 344 additions and 91 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
test:
timeout-minutes: 40
runs-on: ubuntu-latest
env:
AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE: 1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,23 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v6.132.0](https://github.com/opengovsg/FormSG/compare/v6.131.0...v6.132.0)

- chore: remove nric mask toggle if nricmask is false [`#7472`](https://github.com/opengovsg/FormSG/pull/7472)
- fix(deps): bump type-fest from 4.20.1 to 4.21.0 in /shared [`#7468`](https://github.com/opengovsg/FormSG/pull/7468)
- fix(deps): bump @babel/runtime from 7.24.1 to 7.24.7 [`#7466`](https://github.com/opengovsg/FormSG/pull/7466)
- chore(deps-dev): bump prettier from 3.2.5 to 3.3.2 [`#7465`](https://github.com/opengovsg/FormSG/pull/7465)
- chore(deps-dev): bump @types/compression from 1.7.2 to 1.7.5 [`#7464`](https://github.com/opengovsg/FormSG/pull/7464)
- feat(i18n): replace hardcoded text in PublicFormSubmitButton [`#7427`](https://github.com/opengovsg/FormSG/pull/7427)
- fix(deps): bump validator and @types/validator [`#7440`](https://github.com/opengovsg/FormSG/pull/7440)
- fix(encrypt-submission): add missing ndi response fields [`#7425`](https://github.com/opengovsg/FormSG/pull/7425)
- build: merge release v6.131.0 to develop [`#7460`](https://github.com/opengovsg/FormSG/pull/7460)
- build: release v6.131.0 [`#7459`](https://github.com/opengovsg/FormSG/pull/7459)

#### [v6.131.0](https://github.com/opengovsg/FormSG/compare/v6.130.1...v6.131.0)

> 1 July 2024

- fix: update husky commit hook status msg [`#7458`](https://github.com/opengovsg/FormSG/pull/7458)
- build: merge release v6.130.1 to develop [`#7455`](https://github.com/opengovsg/FormSG/pull/7455)
- fix(attachment): convoy separation (#7449) [`#7451`](https://github.com/opengovsg/FormSG/pull/7451)
Expand All @@ -16,6 +31,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- chore: add minor changes to sample form submission api [`#7442`](https://github.com/opengovsg/FormSG/pull/7442)
- fix: silence aws-sdk deprecation warnings [`#7445`](https://github.com/opengovsg/FormSG/pull/7445)
- fix: move link to constants file, move out helper text as own component [`b549278`](https://github.com/opengovsg/FormSG/commit/b549278906a6960879066760c574340119cc7832)
- chore: bump version to v6.131.0 [`ef1599b`](https://github.com/opengovsg/FormSG/commit/ef1599b9e4dc236994dbff7b7c1c04b15770d6a1)
- fix: remove memo from low cost component [`10b037d`](https://github.com/opengovsg/FormSG/commit/10b037d707f096591ebbd1bdaba90ecc9da7175f)

#### [v6.130.1](https://github.com/opengovsg/FormSG/compare/v6.130.0...v6.130.1)
Expand Down
26 changes: 13 additions & 13 deletions __tests__/e2e/email-submission.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
createMyInfoField,
createOptionalVersion,
deleteDocById,
getSettings,
getEmailSettings,
makeModel,
makeMongooseFixtures,
} from './utils'
Expand Down Expand Up @@ -58,7 +58,7 @@ test.describe('Email form submission', () => {
// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
const formSettings = getSettings()
const formSettings = getEmailSettings()

// Test
await runEmailSubmissionTest(page, Form, {
Expand All @@ -76,7 +76,7 @@ test.describe('Email form submission', () => {
createBlankVersion(createOptionalVersion(ff)),
)
const formLogics = NO_LOGIC
const formSettings = getSettings()
const formSettings = getEmailSettings()

// Test
await runEmailSubmissionTest(page, Form, {
Expand All @@ -98,10 +98,10 @@ test.describe('Email form submission', () => {
title: `Attachment ${i}`,
path: `__tests__/e2e/files/att-folder-${i}/test-att.txt`,
val: `${i === 2 ? '' : `${2 - i}-`}test-att.txt`,
} as E2eFieldMetadata),
}) as E2eFieldMetadata,
)
const formLogics = NO_LOGIC
const formSettings = getSettings()
const formSettings = getEmailSettings()

// Test
await runEmailSubmissionTest(page, Form, {
Expand Down Expand Up @@ -135,7 +135,7 @@ test.describe('Email form submission', () => {
} as E2eFieldMetadata,
]
const formLogics = NO_LOGIC
const formSettings = getSettings()
const formSettings = getEmailSettings()

// Test
await runEmailSubmissionTest(page, Form, {
Expand All @@ -151,7 +151,7 @@ test.describe('Email form submission', () => {
// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
const formSettings = getSettings({
const formSettings = getEmailSettings({
authType: FormAuthType.SP,
})

Expand All @@ -169,7 +169,7 @@ test.describe('Email form submission', () => {
// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
const formSettings = getSettings({
const formSettings = getEmailSettings({
authType: FormAuthType.CP,
})

Expand All @@ -187,7 +187,7 @@ test.describe('Email form submission', () => {
// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
const formSettings = getSettings({
const formSettings = getEmailSettings({
authType: FormAuthType.SGID,
})

Expand Down Expand Up @@ -216,7 +216,7 @@ test.describe('Email form submission', () => {
createMyInfoField(MyInfoAttribute.WorkpassStatus, 'Live', false),
]
const formLogics = NO_LOGIC
const formSettings = getSettings({
const formSettings = getEmailSettings({
authType: FormAuthType.MyInfo,
})

Expand All @@ -233,7 +233,7 @@ test.describe('Email form submission', () => {
}) => {
// Define
const { formFields, formLogics } = TEST_ALL_FIELDS_SHOWN_BY_LOGIC
const formSettings = getSettings()
const formSettings = getEmailSettings()

// Test
await runEmailSubmissionTest(page, Form, {
Expand All @@ -248,7 +248,7 @@ test.describe('Email form submission', () => {
}) => {
// Define
const { formFields, formLogics } = TEST_FIELD_HIDDEN_BY_LOGIC
const formSettings = getSettings()
const formSettings = getEmailSettings()

// Test
await runEmailSubmissionTest(page, Form, {
Expand All @@ -264,7 +264,7 @@ test.describe('Email form submission', () => {
// Define
const { formFields, formLogics, preventSubmitMessage } =
TEST_SUBMISSION_DISABLED_BY_CHAINED_LOGIC
const formSettings = getSettings()
const formSettings = getEmailSettings()

// Test
const { form } = await createForm(page, Form, FormResponseMode.Email, {
Expand Down
14 changes: 7 additions & 7 deletions __tests__/e2e/encrypt-submission.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
createMyInfoField,
createOptionalVersion,
deleteDocById,
getSettings,
getEncryptSettings,
makeModel,
makeMongooseFixtures,
} from './utils'
Expand Down Expand Up @@ -61,7 +61,7 @@ test.describe('Storage form submission', () => {
// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
const formSettings = getSettings()
const formSettings = getEncryptSettings()

// Test
await runEncryptSubmissionTest(page, Form, {
Expand All @@ -79,7 +79,7 @@ test.describe('Storage form submission', () => {
createBlankVersion(createOptionalVersion(ff)),
)
const formLogics = NO_LOGIC
const formSettings = getSettings()
const formSettings = getEncryptSettings()

// Test
await runEncryptSubmissionTest(page, Form, {
Expand All @@ -94,7 +94,7 @@ test.describe('Storage form submission', () => {
}) => {
// Define
const { formFields, formLogics } = TEST_ALL_FIELDS_SHOWN_BY_LOGIC
const formSettings = getSettings()
const formSettings = getEncryptSettings()

// Test
await runEncryptSubmissionTest(page, Form, {
Expand All @@ -109,7 +109,7 @@ test.describe('Storage form submission', () => {
}) => {
// Define
const { formFields, formLogics } = TEST_FIELD_HIDDEN_BY_LOGIC
const formSettings = getSettings()
const formSettings = getEncryptSettings()

// Test
await runEncryptSubmissionTest(page, Form, {
Expand All @@ -125,7 +125,7 @@ test.describe('Storage form submission', () => {
// Define
const { formFields, formLogics, preventSubmitMessage } =
TEST_SUBMISSION_DISABLED_BY_CHAINED_LOGIC
const formSettings = getSettings()
const formSettings = getEncryptSettings()

// Test
const { form } = await createForm(page, Form, FormResponseMode.Encrypt, {
Expand Down Expand Up @@ -158,7 +158,7 @@ test.describe('Storage form submission', () => {
createMyInfoField(MyInfoAttribute.WorkpassStatus, 'Live', false),
]
const formLogics = NO_LOGIC
const formSettings = getSettings({
const formSettings = getEncryptSettings({
authType: FormAuthType.MyInfo,
})

Expand Down
7 changes: 3 additions & 4 deletions __tests__/e2e/helpers/createForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,7 @@ const addSettings = async (
await expect(page).toHaveURL(ADMIN_FORM_PAGE_SETTINGS(formId))

await addGeneralSettings(page, formSettings)
// Encrypt mode forms don't have an email
if (formResponseMode.responseMode === FormResponseMode.Encrypt) {
await addAdminEmails(page, formSettings)
}
await addAdminEmails(page, formSettings)
await addAuthSettings(page, formSettings)
await addCollaborators(page, formSettings)

Expand Down Expand Up @@ -385,6 +382,8 @@ const addAdminEmails = async (

await emailInput.fill(formSettings.emails.join(', '))

await page.keyboard.press('Tab')

await expectToast(page, /emails successfully updated/i)
}
}
Expand Down
51 changes: 40 additions & 11 deletions __tests__/e2e/helpers/verifySubmission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const verifySubmission = async (
// Verify the submission content
switch (formResponseMode.responseMode) {
case FormResponseMode.Email:
await verifyEmailSubmission(data)
await verifyEmailSubmission(page, data)
break
case FormResponseMode.Encrypt:
await verifyEncryptSubmission(page, {
Expand Down Expand Up @@ -87,14 +87,17 @@ export const verifySubmission = async (
* @param {E2eFieldMetadata[]} formFields the field metadata used to create and fill the form
* @param {E2eSettingsOptions} formSettings the form settings used to create the form
*/
export const verifyEmailSubmission = async ({
form,
responseId,
formFields,
formSettings,
}: VerifySubmissionBaseInputs): Promise<void> => {
export const verifyEmailSubmission = async (
page: Page,
{ form, responseId, formFields, formSettings }: VerifySubmissionBaseInputs,
): Promise<void> => {
// Get the submission from the email, via the subject.
const submission = await getSubmission(form.title, responseId)
const submission = await getSubmission(
page,
form.title,
responseId,
FormResponseMode.Email,
)

// Verify email metadata
expect(submission.from).toContain(MAIL_FROM)
Expand All @@ -120,6 +123,7 @@ export const verifyEmailSubmission = async ({
getResponseTitle(field, { mode: FormResponseMode.Email }),
...responseArray,
])
if (!submission.attachments) continue
expectAttachment(field, submission.attachments)
}

Expand Down Expand Up @@ -166,7 +170,21 @@ export const verifyEncryptSubmission = async (
if (formSettings.emails) {
// (Optional) Step 1: Verify that there's an email notification in maildev
// Get the submission from the email, via the subject.
const submission = await getSubmission(form.title, responseId)
await page.evaluate(
([responseId, form_title]) => {
console.log(
`Checking maildev for submission_id=${responseId} for form=${form_title}`,
)
},
[responseId, form.title],
)

const submission = await getSubmission(
page,
form.title,
responseId,
FormResponseMode.Encrypt,
)

// Verify email metadata
expect(submission.from).toContain(MAIL_FROM)
Expand All @@ -186,13 +204,15 @@ export const verifyEncryptSubmission = async (
// Verify form responses in email
for (const field of formFields) {
const responseArray = getResponseArray(field, {
mode: FormResponseMode.Email,
mode: FormResponseMode.Encrypt,
csv: false,
})
if (!responseArray) continue
expectSubmissionContains([
getResponseTitle(field, { mode: FormResponseMode.Email }),
getResponseTitle(field, { mode: FormResponseMode.Encrypt, csv: false }),
...responseArray,
])
if (!submission.attachments) continue
expectAttachment(field, submission.attachments)
}

Expand All @@ -218,6 +238,15 @@ export const verifyEncryptSubmission = async (

// Step 2: Download the response using secret key

// await page.evaluate(
// ([responseId, form_title]) => {
// console.log(
// `Downloading response using secret key for submission_id=${responseId} for form=${form_title}`,
// )
// },
// [responseId, form.title],
// )

// Go to the responses summary page and enter the secret key
await page.goto(ADMIN_FORM_PAGE_RESPONSES(form._id))
await page.getByLabel(/Enter or upload Secret Key/).fill(secretKey)
Expand Down
22 changes: 19 additions & 3 deletions __tests__/e2e/utils/mail.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Page } from '@playwright/test'
import axios from 'axios'
import { FormResponseMode } from 'shared/types'

// Maildev default port is 1080.
const MAIL_URL = 'http://0.0.0.0:1080'
Expand Down Expand Up @@ -29,7 +31,7 @@ type EmailSubmission = {
from: string[]
subject: string
html: string
attachments: Record<string, string>
attachments?: Record<string, string>
}

// Sleep util, needed before getting mail to give mail server some time to receive email.
Expand Down Expand Up @@ -82,23 +84,37 @@ export const extractOtp = async (recipient: string): Promise<string> => {
* @returns {object} subject, sender, recipient and html content of email
*/
export const getSubmission = async (
page: Page,
formName: string,
responseId: string,
responseMode: FormResponseMode,
): Promise<EmailSubmission> => {
const subject = `formsg-auto: ${formName} (#${responseId})`

const emails = await getEmailsBy((e) => e.subject === subject)

const lastEmail = emails.pop()
if (!lastEmail) throw Error(`mailbox does not contain subject "${subject}"`)
if (!lastEmail) {
const err_msg = `mailbox does not contain subject "${subject}"`
await page.evaluate(
([err_msg]) => {
console.log(err_msg)
},
[err_msg],
)
throw Error(err_msg)
}

const submission = {
responseId,
to: lastEmail.to.map((p) => p.address),
from: lastEmail.from.map((p) => p.address),
subject: lastEmail.subject,
html: lastEmail.html,
attachments: await getSubmissionAttachments(lastEmail),
attachments:
responseMode === FormResponseMode.Email
? await getSubmissionAttachments(lastEmail)
: undefined,
}

await MAIL_CLIENT.deleteById(lastEmail.id)
Expand Down
Loading

0 comments on commit bfa5421

Please sign in to comment.