-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: saving user account info (#4121)
- Loading branch information
1 parent
e7a5f54
commit fa2f6c4
Showing
13 changed files
with
458 additions
and
297 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,14 @@ export const devSeeding = async ( | |
password: 'abcdef', | ||
}), | ||
}); | ||
await prismaClient.userAccounts.create({ | ||
data: await userFactory({ | ||
email: '[email protected]', | ||
confirmedAt: new Date(), | ||
jurisdictionIds: [jurisdiction.id], | ||
password: 'abcdef', | ||
}), | ||
}); | ||
await prismaClient.userAccounts.create({ | ||
data: await userFactory({ | ||
roles: { isJurisdictionalAdmin: true }, | ||
|
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 |
---|---|---|
|
@@ -95,6 +95,14 @@ export const stagingSeed = async ( | |
singleUseCode: '12345', | ||
}), | ||
}); | ||
await prismaClient.userAccounts.create({ | ||
data: await userFactory({ | ||
email: '[email protected]', | ||
confirmedAt: new Date(), | ||
jurisdictionIds: [jurisdiction.id], | ||
password: 'abcdef', | ||
}), | ||
}); | ||
// add jurisdiction specific translations and default ones | ||
await prismaClient.translations.create({ | ||
data: translationFactory(jurisdiction.id, jurisdiction.name), | ||
|
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { publicUser, updatedPublicUser } from "../../mockData/userData" | ||
|
||
describe("User accounts", () => { | ||
it("should allow users to update their account information", () => { | ||
cy.visit("/sign-in") | ||
cy.signIn(publicUser.email, publicUser.password) | ||
|
||
// Assert that a user's data shows up on their settings page | ||
cy.getByID("account-dashboard-settings").click() | ||
cy.getByTestId("loading-overlay").should("not.exist") | ||
cy.getByTestId("account-first-name").should("have.value", publicUser.firstName) | ||
cy.getByTestId("account-middle-name").should("have.value", publicUser.middleName) | ||
cy.getByTestId("account-last-name").should("have.value", publicUser.lastName) | ||
cy.getByTestId("dob-field-month").should("have.value", publicUser.birthMonth) | ||
cy.getByTestId("dob-field-day").should("have.value", publicUser.birthDay) | ||
cy.getByTestId("dob-field-year").should("have.value", publicUser.birthYear) | ||
cy.getByTestId("account-email").should("have.value", publicUser.email) | ||
|
||
// Change the name fields | ||
cy.getByTestId("account-first-name").clear().type(updatedPublicUser.firstName) | ||
cy.getByTestId("account-middle-name").clear().type(updatedPublicUser.middleName) | ||
cy.getByTestId("account-last-name").clear().type(updatedPublicUser.lastName) | ||
cy.getByID("account-submit-name").click() | ||
cy.getByTestId("alert-box").contains("Name update successful") | ||
cy.get("[aria-label='close alert']").click() | ||
cy.getByTestId("alert-box").should("not.exist") | ||
|
||
// Change the birthday field | ||
cy.getByTestId("dob-field-month").clear().type(updatedPublicUser.birthMonth) | ||
cy.getByTestId("dob-field-day").clear().type(updatedPublicUser.birthDay) | ||
cy.getByTestId("dob-field-year").clear().type(updatedPublicUser.birthYear) | ||
cy.getByID("account-submit-dob").click() | ||
cy.getByTestId("alert-box").contains("Birthdate update successful") | ||
cy.get("[aria-label='close alert']").click() | ||
cy.getByTestId("alert-box").should("not.exist") | ||
|
||
// Change the password | ||
cy.getByTestId("account-current-password").type(publicUser.password) | ||
cy.getByTestId("account-password").type(updatedPublicUser.password) | ||
cy.getByTestId("account-password-confirmation").type(updatedPublicUser.passwordConfirmation) | ||
cy.getByID("account-submit-password").click() | ||
cy.getByTestId("alert-box").contains("Password update successful") | ||
cy.get("[aria-label='close alert']").click() | ||
cy.getByTestId("alert-box").should("not.exist") | ||
|
||
cy.visit("/account/edit") | ||
|
||
// Confirm that the data actually updated | ||
cy.getByTestId("loading-overlay").should("not.exist") | ||
cy.getByTestId("account-first-name").should("have.value", updatedPublicUser.firstName) | ||
cy.getByTestId("account-middle-name").should("have.value", updatedPublicUser.middleName) | ||
cy.getByTestId("account-last-name").should("have.value", updatedPublicUser.lastName) | ||
cy.getByTestId("dob-field-month").should("have.value", updatedPublicUser.birthMonth) | ||
cy.getByTestId("dob-field-day").should("have.value", updatedPublicUser.birthDay) | ||
cy.getByTestId("dob-field-year").should("have.value", updatedPublicUser.birthYear) | ||
|
||
cy.signOut() | ||
|
||
// Confirm that the new password works | ||
cy.visit("/sign-in") | ||
cy.signIn(updatedPublicUser.email, updatedPublicUser.password) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export const publicUser = { | ||
email: "[email protected]", | ||
password: "abcdef", | ||
firstName: "First", | ||
middleName: "Middle", | ||
lastName: "Last", | ||
birthDay: "01", | ||
birthMonth: "01", | ||
birthYear: "1970", | ||
} | ||
|
||
export const updatedPublicUser = { | ||
email: "[email protected]", | ||
password: "Abcdefghijk1!", | ||
passwordConfirmation: "Abcdefghijk1!", | ||
firstName: "First Updated", | ||
middleName: "Middle Updated", | ||
lastName: "Last Updated", | ||
birthDay: "20", | ||
birthMonth: "12", | ||
birthYear: "2000", | ||
} |
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 |
---|---|---|
|
@@ -9,9 +9,9 @@ import { | |
raceCheckboxesOrder, | ||
} from "./../mockData/applicationData" | ||
|
||
Cypress.Commands.add("signIn", () => { | ||
cy.get(`[data-testid="sign-in-email-field"]`).type("[email protected]") | ||
cy.get(`[data-testid="sign-in-password-field"]`).type("abcdef") | ||
Cypress.Commands.add("signIn", (email, password) => { | ||
cy.get(`[data-testid="sign-in-email-field"]`).type(email ?? "[email protected]") | ||
cy.get(`[data-testid="sign-in-password-field"]`).type(password ?? "abcdef") | ||
cy.getByID("sign-in-button").click() | ||
}) | ||
|
||
|
@@ -578,7 +578,7 @@ Cypress.Commands.add("step18Summary", (application, verify) => { | |
fields.push({ id: val, fieldValue: val }) | ||
} | ||
|
||
if (application.alternateContact.type !== "dontHave") { | ||
if (application.alternateContact.type !== "noContact") { | ||
fields.push({ | ||
id: "app-summary-alternate-name", | ||
fieldValue: `${application.alternateContact.firstName} ${application.alternateContact.lastName}`, | ||
|
@@ -682,7 +682,7 @@ Cypress.Commands.add("submitApplication", (listingName, application, signedIn, v | |
cy.step1PrimaryApplicantName(application) | ||
cy.step2PrimaryApplicantAddresses(application) | ||
cy.step3AlternateContactType(application) | ||
if (application.alternateContact.type !== "dontHave") { | ||
if (application.alternateContact.type !== "noContact") { | ||
cy.step4AlternateContactName(application) | ||
cy.step5AlternateContactInfo(application) | ||
} | ||
|
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
Oops, something went wrong.