From 3c8c00ac0bf2f47abb261445cd43970d578ad578 Mon Sep 17 00:00:00 2001 From: Andrew Snaith Date: Wed, 18 May 2022 15:42:25 -0700 Subject: [PATCH 1/4] add new test data --- packages/files-ui/cypress/fixtures/filesTestData.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/files-ui/cypress/fixtures/filesTestData.ts b/packages/files-ui/cypress/fixtures/filesTestData.ts index ec53e20087..1dd141a5e2 100644 --- a/packages/files-ui/cypress/fixtures/filesTestData.ts +++ b/packages/files-ui/cypress/fixtures/filesTestData.ts @@ -7,4 +7,6 @@ export const sharedFolderEditedName = "Edited" export const validEthAddress = "0x2eab9cfa0b5e8e82a73da026254d50567f52d3ce" export const validUsernameA = "filesusera" export const validUsernameB = "filesuserb" -export const validShareKey = "0x02c62b63ef1bd5ead99deb91a74bc7db4bc60d64a6d65a68461f3cf03d8c75da40" \ No newline at end of file +export const validShareKey = "0x02c62b63ef1bd5ead99deb91a74bc7db4bc60d64a6d65a68461f3cf03d8c75da40" +export const complexPassword = "4utom4t3P455w0rd!" +export const simplePassword = "basic" From 947cec0159f85274625f0fffe44dbfd0c6ae7628 Mon Sep 17 00:00:00 2001 From: Andrew Snaith Date: Wed, 18 May 2022 15:43:02 -0700 Subject: [PATCH 2/4] Add tests for change password (wip) --- .../support/page-objects/settingsPage.ts | 5 ++ .../files-ui/cypress/tests/settings-spec.ts | 74 ++++++++++++++++++- .../Modules/Settings/SecurityTab/index.tsx | 7 +- 3 files changed, 81 insertions(+), 5 deletions(-) diff --git a/packages/files-ui/cypress/support/page-objects/settingsPage.ts b/packages/files-ui/cypress/support/page-objects/settingsPage.ts index eeb62881d8..c30f6c0b62 100644 --- a/packages/files-ui/cypress/support/page-objects/settingsPage.ts +++ b/packages/files-ui/cypress/support/page-objects/settingsPage.ts @@ -25,6 +25,11 @@ export const settingsPage = { // security tab securityTabButton: () => cy.get("[data-testid=tab-security]"), securityTabHeader: () => cy.get("[data-cy=label-security-header]"), + changePasswordLink: () => cy.get("[data-cy=link-change-password]"), + passwordInput: () => cy.get("[data-cy=input-sign-in-password]"), + confirmPasswordInput: () => cy.get("[data-cy=input-sign-in-password-verification]"), + changePasswordButton: () => cy.get("[data-cy=button-sign-in-password]"), + changePasswordErrorLabel: () => cy.get("[data-cy=form-change-password] span.error"), // subscription tab subscriptionTabButton: () => cy.get("[data-testid=tab-subscription]"), diff --git a/packages/files-ui/cypress/tests/settings-spec.ts b/packages/files-ui/cypress/tests/settings-spec.ts index 6491f166de..6bb4ecce84 100644 --- a/packages/files-ui/cypress/tests/settings-spec.ts +++ b/packages/files-ui/cypress/tests/settings-spec.ts @@ -1,16 +1,15 @@ import { navigationMenu } from "../support/page-objects/navigationMenu" import { settingsPage } from "../support/page-objects/settingsPage" import { homePage } from "../support/page-objects/homePage" +import { complexPassword, simplePassword } from "../fixtures/filesTestData" // import { profileUpdateSuccessToast } from "../support/page-objects/toasts/profileUpdateSuccessToast" describe("Settings", () => { context("desktop", () => { - beforeEach(() => { - cy.web3Login() - navigationMenu.settingsNavButton().click() - }) it("can navigate to settings profile page", () => { + cy.web3Login() + navigationMenu.settingsNavButton().click() settingsPage.profileTabHeader().should("be.visible") cy.url().should("include", "/settings") settingsPage.profileTabButton().click() @@ -19,6 +18,8 @@ describe("Settings", () => { }) // it("save changes button should be disabled without first and last name", () => { + // cy.web3Login() + // navigationMenu.settingsNavButton().click() // settingsPage.signOutDropdown().should("be.visible") // settingsPage.firstNameInput().clear() // settingsPage.lastNameInput().clear() @@ -43,6 +44,8 @@ describe("Settings", () => { const newUserName = Date.now().toString() it("can add a username", () => { + cy.web3Login() + navigationMenu.settingsNavButton().click() settingsPage.signOutDropdown().should("be.visible") settingsPage.addUsernameButton().should("be.visible") settingsPage.addUsernameButton().click() @@ -55,12 +58,75 @@ describe("Settings", () => { }) it("can navigate to settings security page", () => { + cy.web3Login() + navigationMenu.settingsNavButton().click() settingsPage.securityTabButton().click() cy.url().should("include", "/settings") settingsPage.securityTabButton().click() cy.url().should("include", "/settings/security") settingsPage.securityTabHeader().should("be.visible") }) + + it("can change the account password", () => { + cy.web3Login({ withNewSession: true }) + navigationMenu.settingsNavButton().click() + settingsPage.securityTabButton().click() + settingsPage.securityTabButton().click() + settingsPage.changePasswordLink().click() + + // change password + settingsPage.passwordInput().type(complexPassword) + settingsPage.confirmPasswordInput().type(complexPassword) + settingsPage.changePasswordButton().click() + + // ensure change password elements are not displayed after change + settingsPage.passwordInput().should("not.exist") + settingsPage.confirmPasswordInput().should("not.exist") + settingsPage.changePasswordButton().should("not.exist") + }) + + it.only("can see error messages when password doesn't meet critieria", () => { + cy.web3Login() + navigationMenu.settingsNavButton().click() + settingsPage.securityTabButton().click() + settingsPage.securityTabButton().click() + settingsPage.changePasswordLink().click() + + // ensure error displayed if password fields are blank + settingsPage.passwordInput().type("{selectall}{del}{esc}") + settingsPage.confirmPasswordInput().type("{selectall}{del}{esc}") + settingsPage.changePasswordButton().click() + settingsPage.changePasswordErrorLabel() + .should("be.visible") + .should("have.length", 2) + + + // ensure error displayed if passwords are not complex enough + settingsPage.passwordInput().type(simplePassword) + settingsPage.confirmPasswordInput().type(simplePassword) + settingsPage.changePasswordButton().click() + settingsPage.changePasswordErrorLabel() + .should("be.visible") + .should("have.length", 2) + + + // should see error if confirm password is missing + settingsPage.passwordInput().type(complexPassword) + settingsPage.confirmPasswordInput().type("{selectall}{del}{esc}") + settingsPage.changePasswordButton().click() + settingsPage.changePasswordErrorLabel() + .should("be.visible") + .should("have.length", 1) + + + // should see error if confirm password does not match password + settingsPage.passwordInput().type(complexPassword) + settingsPage.confirmPasswordInput().type(simplePassword) + settingsPage.changePasswordButton().click() + settingsPage.changePasswordErrorLabel() + .should("be.visible") + .should("have.length", 1) + }) }) context("mobile", () => { diff --git a/packages/files-ui/src/Components/Modules/Settings/SecurityTab/index.tsx b/packages/files-ui/src/Components/Modules/Settings/SecurityTab/index.tsx index 1296e14064..a193a0d144 100644 --- a/packages/files-ui/src/Components/Modules/Settings/SecurityTab/index.tsx +++ b/packages/files-ui/src/Components/Modules/Settings/SecurityTab/index.tsx @@ -242,7 +242,10 @@ const Security = ({ className }: SecurityProps) => { )} { isChangingPassword ? ( -
+
{
) @@ -274,6 +278,7 @@ const Security = ({ className }: SecurityProps) => { {setIsChangingPassword(true)}} + data-cy="link-change-password" > Change Password From 4003b5ed2e3304577b6e69af2bcdffa78e6b55b6 Mon Sep 17 00:00:00 2001 From: Andrew Snaith Date: Tue, 24 May 2022 15:37:35 -0700 Subject: [PATCH 3/4] Additional test spec changes --- .../files-ui/cypress/tests/settings-spec.ts | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/files-ui/cypress/tests/settings-spec.ts b/packages/files-ui/cypress/tests/settings-spec.ts index 6bb4ecce84..897f839bb3 100644 --- a/packages/files-ui/cypress/tests/settings-spec.ts +++ b/packages/files-ui/cypress/tests/settings-spec.ts @@ -44,7 +44,7 @@ describe("Settings", () => { const newUserName = Date.now().toString() it("can add a username", () => { - cy.web3Login() + cy.web3Login({ withNewSession: true }) navigationMenu.settingsNavButton().click() settingsPage.signOutDropdown().should("be.visible") settingsPage.addUsernameButton().should("be.visible") @@ -85,47 +85,44 @@ describe("Settings", () => { settingsPage.changePasswordButton().should("not.exist") }) - it.only("can see error messages when password doesn't meet critieria", () => { + it("can see error messages when password doesn't meet critieria", () => { cy.web3Login() navigationMenu.settingsNavButton().click() settingsPage.securityTabButton().click() settingsPage.securityTabButton().click() settingsPage.changePasswordLink().click() - // ensure error displayed if password fields are blank + // ensure an error is displayed if password fields are blank settingsPage.passwordInput().type("{selectall}{del}{esc}") settingsPage.confirmPasswordInput().type("{selectall}{del}{esc}") settingsPage.changePasswordButton().click() settingsPage.changePasswordErrorLabel() .should("be.visible") - .should("have.length", 2) - + .should("have.length.at.least", 2) - // ensure error displayed if passwords are not complex enough + // ensure an error displayed if passwords are not complex enough settingsPage.passwordInput().type(simplePassword) settingsPage.confirmPasswordInput().type(simplePassword) settingsPage.changePasswordButton().click() settingsPage.changePasswordErrorLabel() .should("be.visible") - .should("have.length", 2) + .should("have.length.at.least", 2) - - // should see error if confirm password is missing + // should see an error if confirm password is missing settingsPage.passwordInput().type(complexPassword) settingsPage.confirmPasswordInput().type("{selectall}{del}{esc}") settingsPage.changePasswordButton().click() settingsPage.changePasswordErrorLabel() .should("be.visible") - .should("have.length", 1) - + .should("have.length.at.least", 1) - // should see error if confirm password does not match password + // should see an error if confirm password does not match password settingsPage.passwordInput().type(complexPassword) settingsPage.confirmPasswordInput().type(simplePassword) settingsPage.changePasswordButton().click() settingsPage.changePasswordErrorLabel() .should("be.visible") - .should("have.length", 1) + .should("have.length.at.least", 1) }) }) From 23f0e6b2fbd413155f0a9830270f231ebf764e98 Mon Sep 17 00:00:00 2001 From: Andrew Snaith Date: Thu, 26 May 2022 15:23:09 -0700 Subject: [PATCH 4/4] fix check after pr feedback --- .../cypress/support/page-objects/settingsPage.ts | 2 +- packages/files-ui/cypress/tests/settings-spec.ts | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/files-ui/cypress/support/page-objects/settingsPage.ts b/packages/files-ui/cypress/support/page-objects/settingsPage.ts index c30f6c0b62..b4a3f18add 100644 --- a/packages/files-ui/cypress/support/page-objects/settingsPage.ts +++ b/packages/files-ui/cypress/support/page-objects/settingsPage.ts @@ -29,7 +29,7 @@ export const settingsPage = { passwordInput: () => cy.get("[data-cy=input-sign-in-password]"), confirmPasswordInput: () => cy.get("[data-cy=input-sign-in-password-verification]"), changePasswordButton: () => cy.get("[data-cy=button-sign-in-password]"), - changePasswordErrorLabel: () => cy.get("[data-cy=form-change-password] span.error"), + changePasswordErrorLabel: () => cy.get("[data-cy=form-change-password] span.default.error"), // subscription tab subscriptionTabButton: () => cy.get("[data-testid=tab-subscription]"), diff --git a/packages/files-ui/cypress/tests/settings-spec.ts b/packages/files-ui/cypress/tests/settings-spec.ts index 897f839bb3..5d055a30bb 100644 --- a/packages/files-ui/cypress/tests/settings-spec.ts +++ b/packages/files-ui/cypress/tests/settings-spec.ts @@ -92,21 +92,20 @@ describe("Settings", () => { settingsPage.securityTabButton().click() settingsPage.changePasswordLink().click() - // ensure an error is displayed if password fields are blank + // ensure errors are displayed if password fields are blank settingsPage.passwordInput().type("{selectall}{del}{esc}") settingsPage.confirmPasswordInput().type("{selectall}{del}{esc}") settingsPage.changePasswordButton().click() settingsPage.changePasswordErrorLabel() .should("be.visible") - .should("have.length.at.least", 2) + .should("have.length", 2) - // ensure an error displayed if passwords are not complex enough + // ensure an error displayed if password is not complex enough settingsPage.passwordInput().type(simplePassword) - settingsPage.confirmPasswordInput().type(simplePassword) settingsPage.changePasswordButton().click() settingsPage.changePasswordErrorLabel() .should("be.visible") - .should("have.length.at.least", 2) + .should("have.length", 2) // should see an error if confirm password is missing settingsPage.passwordInput().type(complexPassword) @@ -114,7 +113,7 @@ describe("Settings", () => { settingsPage.changePasswordButton().click() settingsPage.changePasswordErrorLabel() .should("be.visible") - .should("have.length.at.least", 1) + .should("have.length", 1) // should see an error if confirm password does not match password settingsPage.passwordInput().type(complexPassword) @@ -122,7 +121,7 @@ describe("Settings", () => { settingsPage.changePasswordButton().click() settingsPage.changePasswordErrorLabel() .should("be.visible") - .should("have.length.at.least", 1) + .should("have.length", 1) }) })