Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: e2e form testing #8143

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
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
32 changes: 27 additions & 5 deletions __tests__/e2e/email-submission.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,17 @@ test.describe('Email form submission', () => {
db = (await makeMongooseFixtures()).connection
Form = makeModel(db, 'form.server.model', 'Form')
})
test.beforeEach(async () => {
await createFeedbackForm()
})

test.afterAll(async () => {
// Clean up db
await db.dropCollection(Form.collection.name)
await db.close()
})

test('Create and submit email mode form with all fields', async ({
page,
}) => {
test.setTimeout(60 * 1000)
await createFeedbackForm()

// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
Expand All @@ -78,6 +76,8 @@ test.describe('Email form submission', () => {
page,
}) => {
test.setTimeout(60 * 1000)
await createFeedbackForm()

// Define
const formFields = ALL_FIELDS.map((ff) =>
createBlankVersion(createOptionalVersion(ff)),
Expand All @@ -96,6 +96,9 @@ test.describe('Email form submission', () => {
test('Create and submit email mode form with identical attachment names', async ({
page,
}) => {
test.setTimeout(60 * 1000)
await createFeedbackForm()

// Define
const baseField = SAMPLE_FIELD[BasicField.Attachment]
const formFields = new Array(3).fill('').map(
Expand All @@ -121,6 +124,8 @@ test.describe('Email form submission', () => {
test('Create and submit email mode form with optional and required attachments', async ({
page,
}) => {
await createFeedbackForm()

// Define
const baseField = SAMPLE_FIELD[BasicField.Attachment]
const formFields = [
Expand Down Expand Up @@ -156,6 +161,8 @@ test.describe('Email form submission', () => {
page,
}) => {
test.setTimeout(60 * 1000)
await createFeedbackForm()

// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
Expand All @@ -175,6 +182,8 @@ test.describe('Email form submission', () => {
page,
}) => {
test.setTimeout(60 * 1000)
await createFeedbackForm()

// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
Expand All @@ -194,6 +203,8 @@ test.describe('Email form submission', () => {
page,
}) => {
test.setTimeout(60 * 1000)
await createFeedbackForm()

// Define
const formFields = ALL_FIELDS
const formLogics = NO_LOGIC
Expand All @@ -212,6 +223,9 @@ test.describe('Email form submission', () => {
test('Create and submit email mode form with MyInfo fields', async ({
page,
}) => {
test.setTimeout(60 * 1000)
await createFeedbackForm()

// Define
const formFields = [
// Short answer
Expand Down Expand Up @@ -242,6 +256,8 @@ test.describe('Email form submission', () => {
page,
}) => {
test.setTimeout(60 * 1000)
await createFeedbackForm()

// Define
const { formFields, formLogics } = TEST_ALL_FIELDS_SHOWN_BY_LOGIC
const formSettings = getEmailSettings()
Expand All @@ -257,6 +273,9 @@ test.describe('Email form submission', () => {
test('Create and submit email mode form with a field hidden by logic', async ({
page,
}) => {
test.setTimeout(60 * 1000)
await createFeedbackForm()

// Define
const { formFields, formLogics } = TEST_FIELD_HIDDEN_BY_LOGIC
const formSettings = getEmailSettings()
Expand All @@ -272,6 +291,9 @@ test.describe('Email form submission', () => {
test('Create email mode form with submission disabled by chained logic', async ({
page,
}) => {
test.setTimeout(60 * 1000)
await createFeedbackForm()

// Define
const { formFields, formLogics, preventSubmitMessage } =
TEST_SUBMISSION_DISABLED_BY_CHAINED_LOGIC
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default defineConfig({
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [['list'], ['html']],
reporter: [['line'], ['html']],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
Expand Down
Loading