From 1c2a48a57ed317547299184e5f67303abdee74dd Mon Sep 17 00:00:00 2001 From: Shane Laymance Date: Wed, 18 Aug 2021 11:56:09 -0700 Subject: [PATCH 1/6] Use common button click step and make it case insensitive --- packages/e2e/cypress/integration/common/index.tsx | 2 +- .../reset-password/reset-password.steps.ts | 8 -------- .../sign-in-force-new-password.steps.ts | 4 ---- .../sign-in-sms-mfa/sign-in-sms-mfa.steps.ts | 4 ---- .../sign-in-totp-mfa/sign-in-totp-mfa.steps.ts | 4 ---- .../sign-in-with-email/sign-in-with-email.steps.ts | 4 ---- .../sign-in-with-phone/sign-in-with-phone.steps.ts | 4 ---- .../sign-in-with-username.steps.ts | 4 ---- .../sign-up-with-email/sign-up-with-email.steps.ts | 4 ---- .../sign-up-with-phone/sign-up-with-phone.steps.ts | 4 ---- .../authenticator/sign-up/sign-up.steps.ts | 12 ++++-------- 11 files changed, 5 insertions(+), 49 deletions(-) diff --git a/packages/e2e/cypress/integration/common/index.tsx b/packages/e2e/cypress/integration/common/index.tsx index 854b1e720ad..5aa1ed5639c 100644 --- a/packages/e2e/cypress/integration/common/index.tsx +++ b/packages/e2e/cypress/integration/common/index.tsx @@ -16,7 +16,7 @@ And('I type a valid password {string}', (password: string) => { }); And('I click the {string} button', (name: string) => { - cy.findByRole('button', { name }).click(); + cy.findByRole('button', { name: new RegExp(name, 'i') }).click(); }); Then('I see {string}', (message: string) => { diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/reset-password/reset-password.steps.ts b/packages/e2e/cypress/integration/ui/components/authenticator/reset-password/reset-password.steps.ts index 0cb5aed886b..b22e003a5bf 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/reset-password/reset-password.steps.ts +++ b/packages/e2e/cypress/integration/ui/components/authenticator/reset-password/reset-password.steps.ts @@ -4,10 +4,6 @@ Given("I'm running the example {string}", (url: string) => { cy.visit(url); }); -When('I click on the {string} button', (name: string) => { - cy.findByRole('button', { name }).click(); -}); - And('I type a valid username {string}', (username: string) => { cy.findByRole('textbox', { name: /username/i }).type(Cypress.env(username)); }); @@ -16,10 +12,6 @@ And('I type an invalid username {string}', (username: string) => { cy.findByRole('textbox', { name: /username/i }).type(Cypress.env(username)); }); -And('I click the {string} button', (name: string) => { - cy.findByRole('button', { name }).click(); -}); - Then('I will be redirected to the confirm forgot password page', () => { cy.findByRole('textbox', { label: 'New password' }).should('exist'); }); diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-force-new-password/sign-in-force-new-password.steps.ts b/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-force-new-password/sign-in-force-new-password.steps.ts index aab9feefc5c..3291ea1fc60 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-force-new-password/sign-in-force-new-password.steps.ts +++ b/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-force-new-password/sign-in-force-new-password.steps.ts @@ -13,10 +13,6 @@ And('I type in the password {string}', (password: string) => { cy.findByLabelText(/password/i).type(Cypress.env(password)); }); -And('I click the {string} button', (name: string) => { - cy.findByRole('button', { name }).click(); -}); - Then('I should see the Force Change Password screen', () => { cy.findByRole('document').contains(new RegExp('Change Password', 'i')); }); diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-sms-mfa/sign-in-sms-mfa.steps.ts b/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-sms-mfa/sign-in-sms-mfa.steps.ts index 18603217f0d..60932ba7588 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-sms-mfa/sign-in-sms-mfa.steps.ts +++ b/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-sms-mfa/sign-in-sms-mfa.steps.ts @@ -21,10 +21,6 @@ And('I type a valid password {string}', (password: string) => { cy.get('[data-amplify-password]').type(Cypress.env(password)); }); -And('I click the {string} button', (name: string) => { - cy.findByRole('button', { name }).click(); -}); - Then('I will be redirected to the confirm sms mfa page', () => { cy.get('[data-amplify-authenticator-confirmsignin]').should('be.visible'); }); diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-totp-mfa/sign-in-totp-mfa.steps.ts b/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-totp-mfa/sign-in-totp-mfa.steps.ts index 559f060c2d6..e2178979503 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-totp-mfa/sign-in-totp-mfa.steps.ts +++ b/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-totp-mfa/sign-in-totp-mfa.steps.ts @@ -20,10 +20,6 @@ And('I type a valid password {string}', (password: string) => { cy.get('[data-amplify-password]').type(Cypress.env(password)); }); -And('I click the {string} button', (name: string) => { - cy.findByRole('button', { name }).click(); -}); - Then('I will be redirected to the confirm totp mfa page', () => { cy.get('body').contains('TOTP'); }); diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-with-email/sign-in-with-email.steps.ts b/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-with-email/sign-in-with-email.steps.ts index 8d8d9fdc188..7fd4121f5ed 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-with-email/sign-in-with-email.steps.ts +++ b/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-with-email/sign-in-with-email.steps.ts @@ -12,10 +12,6 @@ And('I type the valid password {string}', (password: string) => { cy.findByLabelText(/password/i).type(Cypress.env(password)); }); -And('I click the {string} button', (name: string) => { - cy.findByRole('button', { name }).click(); -}); - Then('I see {string}', (message: string) => { cy.findByRole('document').contains(new RegExp(message, 'i')); }); diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-with-phone/sign-in-with-phone.steps.ts b/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-with-phone/sign-in-with-phone.steps.ts index c45f33ce677..0858dbbea62 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-with-phone/sign-in-with-phone.steps.ts +++ b/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-with-phone/sign-in-with-phone.steps.ts @@ -14,10 +14,6 @@ And('I type the valid password {string}', (password: string) => { cy.findByLabelText(/password/i).type(Cypress.env(password)); }); -And('I click the {string} button', (name: string) => { - cy.findByRole('button', { name }).click(); -}); - Then('I see {string}', (message: string) => { cy.findByRole('document').contains(new RegExp(message, 'i')); }); diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-with-username/sign-in-with-username.steps.ts b/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-with-username/sign-in-with-username.steps.ts index 332adf9ce85..f9f8b9fd4a2 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-with-username/sign-in-with-username.steps.ts +++ b/packages/e2e/cypress/integration/ui/components/authenticator/sign-in-with-username/sign-in-with-username.steps.ts @@ -12,10 +12,6 @@ And('I type the valid password {string}', (password: string) => { cy.findByLabelText(/password/i).type(Cypress.env(password)); }); -And('I click the {string} button', (name: string) => { - cy.findByRole('button', { name }).click(); -}); - Then('I see {string}', (message: string) => { cy.findByRole('document').contains(new RegExp(message, 'i')); }); diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/sign-up-with-email/sign-up-with-email.steps.ts b/packages/e2e/cypress/integration/ui/components/authenticator/sign-up-with-email/sign-up-with-email.steps.ts index 2c65ede9629..9feac56268f 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/sign-up-with-email/sign-up-with-email.steps.ts +++ b/packages/e2e/cypress/integration/ui/components/authenticator/sign-up-with-email/sign-up-with-email.steps.ts @@ -30,10 +30,6 @@ And('I confirm the password {string}', (password: string) => { cy.findByLabelText(/confirm password/i).type(Cypress.env(password)); }); -And('I click the {string} button', (name: string) => { - cy.findByRole('button', { name }).click(); -}); - Then('I see {string}', (message: string) => { cy.findByRole('document').contains(message); }); diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/sign-up-with-phone/sign-up-with-phone.steps.ts b/packages/e2e/cypress/integration/ui/components/authenticator/sign-up-with-phone/sign-up-with-phone.steps.ts index a77b2b3da57..8650bfeb272 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/sign-up-with-phone/sign-up-with-phone.steps.ts +++ b/packages/e2e/cypress/integration/ui/components/authenticator/sign-up-with-phone/sign-up-with-phone.steps.ts @@ -28,10 +28,6 @@ And('I confirm the password {string}', (password: string) => { cy.findByLabelText(/confirm password/i).type(Cypress.env(password)); }); -And('I click the {string} button', (name: string) => { - cy.findByRole('button', { name }).click(); -}); - Then('I see {string}', (message: string) => { cy.findByRole('document').contains(message); }); diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/sign-up/sign-up.steps.ts b/packages/e2e/cypress/integration/ui/components/authenticator/sign-up/sign-up.steps.ts index ad0400cbd3f..2151f4c425d 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/sign-up/sign-up.steps.ts +++ b/packages/e2e/cypress/integration/ui/components/authenticator/sign-up/sign-up.steps.ts @@ -4,11 +4,11 @@ const now = Date.now(); const randomNumber = window.crypto.getRandomValues(new Uint32Array(1))[0]; const password = `test-${randomNumber}`; -Given("I'm running the example {string}", url => { +Given("I'm running the example {string}", (url) => { cy.visit(url); }); -And('I click {string}', text => { +And('I click {string}', (text) => { cy.findByText(text).click(); }); @@ -24,18 +24,14 @@ And('I type a new confirm password', () => { cy.findByLabelText(/^confirm password$/i).type(`${password}`); }); -And('I type the email {string}', email => { +And('I type the email {string}', (email) => { cy.findByLabelText('Email').type(email); }); -And('I type the phone number {string}', phone => { +And('I type the phone number {string}', (phone) => { cy.findByLabelText('Phone Number').type(phone); }); -And('I click the {string} button', (name: string) => { - cy.findByRole('button', { name }).click(); -}); - Then('I see {string}', (message: string) => { cy.get('body').contains(message); }); From 007b63ba4142fec571c2b45a72697da179f40ce8 Mon Sep 17 00:00:00 2001 From: Shane Laymance Date: Wed, 18 Aug 2021 12:00:04 -0700 Subject: [PATCH 2/6] Rename step to When --- packages/e2e/cypress/integration/common/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e/cypress/integration/common/index.tsx b/packages/e2e/cypress/integration/common/index.tsx index 5aa1ed5639c..3a3b5c6a9f3 100644 --- a/packages/e2e/cypress/integration/common/index.tsx +++ b/packages/e2e/cypress/integration/common/index.tsx @@ -15,7 +15,7 @@ And('I type a valid password {string}', (password: string) => { cy.findByLabelText(/password/i).type(Cypress.env(password)); }); -And('I click the {string} button', (name: string) => { +When('I click the {string} button', (name: string) => { cy.findByRole('button', { name: new RegExp(name, 'i') }).click(); }); From 7f5e2f8eb6f96a6a0355173049b7532fbdc13710 Mon Sep 17 00:00:00 2001 From: Shane Laymance Date: Wed, 18 Aug 2021 13:03:29 -0700 Subject: [PATCH 3/6] Rename button step for reset-password --- .../ui/components/authenticator/reset-password.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/reset-password.feature b/packages/e2e/cypress/integration/ui/components/authenticator/reset-password.feature index b841a309c80..7d071dd9a9b 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/reset-password.feature +++ b/packages/e2e/cypress/integration/ui/components/authenticator/reset-password.feature @@ -9,7 +9,7 @@ Feature: Reset Password @next @react Scenario: Reset Password with valid username - When I click on the "Reset password" button + When I click the "Reset password" button And I type a valid username "VALID_USERNAME" And I click the "Send code" button Then I will be redirected to the confirm forgot password page From 5db88c68828428b4b4c6fead99c3b701c23cb7ad Mon Sep 17 00:00:00 2001 From: Shane Laymance Date: Wed, 18 Aug 2021 13:08:16 -0700 Subject: [PATCH 4/6] Remove unused variable --- .../authenticator/reset-password/reset-password.steps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/reset-password/reset-password.steps.ts b/packages/e2e/cypress/integration/ui/components/authenticator/reset-password/reset-password.steps.ts index b22e003a5bf..40b4145812a 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/reset-password/reset-password.steps.ts +++ b/packages/e2e/cypress/integration/ui/components/authenticator/reset-password/reset-password.steps.ts @@ -1,4 +1,4 @@ -import { And, Given, Then, When } from 'cypress-cucumber-preprocessor/steps'; +import { And, Given, Then } from 'cypress-cucumber-preprocessor/steps'; Given("I'm running the example {string}", (url: string) => { cy.visit(url); From 6da0a942c82bf4af238946c928a67cf5fadd39c5 Mon Sep 17 00:00:00 2001 From: Shane Laymance Date: Wed, 18 Aug 2021 14:40:21 -0700 Subject: [PATCH 5/6] Skip sign up with email test --- .../ui/components/authenticator/sign-up-with-email.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/sign-up-with-email.feature b/packages/e2e/cypress/integration/ui/components/authenticator/sign-up-with-email.feature index 6bd07abe955..33f434d784b 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/sign-up-with-email.feature +++ b/packages/e2e/cypress/integration/ui/components/authenticator/sign-up-with-email.feature @@ -13,7 +13,7 @@ Feature: Sign Up with Email And I don't see "Username" as an input field And I don't see "Phone Number" as an input field -@next @react @vue @angular +@next @react @vue @angular @skip Scenario: Sign up with valid email & password When I type the email "VALID_EMAIL" And I type the password "VALID_PASSWORD" From c7ebea9cddc95f828835dc748f8988347d4d452f Mon Sep 17 00:00:00 2001 From: Shane Laymance Date: Wed, 18 Aug 2021 15:04:43 -0700 Subject: [PATCH 6/6] Use common button click action --- .../ui/components/authenticator/reset-password.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e/cypress/integration/ui/components/authenticator/reset-password.feature b/packages/e2e/cypress/integration/ui/components/authenticator/reset-password.feature index 7d071dd9a9b..1ac4a708960 100644 --- a/packages/e2e/cypress/integration/ui/components/authenticator/reset-password.feature +++ b/packages/e2e/cypress/integration/ui/components/authenticator/reset-password.feature @@ -16,7 +16,7 @@ Feature: Reset Password @next @react Scenario: Reset Password with invalid username - When I click on the "Reset password" button + When I click the "Reset password" button And I type an invalid username "INVALID_USERNAME" And I click the "Send code" button Then I see "Username/client id combination not found."