-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Retire 'test test' workaround (#1726)
- Loading branch information
1 parent
aa8ea83
commit cc4f3e2
Showing
8 changed files
with
53 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,3 +216,32 @@ it("should not have any accessibility violations while in the error state", asyn | |
const results = await axe(container); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
|
||
test("does not allow the name 'Test Test' to be used", async () => { | ||
const handleSubmit = jest.fn(); | ||
const dataField = "applicant"; | ||
|
||
const { user } = setup( | ||
<ContactInput | ||
handleSubmit={handleSubmit} | ||
title="Enter your contact details" | ||
fn={dataField} | ||
/> | ||
); | ||
|
||
await fillInFieldsUsingLabel(user, { | ||
"First name": "Test", | ||
"Last name": "Test", | ||
"Phone number": "0123456789", | ||
"Email address": "[email protected]", | ||
}); | ||
|
||
await user.click(screen.getByTestId("continue-button")); | ||
|
||
expect(handleSubmit).not.toHaveBeenCalled(); | ||
|
||
const errorMessage = await screen.findByText( | ||
"'Test Test' is not a valid name - please submit test applications via the staging environment" | ||
); | ||
expect(errorMessage).toBeVisible(); | ||
}); |
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 |
---|---|---|
|
@@ -23,6 +23,22 @@ export const userDataSchema: SchemaOf<Contact> = object({ | |
"Enter an email address in the correct format, like [email protected]" | ||
) | ||
.required("Enter an email address"), | ||
}).test({ | ||
name: "Test Test is not used for applications", | ||
test: ({ firstName, lastName }, context) => { | ||
const isValid = | ||
[firstName, lastName] | ||
.map((x) => String(x).toLowerCase().trim()) | ||
.join("|") !== "test|test"; | ||
|
||
if (isValid) return true; | ||
|
||
return context.createError({ | ||
path: "firstName", | ||
message: | ||
"'Test Test' is not a valid name - please submit test applications via the staging environment", | ||
}); | ||
}, | ||
}); | ||
|
||
export interface ContactInput extends MoreInformation { | ||
|
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
59 changes: 0 additions & 59 deletions
59
editor.planx.uk/src/@planx/components/shared/utils.test.ts
This file was deleted.
Oops, something went wrong.
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