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

Test: publicform integration tests #1572

Merged
merged 5 commits into from
Apr 12, 2021

Conversation

seaerchin
Copy link
Contributor

@seaerchin seaerchin commented Apr 7, 2021

Problem

current public form end point does not have any integration tests and only has unit tests on the controller. this PR adds integration tests for HTTP errors.

Part of #1513

Solution

Added integration tests for GET /:formId/publicform endpoint.

@seaerchin seaerchin changed the base branch from develop to refactor/public-forms-endpoint April 7, 2021 04:50
@seaerchin seaerchin changed the title Test/publicform integration tests Test: publicform integration tests Apr 7, 2021
@seaerchin seaerchin requested review from karrui and mantariksh and removed request for karrui April 7, 2021 04:53
Copy link
Contributor

@karrui karrui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests are fine, but check if there is a regression on private form response

const expectedResponseBody = JSON.parse(
JSON.stringify({
message:
'If you think this is a mistake, please contact the agency that gave you the form link.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The body response should have 2 more key-values:

formTitle: string
isPageFound: boolean

check if this is a regression

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. this is a regression. will update tests and the controller

tests/unit/backend/helpers/jest-db.ts Outdated Show resolved Hide resolved
@seaerchin seaerchin force-pushed the test/publicform-integration-tests branch from a9445ab to 74507d6 Compare April 7, 2021 10:44
Base automatically changed from refactor/public-forms-endpoint to develop April 8, 2021 07:58
@seaerchin seaerchin force-pushed the test/publicform-integration-tests branch from 74507d6 to c90cf27 Compare April 8, 2021 10:19
@seaerchin seaerchin force-pushed the test/publicform-integration-tests branch from c90cf27 to e4790c5 Compare April 12, 2021 03:32
message: string
}

export interface PrivateFormErrorDto extends ErrorDto {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't make a difference but for the record, it wasn't necessary to change this to an interface, since you can use & to achieve the same thing

// Specialized error response for PrivateFormError.
// This is to maintain backwards compatibility with the middleware implementation
if (error instanceof PrivateFormError) {
return res.status(statusCode).json({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noticed you fixed a regression here. in future it would be good to separate this kind of change into a different PR which can be reviewed with greater urgency. if you name your PR as you did here, other devs may (rightly) assume (as I did) that this PR only contains tests.

@seaerchin seaerchin merged commit 6f6580e into develop Apr 12, 2021
@karrui karrui mentioned this pull request Apr 13, 2021
@karrui karrui deleted the test/publicform-integration-tests branch April 21, 2021 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants