Skip to content

Commit

Permalink
finish forgot password conversion to gherkin
Browse files Browse the repository at this point in the history
  • Loading branch information
pixiwyn committed Mar 12, 2024
1 parent b3feb21 commit 1724515
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 20 deletions.
38 changes: 36 additions & 2 deletions cypress/cypress-integration/integration/forgot-password.cy.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@deleteAllCypressTestAccountsAfter
# @deleteAllCypressTestAccountsAfter
Feature: DAWSON, Client App - Forgot Password
Background: Clear Current Session
Given a clean session
Expand All @@ -14,10 +14,44 @@ Feature: DAWSON, Client App - Forgot Password
And I enter "[email protected]" on forgot password page
Then I should see an alert that a confirmation email was resent

Scenario: Request a password reset and don't update their password and log in with old password
Scenario: Request a password reset, don't update their password, and log in with old password
Given I create a new petitioner account for "[email protected]"
And I verify my account for "[email protected]"
When I visit forgot password page
And I enter "[email protected]" on forgot password page
And I log into DAWSON as "cypress_test_account+confirmed"
Then I should see the petitioner dashboard

Scenario: Request a password reset, update password, and log in with new password
Given I create a new petitioner account for "[email protected]"
And I verify my account for "[email protected]"
When I visit forgot password page
And I enter "[email protected]" on forgot password page
Then I should see an alert that a password reset code has been sent
When I enter the default forgot password code with a new password of "brandNewPassword1204$^"
Then I should see the petitioner dashboard
Given I logout of DAWSON
When I log into DAWSON as "cypress_test_account+confirmed" with "brandNewPassword1204$^"
Then I should see the petitioner dashboard

Scenario: Attempt a password reset, enter incorrect (or expired) code, and request another code
Given I create a new petitioner account for "[email protected]"
And I verify my account for "[email protected]"
When I visit forgot password page
And I enter "[email protected]" on forgot password page
Then I should see an alert that a password reset code has been sent
When I enter an incorrect password code with a new password of "brandNewPassword1204$^"
Then I should see an alert that I have entered an invalid password reset code
Given I request a new forgot password code
When I enter "[email protected]" on forgot password page
Then I should see an alert that a password reset code has been sent

Scenario: Attempt to reset a password after given e-access to DAWSON with an unconfirmed account
Given I create and serve a paper petition + grant e-access for practitioner as "[email protected]"
Then I should see an alert that my changes to the petition have been saved
Given I logout of DAWSON
When I visit forgot password page
And I enter "[email protected]" on forgot password page
Then I should see an alert that a confirmation email was resent


18 changes: 0 additions & 18 deletions cypress/cypress-integration/integration/forgot-password.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ describe('Forgot Password', () => {
cy.get('[data-testid="my-cases-link"]');
});

