-
Notifications
You must be signed in to change notification settings - Fork 87
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
test(e2e): add storage mode e2e tests #5926
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e7b5f89
test(e2e): add instrumentation for encrypt mode tests, add one encryp…
justynoh f30d575
test(e2e): fix bug in computation of expected response values
justynoh 9ceea22
test(e2e): general code refactor, add more tests to encrypt submissio…
justynoh 8447dab
test(e2e): remove attachments from storage mode tests
justynoh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,6 +1,21 @@ | ||
export const ROOT_PAGE = `${process.env.APP_URL}` | ||
|
||
export const LOGIN_PAGE = `${ROOT_PAGE}/login` | ||
|
||
export const DASHBOARD_PAGE = `${ROOT_PAGE}/dashboard` | ||
|
||
export const ADMIN_FORM_PAGE_PREFIX = `${ROOT_PAGE}/admin/form` | ||
export const PUBLIC_FORM_PAGE_PREFIX = ROOT_PAGE | ||
export const ADMIN_FORM_PAGE_CREATE = (formId: string) => | ||
`${ADMIN_FORM_PAGE_PREFIX}/${formId}` | ||
export const ADMIN_FORM_PAGE_SETTINGS = (formId: string) => | ||
`${ADMIN_FORM_PAGE_CREATE(formId)}/settings` | ||
export const ADMIN_FORM_PAGE_RESPONSES = (formId: string) => | ||
`${ADMIN_FORM_PAGE_CREATE(formId)}/results` | ||
export const ADMIN_FORM_PAGE_RESPONSES_INDIVIDUAL = ( | ||
formId: string, | ||
responseId: string, | ||
) => `${ADMIN_FORM_PAGE_CREATE(formId)}/results/${responseId}` | ||
|
||
const PUBLIC_FORM_PAGE_PREFIX = ROOT_PAGE | ||
export const PUBLIC_FORM_PAGE = (formId: string) => | ||
`${PUBLIC_FORM_PAGE_PREFIX}/${formId}` |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { FormResponseMode } from 'shared/types' | ||
|
||
interface FormResponseViewBase { | ||
mode: FormResponseMode | ||
} | ||
|
||
interface FormResponseViewEmail extends FormResponseViewBase { | ||
mode: FormResponseMode.Email | ||
} | ||
|
||
interface FormResponseViewEncrypt extends FormResponseViewBase { | ||
mode: FormResponseMode.Encrypt | ||
csv: boolean | ||
} | ||
|
||
export type FormResponseView = FormResponseViewEmail | FormResponseViewEncrypt |
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 |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import { BasicField, LogicConditionState, LogicType } from 'shared/types' | ||
|
||
import { ALL_FIELDS, E2eFieldMetadata } from './field' | ||
import { E2eLogic } from './logic' | ||
|
||
type E2eTestFormDefinition = { | ||
formFields: E2eFieldMetadata[] | ||
formLogics: E2eLogic[] | ||
} | ||
|
||
/** | ||
* Test where all fields are shown based on a single field logic | ||
*/ | ||
const TEST_ALL_FIELDS_SHOWN_BY_LOGIC_FORMFIELDS: E2eFieldMetadata[] = [ | ||
{ | ||
title: 'Do you want to hide the fields?', | ||
fieldType: BasicField.YesNo, | ||
val: 'No', | ||
}, | ||
// TODO: Attachment fields don't work on storage mode unless we spin up localstack. | ||
...ALL_FIELDS.filter((field) => field.fieldType !== BasicField.Attachment), | ||
] | ||
export const TEST_ALL_FIELDS_SHOWN_BY_LOGIC: E2eTestFormDefinition = { | ||
formFields: TEST_ALL_FIELDS_SHOWN_BY_LOGIC_FORMFIELDS, | ||
formLogics: [ | ||
// Single logic block: if "yes", show the fields. | ||
{ | ||
conditions: [ | ||
{ | ||
field: 0, | ||
state: LogicConditionState.Equal, | ||
value: 'No', | ||
}, | ||
], | ||
logicType: LogicType.ShowFields, | ||
show: Array.from( | ||
TEST_ALL_FIELDS_SHOWN_BY_LOGIC_FORMFIELDS, | ||
(_, i) => i, | ||
).slice(1), | ||
}, | ||
], | ||
} | ||
|
||
/** | ||
* Test where a field is hidden based on a single field logic | ||
*/ | ||
const TEST_FIELD_HIDDEN_BY_LOGIC_FORMFIELDS: E2eFieldMetadata[] = [ | ||
{ | ||
title: 'Do you want to show the fields?', | ||
fieldType: BasicField.YesNo, | ||
val: 'No', | ||
}, | ||
{ | ||
title: 'This field should be hidden', | ||
fieldType: BasicField.ShortText, | ||
ValidationOptions: { | ||
selectedValidation: null, | ||
customVal: null, | ||
}, | ||
val: '', | ||
hidden: true, | ||
}, | ||
] | ||
export const TEST_FIELD_HIDDEN_BY_LOGIC: E2eTestFormDefinition = { | ||
formFields: TEST_FIELD_HIDDEN_BY_LOGIC_FORMFIELDS, | ||
formLogics: [ | ||
// Single logic block: if "yes", show the fields. | ||
{ | ||
conditions: [ | ||
{ | ||
field: 0, | ||
state: LogicConditionState.Equal, | ||
value: 'Yes', | ||
}, | ||
], | ||
logicType: LogicType.ShowFields, | ||
show: Array.from( | ||
TEST_FIELD_HIDDEN_BY_LOGIC_FORMFIELDS, | ||
(_, i) => i, | ||
).slice(1), | ||
}, | ||
], | ||
} | ||
|
||
/** | ||
* Test where submission is disabled via chained logic | ||
*/ | ||
const TEST_SUBMISSION_DISABLED_BY_CHAINED_LOGIC_MESSAGE = 'You shall not pass!' | ||
const TEST_SUBMISSION_DISABLED_BY_CHAINED_LOGIC_FORMFIELDS: E2eFieldMetadata[] = | ||
[ | ||
{ | ||
title: 'Enter a number at least 10', | ||
fieldType: BasicField.Number, | ||
ValidationOptions: { | ||
selectedValidation: null, | ||
customVal: null, | ||
}, | ||
val: '10', | ||
}, | ||
{ | ||
title: 'Favorite food', | ||
fieldType: BasicField.Dropdown, | ||
fieldOptions: ['Rice', 'Chocolate', 'Ice-Cream'], | ||
val: 'Chocolate', | ||
}, | ||
{ | ||
title: 'Do you want to submit this form?', | ||
fieldType: BasicField.YesNo, | ||
val: 'Yes', | ||
}, | ||
] | ||
export const TEST_SUBMISSION_DISABLED_BY_CHAINED_LOGIC: E2eTestFormDefinition & { | ||
preventSubmitMessage: string | ||
} = { | ||
formFields: TEST_SUBMISSION_DISABLED_BY_CHAINED_LOGIC_FORMFIELDS, | ||
formLogics: [ | ||
{ | ||
conditions: [ | ||
{ | ||
field: 0, | ||
state: LogicConditionState.Gte, | ||
value: '10', | ||
}, | ||
], | ||
logicType: LogicType.ShowFields, | ||
show: [1], | ||
}, | ||
{ | ||
conditions: [ | ||
{ | ||
field: 1, | ||
state: LogicConditionState.Either, | ||
value: ['Rice', 'Chocolate'], | ||
}, | ||
], | ||
logicType: LogicType.ShowFields, | ||
show: [2], | ||
}, | ||
{ | ||
conditions: [ | ||
{ | ||
field: 2, | ||
state: LogicConditionState.Equal, | ||
value: 'Yes', | ||
}, | ||
], | ||
logicType: LogicType.PreventSubmit, | ||
message: TEST_SUBMISSION_DISABLED_BY_CHAINED_LOGIC_MESSAGE, | ||
}, | ||
], | ||
preventSubmitMessage: TEST_SUBMISSION_DISABLED_BY_CHAINED_LOGIC_MESSAGE, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this date value
952970366
special?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok no but on a serious note, I couldn't leave it as the current date because our Storage mode's individual response page also displays the date of submission which would also be the current date. So the
expect()
for finding the response to this question would certainly always succeed, regardless of whether the response to the question was shown.