Skip to content

Commit

Permalink
test(e2e): update tests for passcode auto submit
Browse files Browse the repository at this point in the history
  • Loading branch information
coldlink committed Feb 5, 2025
1 parent 2c8ea15 commit 9ed284a
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 58 deletions.
11 changes: 5 additions & 6 deletions cypress/integration/ete/new_account_review.3.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
33 changes: 14 additions & 19 deletions cypress/integration/ete/registration_1.2.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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');
Expand All @@ -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);
Expand Down Expand Up @@ -160,16 +159,16 @@ 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))
.and('match', new RegExp(refViewId))
.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');
Expand Down Expand Up @@ -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))
Expand All @@ -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');
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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');
});
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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');

Expand Down
3 changes: 1 addition & 2 deletions cypress/integration/ete/registration_2.6.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 4 additions & 6 deletions cypress/integration/ete/reset_password_2.5.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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');
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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');
Expand Down
Loading

0 comments on commit 9ed284a

Please sign in to comment.