/*
Given a petitioner with a DAWSON account
When they indicate that they Forgot Password
And they click the password reset link that was emailed to them
Then they should be routed to the change password screen and after successful reset, be logged into their account
*/
it('should reset a users password and log them in when they indicate they have forgotten their password and click on the email verfication link', () => {
const username = `cypress_test_account+${v4()}`;
const email = `${username}@example.com`;
Expand Down Expand Up @@ -114,12 +108,6 @@ describe('Forgot Password', () => {
cy.get('[data-testid="header-text"]').should('contain', `Welcome, ${name}`);
});

/*
Given a petitioner with a DAWSON account
When they indicate that they Forgot Password
And it has been longer than 24 hours since they indicated they Forgot Password
Then they should be alerted that their forgot password link has expired
*/
it('should notify the user that their forgot password link has expired or is wrong when the user types in the wrong confirmation code and they should be able to request a new code', () => {
const username = `cypress_test_account+${v4()}`;
const email = `${username}@example.com`;
Expand Down Expand Up @@ -161,12 +149,6 @@ describe('Forgot Password', () => {
);
});

/*
Given an external user who has been granted e-access to DAWSON
When they indicate that they Forgot Password
And their account is unconfirmed
Then they should be alerted that they have been sent an email to assist them with confirmation of their account
*/
it('should alert a user that that they have been sent an email to assist them with the confirmation of their account when they enter an email address that has been granted e-access but has not set a password', () => {
createAndServePaperPetition().then(({ docketNumber }) => {
const practitionerUserName = `cypress_test_account+${v4()}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
/* eslint-disable quotes */
import { DEFAULT_FORGOT_PASSWORD_CODE } from '../../../../support/cognito-login';
import { Given, Then, When } from '@badeball/cypress-cucumber-preprocessor';
import { v4 } from 'uuid';
import { verifyPasswordRequirements } from '../../../../helpers/auth/verify-password-requirements';

Given('I visit forgot password page', () => {
cy.visit('/login');
cy.get('[data-testid="forgot-password-button"]').click();
});

Given('I request a new forgot password code', () => {
cy.get('[data-testid="request-new-forgot-password-code-button"]').click();
});

When('I enter an email without an account on forgot password page', () => {
const emailWithoutAccount = `doesNotExist${v4()}@email.com`;
cy.get('[data-testid="email-input"]').type(emailWithoutAccount);
Expand All @@ -19,6 +25,38 @@ When(`I enter {string} on forgot password page`, (email: string) => {
cy.get('[data-testid="send-password-reset-button"]').click();
});

When(
`I enter the default forgot password code with a new password of {string}`,
(brandNewPassword: string) => {
cy.get('[data-testid="change-password-button"]').should('be.disabled');

verifyPasswordRequirements('[data-testid="new-password-input"]');

cy.get('[data-testid="forgot-password-code"]').type(
DEFAULT_FORGOT_PASSWORD_CODE,
);
cy.get('[data-testid="new-password-input"]').clear();
cy.get('[data-testid="new-password-input"]').type(brandNewPassword);
cy.get('[data-testid="confirm-new-password-input"]').clear();
cy.get('[data-testid="confirm-new-password-input"]').type(brandNewPassword);
cy.get('[data-testid="change-password-button"]').click();
},
);

When(
`I enter an incorrect password code with a new password of {string}`,
(brandNewPassword: string) => {
cy.get('[data-testid="forgot-password-code"]').type(
'totally incorrect code',
);
cy.get('[data-testid="new-password-input"]').clear();
cy.get('[data-testid="new-password-input"]').type(brandNewPassword);
cy.get('[data-testid="confirm-new-password-input"]').clear();
cy.get('[data-testid="confirm-new-password-input"]').type(brandNewPassword);
cy.get('[data-testid="change-password-button"]').click();
},
);

Then('I should see an alert that a password reset code has been sent', () => {
cy.get('[data-testid="success-alert"]').should(
'contain',
Expand All @@ -32,3 +70,13 @@ Then('I should see an alert that a confirmation email was resent', () => {
'We’ve sent you an email',
);
});

Then(
'I should see an alert that I have entered an invalid password reset code',
() => {
cy.get('[data-testid="error-alert"]').should(
'contain',
'Invalid verification code',
);
},
);
15 changes: 15 additions & 0 deletions cypress/cypress-integration/support/stepDefinitions/auth/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
When,
//defineParameterType,
} from '@badeball/cypress-cucumber-preprocessor';
import { logout } from '../../../../helpers/auth/logout';

// const users = [
// 'petitionsclerk',
Expand Down Expand Up @@ -31,6 +32,20 @@ Given('I log into DAWSON as {string}', (user: string) => {
cy.login(user);
});

Given(
'I log into DAWSON as {string} with {string}',
(user: string, password: string) => {
cy.visit('/login');
cy.get('[data-testid="email-input"]').type(`${user}@example.com`);
cy.get('[data-testid="password-input"]').type(password);
cy.get('[data-testid="login-button"]').click();
},
);

Given('I logout of DAWSON', () => {
logout();
});

When('I visit the login page', () => {
cy.visit('/login');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* eslint-disable quotes */
import { Then, When } from '@badeball/cypress-cucumber-preprocessor';
import { createAndServePaperPetition } from '../../../helpers/create-and-serve-paper-petition';

When(
`I create and serve a paper petition + grant e-access for practitioner as {string}`,
(email: string) => {
createAndServePaperPetition().then(({ docketNumber }) => {
cy.login('admissionsclerk1');
cy.get('[data-testid="messages-banner"]');
cy.get('[data-testid="docket-number-search-input"]').type(docketNumber);
cy.get('[data-testid="search-docket-number"]').click();
cy.get('[data-testid="tab-case-information"]').click();
cy.get('[data-testid="tab-parties"]').click();
cy.get('[data-testid="edit-petitioner-button"]').click();
cy.get('[data-testid="internal-edit-petitioner-email-input"]').type(
email,
);
cy.get('[data-testid="internal-confirm-petitioner-email-input"]').type(
email,
);
cy.get(
'[data-testid="submit-edit-petitioner-information-button"]',
).click();
cy.get('[data-testid="modal-button-confirm"]').click();

// cy.visit('/login');
// cy.get('[data-testid="forgot-password-button"]').click();
// cy.get('[data-testid="email-input"]').clear();
// cy.get('[data-testid="email-input"]').type(practitionerEmail);
// cy.get('[data-testid="send-password-reset-button"]').click();
// cy.get('[data-testid="warning-alert"]').should(
// 'contain',
// 'We’ve sent you an email',
// );
});
},
);

Then(
'I should see an alert that my changes to the petition have been saved',
() => {
cy.get('[data-testid="success-alert"]').contains('Changes saved');
},
);

0 comments on commit 1724515

Please sign in to comment.