From 9ed284af56d85f731f615b139cc10784b6bd9f23 Mon Sep 17 00:00:00 2001 From: Mahesh Makani Date: Tue, 4 Feb 2025 10:17:07 +0000 Subject: [PATCH] test(e2e): update tests for passcode auto submit --- .../ete/new_account_review.3.cy.ts | 11 +++--- .../integration/ete/registration_1.2.cy.ts | 33 +++++++--------- .../integration/ete/registration_2.6.cy.ts | 3 +- .../integration/ete/reset_password_2.5.cy.ts | 10 ++--- .../ete/reset_password_passcode.7.cy.ts | 38 +++++++++---------- cypress/integration/ete/sign_in.1.cy.ts | 2 +- .../integration/ete/sign_in_passcode.8.cy.ts | 9 ++--- 7 files changed, 48 insertions(+), 58 deletions(-) diff --git a/cypress/integration/ete/new_account_review.3.cy.ts b/cypress/integration/ete/new_account_review.3.cy.ts index a67a1f42b..1c876d668 100644 --- a/cypress/integration/ete/new_account_review.3.cy.ts +++ b/cypress/integration/ete/new_account_review.3.cy.ts @@ -44,10 +44,9 @@ describe('New account review page', () => { // passcode page cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); - cy.contains('Complete creating account'); cy.get('input[name="password"]').type(randomPassword()); cy.get('button[type="submit"]').click(); @@ -128,9 +127,9 @@ describe('New account review page', () => { // passcode page cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); cy.contains('Complete creating account'); cy.get('input[name="password"]').type(randomPassword()); cy.get('button[type="submit"]').click(); @@ -204,9 +203,9 @@ describe('New account newsletters page', () => { // passcode page cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); cy.contains('Complete creating account'); cy.get('input[name="password"]').type(randomPassword()); cy.get('button[type="submit"]').click(); @@ -249,9 +248,9 @@ describe('New account newsletters page', () => { // passcode page cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); cy.contains('Complete creating account'); cy.get('input[name="password"]').type(randomPassword()); cy.get('button[type="submit"]').click(); @@ -296,9 +295,9 @@ describe('New account newsletters page', () => { // passcode page cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); cy.contains('Complete creating account'); cy.get('input[name="password"]').type(randomPassword()); cy.get('button[type="submit"]').click(); diff --git a/cypress/integration/ete/registration_1.2.cy.ts b/cypress/integration/ete/registration_1.2.cy.ts index d46a233b6..0b28e2827 100644 --- a/cypress/integration/ete/registration_1.2.cy.ts +++ b/cypress/integration/ete/registration_1.2.cy.ts @@ -61,8 +61,8 @@ const existingUserSendEmailAndValidatePasscode = ({ const code = codes?.[0].value; expect(code).to.match(/^\d{6}$/); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); cy.contains('Return to the Guardian') .should('have.attr', 'href') @@ -82,10 +82,9 @@ const existingUserSendEmailAndValidatePasscode = ({ } case 'passcode-incorrect': { + cy.contains('Submit verification code'); cy.get('input[name=code]').type(`123456`); - cy.contains('Submit verification code').click(); - cy.url().should('include', '/register/code'); cy.contains('Incorrect code'); @@ -105,8 +104,8 @@ const existingUserSendEmailAndValidatePasscode = ({ } break; default: { + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); if (params?.includes('fromURI')) { cy.url().should('include', expectedReturnUrl); @@ -160,8 +159,6 @@ describe('Registration flow - Split 1/2', () => { // passcode page cy.url().should('include', '/register/email-sent'); - cy.get('input[name=code]').type(code!); - cy.get('form') .should('have.attr', 'action') .and('match', new RegExp(encodedReturnUrl)) @@ -169,7 +166,9 @@ describe('Registration flow - Split 1/2', () => { .and('match', new RegExp(encodedRef)) .and('match', new RegExp(clientId)); - cy.contains('Submit verification code').click(); + cy.contains('Submit verification code'); + + cy.get('input[name=code]').type(code!); // password page cy.url().should('include', '/welcome/password'); @@ -239,8 +238,6 @@ describe('Registration flow - Split 1/2', () => { // passcode page cy.url().should('include', '/register/email-sent'); - cy.get('input[name=code]').type(code!); - cy.get('form') .should('have.attr', 'action') .and('match', new RegExp(encodedReturnUrl)) @@ -249,7 +246,8 @@ describe('Registration flow - Split 1/2', () => { .and('match', new RegExp(appClientId)) .and('match', new RegExp(encodeURIComponent(fromURI))); - cy.contains('Submit verification code').click(); + cy.contains('Submit verification code'); + cy.get('input[name=code]').type(code!); // password page cy.url().should('include', '/welcome/password'); @@ -336,8 +334,8 @@ describe('Registration flow - Split 1/2', () => { // passcode page cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); cy.contains('Complete creating account'); @@ -374,10 +372,9 @@ describe('Registration flow - Split 1/2', () => { // passcode page cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(`${+code! + 1}`); - cy.contains('Submit verification code').click(); - cy.url().should('include', '/register/code'); cy.contains('Incorrect code'); @@ -412,8 +409,8 @@ describe('Registration flow - Split 1/2', () => { expect(code).to.match(/^\d{6}$/); // passcode page + cy.contains('Submit verification code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit verification code').click(); cy.url().should('contain', '/welcome/password'); @@ -475,8 +472,8 @@ describe('Registration flow - Split 1/2', () => { cy.url().should('include', '/register/email-sent'); cy.contains('Email with verification code sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); cy.url().should('contain', '/welcome/password'); }); @@ -756,10 +753,9 @@ describe('Registration flow - Split 1/2', () => { // passcode page cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); - // password page cy.url().should('include', '/welcome/password'); @@ -827,10 +823,9 @@ describe('Registration flow - Split 1/2', () => { // passcode page cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); - // password page cy.url().should('include', '/welcome/password'); diff --git a/cypress/integration/ete/registration_2.6.cy.ts b/cypress/integration/ete/registration_2.6.cy.ts index 69639b611..3be44b11f 100644 --- a/cypress/integration/ete/registration_2.6.cy.ts +++ b/cypress/integration/ete/registration_2.6.cy.ts @@ -305,10 +305,9 @@ describe('Registration flow - Split 2/2', () => { // passcode page cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); - cy.contains('Complete creating account'); cy.get('form') diff --git a/cypress/integration/ete/reset_password_2.5.cy.ts b/cypress/integration/ete/reset_password_2.5.cy.ts index a756c7e8d..8b62fca68 100644 --- a/cypress/integration/ete/reset_password_2.5.cy.ts +++ b/cypress/integration/ete/reset_password_2.5.cy.ts @@ -37,10 +37,9 @@ describe('Password reset recovery flows', () => { // passcode page cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); - // password page cy.url().should('include', '/welcome/password'); @@ -66,8 +65,8 @@ describe('Password reset recovery flows', () => { cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); + cy.contains('Submit one-time code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit one-time code').click(); // password page cy.url().should('include', '/reset-password/password'); @@ -107,10 +106,9 @@ describe('Password reset recovery flows', () => { // passcode page cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); - // password page cy.url().should('include', '/welcome/password'); @@ -138,8 +136,8 @@ describe('Password reset recovery flows', () => { cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); + cy.contains('Submit one-time code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit one-time code').click(); // password page cy.url().should('include', '/reset-password/password'); diff --git a/cypress/integration/ete/reset_password_passcode.7.cy.ts b/cypress/integration/ete/reset_password_passcode.7.cy.ts index bad4ed840..7f43e5ff4 100644 --- a/cypress/integration/ete/reset_password_passcode.7.cy.ts +++ b/cypress/integration/ete/reset_password_passcode.7.cy.ts @@ -37,8 +37,6 @@ describe('Password reset recovery flows - with Passcodes', () => { // passcode page cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); - cy.get('input[name=code]').type(code!); - cy.get('form') .should('have.attr', 'action') .and('match', new RegExp(encodedReturnUrl)) @@ -46,7 +44,9 @@ describe('Password reset recovery flows - with Passcodes', () => { .and('match', new RegExp(encodedRef)) .and('match', new RegExp(clientId)); - cy.contains('Submit one-time code').click(); + cy.contains('Submit one-time code'); + + cy.get('input[name=code]').type(code!); // password page cy.url().should('include', '/reset-password/password'); @@ -123,8 +123,6 @@ describe('Password reset recovery flows - with Passcodes', () => { // passcode page cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); - cy.get('input[name=code]').type(code!); - cy.get('form') .should('have.attr', 'action') .and('match', new RegExp(encodedReturnUrl)) @@ -134,7 +132,9 @@ describe('Password reset recovery flows - with Passcodes', () => { .and('match', new RegExp(appClientId)) .and('match', new RegExp(encodeURIComponent(fromURI))); - cy.contains('Submit one-time code').click(); + cy.contains('Submit one-time code'); + + cy.get('input[name=code]').type(code!); // password page cy.url().should('include', '/reset-password/password'); @@ -183,9 +183,9 @@ describe('Password reset recovery flows - with Passcodes', () => { // passcode page cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); - cy.get('input[name=code]').type(`${+code! + 1}`); + cy.contains('Submit one-time code'); - cy.contains('Submit one-time code').click(); + cy.get('input[name=code]').type(`${+code! + 1}`); cy.url().should('include', '/reset-password/code'); @@ -232,8 +232,8 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); + cy.contains('Submit one-time code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit one-time code').click(); cy.url().should('contain', '/reset-password/password'); @@ -300,8 +300,8 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); + cy.contains('Submit one-time code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit one-time code').click(); cy.url().should('contain', '/reset-password/password'); @@ -390,8 +390,8 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); + cy.contains('Submit one-time code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit one-time code').click(); cy.url().should('contain', '/set-password'); @@ -453,8 +453,8 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); + cy.contains('Submit one-time code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit one-time code').click(); cy.url().should('contain', '/set-password'); @@ -489,8 +489,8 @@ describe('Password reset recovery flows - with Passcodes', () => { // passcode page, use passcode cy.url().should('include', '/register/email-sent'); + cy.contains('Submit verification code'); cy.get('input[name=code]').type(code!); - cy.contains('Submit verification code').click(); // password page, don't set password cy.url().should('include', '/welcome/password'); @@ -519,8 +519,8 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); + cy.contains('Submit one-time code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit one-time code').click(); // password page cy.url().should('include', '/reset-password/password'); @@ -560,8 +560,8 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); + cy.contains('Submit one-time code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit one-time code').click(); // password page cy.url().should('include', '/reset-password/password'); @@ -606,8 +606,8 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); + cy.contains('Submit one-time code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit one-time code').click(); // password page cy.url().should('include', '/reset-password/password'); @@ -652,8 +652,8 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); + cy.contains('Submit one-time code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit one-time code').click(); // password page cy.url().should('include', '/reset-password/password'); @@ -698,8 +698,8 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.url().should('include', '/reset-password/email-sent'); cy.contains('Enter your one-time code'); + cy.contains('Submit one-time code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit one-time code').click(); // password page cy.url().should('include', '/reset-password/password'); @@ -732,8 +732,8 @@ describe('Password reset recovery flows - with Passcodes', () => { cy.contains('Enter your one-time code'); cy.contains('Don’t have an account?'); + cy.contains('Submit one-time code'); cy.get('input[name=code]').clear().type('123456'); - cy.contains('Submit one-time code').click(); cy.url().should('include', '/reset-password/code'); cy.contains('Enter your one-time code'); diff --git a/cypress/integration/ete/sign_in.1.cy.ts b/cypress/integration/ete/sign_in.1.cy.ts index 60fed9774..f3aa89530 100644 --- a/cypress/integration/ete/sign_in.1.cy.ts +++ b/cypress/integration/ete/sign_in.1.cy.ts @@ -472,8 +472,8 @@ describe('Sign in flow, Okta enabled', () => { cy.contains( 'For security reasons we need you to change your password.', ); + cy.contains('Submit verification code'); cy.get('input[name=code]').clear().type(code!); - cy.contains('Submit verification code').click(); cy.url().should('contain', '/set-password'); diff --git a/cypress/integration/ete/sign_in_passcode.8.cy.ts b/cypress/integration/ete/sign_in_passcode.8.cy.ts index 456c09a0a..9d6e441b0 100644 --- a/cypress/integration/ete/sign_in_passcode.8.cy.ts +++ b/cypress/integration/ete/sign_in_passcode.8.cy.ts @@ -61,8 +61,8 @@ describe('Sign In flow, with passcode', () => { const code = codes?.[0].value; expect(code).to.match(/^\d{6}$/); + cy.contains('Sign in'); cy.get('input[name=code]').type(code!); - cy.contains('Sign in').click(); cy.url().should('include', expectedReturnUrl); @@ -79,10 +79,9 @@ describe('Sign In flow, with passcode', () => { cy.url().should('include', '/signin'); break; case 'passcode-incorrect': + cy.contains('Sign in'); cy.get('input[name=code]').type(`${+code! + 1}`); - cy.contains('Sign in').click(); - cy.url().should('include', '/signin/code'); cy.contains('Incorrect code'); @@ -98,8 +97,8 @@ describe('Sign In flow, with passcode', () => { }); break; default: { + cy.contains('Sign in'); cy.get('input[name=code]').type(code!); - cy.contains('Sign in').click(); cy.url().should('include', expectedReturnUrl); @@ -370,8 +369,8 @@ describe('Sign In flow, with passcode', () => { cy.contains('Enter your one-time code'); cy.contains('Don’t have an account?'); + cy.contains('Sign in'); cy.get('input[name=code]').clear().type('123456'); - cy.contains('Sign in').click(); cy.url().should('include', '/signin/code'); cy.contains('Enter your one-time code');