-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(EMS-1696-1697): Reactivate an account (#527)
* chore(tech): fix typo * chore(tech): fix typo * feat(EMS-1694): account suspension - initial reactivation journey * feat(EMS-1694-1695): account reactivation - send reactivate email * chore(tech): improve constants documentation * feat(EMS-1694-1695): account sign in - revert accountId type to be optional * feat(EMS-1694-1695): update DB dump * fix typo * feat(EMS-1694-1695): add E2E test descriptions * feat(EMS-1694-1695): fix/update unit test * feat(EMS-1694-1695): update account suspensions to have insurance route * chore(tech): fix issue with api DATE_24_HOURS_FROM_NOW constant after merge * feat(EMS-1696-1697): account reactivation - ability to reactivate an account * feat(EMS-1696-1697): account reactivation - E2E test coverage * feat(EMS-1696-1697): reactivate account - link expired page * feat(EMS-1696-1697): account reactivation - createAnAccountAndBecomeBlocked cypress command * fix typo * feat(EMS-1696-1697): fix/update API unit test * feat(EMS-1696-1697): account reactivation - improve E2E test coverage * chore(tech): add missing async/await to UI unit test * update README * chore(deps): bump cypress * chore(tech): add delete account command to E2E test * feat(EMS-1696-1697): fix/update E2E test * feat(EMS-1696-1697): fix/update E2E test
- Loading branch information
Showing
53 changed files
with
1,199 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
e2e-tests/cypress/e2e/journeys/insurance/account/reactivated/account-reactivated.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { INSURANCE_ROUTES as ROUTES } from '../../../../../../constants/routes/insurance'; | ||
import { BUTTONS, PAGES } from '../../../../../../content-strings'; | ||
import reactivatedPage from '../../../../pages/insurance/account/reactivated'; | ||
import api from '../../../../../support/api'; | ||
|
||
const CONTENT_STRINGS = PAGES.INSURANCE.ACCOUNT.REACTIVATED; | ||
|
||
const { | ||
ACCOUNT: { | ||
SUSPENDED: { VERIFY_EMAIL }, | ||
REACTIVATED_ROOT, | ||
SIGN_IN: { | ||
ROOT: SIGN_IN_ROOT, | ||
}, | ||
}, | ||
} = ROUTES; | ||
|
||
const accountEmail = Cypress.env('GOV_NOTIFY_EMAIL_RECIPIENT_1'); | ||
|
||
context('Insurance - Account - Reactivated page', () => { | ||
const baseUrl = Cypress.config('baseUrl'); | ||
const accountReactivatedUrl = `${baseUrl}${REACTIVATED_ROOT}`; | ||
|
||
let account; | ||
|
||
before(() => { | ||
cy.createAnAccountAndBecomeBlocked({ startReactivationJourney: true }); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteAccount(); | ||
}); | ||
|
||
describe(`when visting ${VERIFY_EMAIL} with a valid token`, () => { | ||
before(() => { | ||
/** | ||
* Get the reactivation hash directly from the API, | ||
* so that we can navigate to the VERIFY_EMAIL URL with a valid token | ||
*/ | ||
api.getAccountByEmail(accountEmail).then((response) => { | ||
const { data } = response.body; | ||
|
||
const [firstAccount] = data.accounts; | ||
account = firstAccount; | ||
|
||
const verifyEmailUrl = `${baseUrl}${VERIFY_EMAIL}?token=${account.reactivationHash}`; | ||
|
||
cy.navigateToUrl(verifyEmailUrl); | ||
|
||
cy.assertUrl(accountReactivatedUrl); | ||
}); | ||
}); | ||
|
||
it('renders core page elements, `thank you` copy and a button link', () => { | ||
cy.corePageChecks({ | ||
pageTitle: CONTENT_STRINGS.PAGE_TITLE, | ||
currentHref: REACTIVATED_ROOT, | ||
assertBackLink: false, | ||
assertAuthenticatedHeader: false, | ||
assertSubmitButton: false, | ||
}); | ||
|
||
cy.checkText( | ||
reactivatedPage.thankYou(), | ||
CONTENT_STRINGS.THANK_YOU, | ||
); | ||
|
||
cy.checkLink( | ||
reactivatedPage.continue(), | ||
SIGN_IN_ROOT, | ||
BUTTONS.CONTINUE, | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...-in/sign-in-with-a-reactivated-account/account-sign-in-with-a-reactivated-account.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { INSURANCE_ROUTES as ROUTES } from '../../../../../../../constants/routes/insurance'; | ||
import reactivatedPage from '../../../../../pages/insurance/account/reactivated'; | ||
|
||
import api from '../../../../../../support/api'; | ||
|
||
const { | ||
ACCOUNT: { | ||
SUSPENDED: { VERIFY_EMAIL }, | ||
REACTIVATED_ROOT, | ||
SIGN_IN: { ENTER_CODE }, | ||
}, | ||
DASHBOARD, | ||
} = ROUTES; | ||
|
||
const accountEmail = Cypress.env('GOV_NOTIFY_EMAIL_RECIPIENT_1'); | ||
|
||
context('Insurance - Account - Sign in - after account has been blocked and reactivated', () => { | ||
const baseUrl = Cypress.config('baseUrl'); | ||
const accountReactivatedUrl = `${baseUrl}${REACTIVATED_ROOT}`; | ||
const enterCodeUrl = `${baseUrl}${ENTER_CODE}`; | ||
const dashboardUrl = `${baseUrl}${DASHBOARD}`; | ||
|
||
let account; | ||
|
||
before(() => { | ||
cy.createAnAccountAndBecomeBlocked({ startReactivationJourney: true }); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteAccount(); | ||
}); | ||
|
||
describe(`when visting ${VERIFY_EMAIL} with a valid token`, () => { | ||
before(() => { | ||
/** | ||
* Get the reactivation hash directly from the API, | ||
* so that we can navigate to the VERIFY_EMAIL URL with a valid token | ||
*/ | ||
api.getAccountByEmail(accountEmail).then((response) => { | ||
const { data } = response.body; | ||
|
||
const [firstAccount] = data.accounts; | ||
account = firstAccount; | ||
|
||
const verifyEmailUrl = `${baseUrl}${VERIFY_EMAIL}?token=${account.reactivationHash}`; | ||
|
||
cy.navigateToUrl(verifyEmailUrl); | ||
|
||
cy.assertUrl(accountReactivatedUrl); | ||
|
||
// click the "continue" link button in the reactivated page | ||
reactivatedPage.continue().click(); | ||
|
||
// submit the sign in form | ||
cy.completeAndSubmitSignInAccountForm({}); | ||
}); | ||
}); | ||
|
||
describe('when submitting the sign in form and entering a valid security code', () => { | ||
let validSecurityCode; | ||
|
||
before(() => { | ||
// create and get an OTP for the exporter's account | ||
cy.accountAddAndGetOTP().then((securityCode) => { | ||
validSecurityCode = securityCode; | ||
}); | ||
}); | ||
|
||
it(`should redirect to ${DASHBOARD}`, () => { | ||
cy.navigateToUrl(enterCodeUrl); | ||
|
||
cy.completeAndSubmitEnterCodeAccountForm(validSecurityCode); | ||
|
||
cy.assertUrl(dashboardUrl); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
.../journeys/insurance/account/suspended/link-expired/account-suspended-link-expired.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { INSURANCE_ROUTES as ROUTES } from '../../../../../../../constants/routes/insurance'; | ||
import { INSURANCE_FIELD_IDS } from '../../../../../../../constants/field-ids/insurance'; | ||
import { PAGES } from '../../../../../../../content-strings'; | ||
import api from '../../../../../../support/api'; | ||
|
||
const { | ||
ACCOUNT: { | ||
SUSPENDED: { | ||
VERIFY_EMAIL, | ||
VERIFY_EMAIL_LINK_EXPIRED, | ||
}, | ||
}, | ||
} = ROUTES; | ||
|
||
const { | ||
ACCOUNT: { REACTIVATION_EXPIRY, REACTIVATION_HASH }, | ||
} = INSURANCE_FIELD_IDS; | ||
|
||
const CONTENT_STRINGS = PAGES.INSURANCE.ACCOUNT.SUSPENDED.VERIFY_EMAIL_LINK_EXPIRED; | ||
|
||
context('Insurance - Account - Suspended - Verify email - Visit with an expired token query param', () => { | ||
const baseUrl = Cypress.config('baseUrl'); | ||
const verifyEmailUrl = `${baseUrl}${VERIFY_EMAIL}`; | ||
const verifyEmailLinkExpiredUrl = `${baseUrl}${VERIFY_EMAIL_LINK_EXPIRED}`; | ||
|
||
before(() => { | ||
cy.createAnAccountAndBecomeBlocked({ startReactivationJourney: true }); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteAccount(); | ||
}); | ||
|
||
describe(`when a reactivation token has expired and the useer navigates to ${VERIFY_EMAIL} with the expired token`, () => { | ||
let updatedAccount; | ||
|
||
beforeEach(async () => { | ||
/** | ||
* Get the account so that we can use the ID | ||
* to update the reactivation verification period. | ||
*/ | ||
const accountEmail = Cypress.env('GOV_NOTIFY_EMAIL_RECIPIENT_1'); | ||
|
||
const accountsResponse = await api.getAccountByEmail(accountEmail); | ||
|
||
const { data } = accountsResponse.body; | ||
|
||
const [firstAccount] = data.accounts; | ||
const account = firstAccount; | ||
|
||
/** | ||
* Update the account's reactivation expiry date via the API, | ||
* so that we can mimic missing the verification period. | ||
*/ | ||
const now = new Date(); | ||
|
||
const MS_PER_MINUTE = 60000; | ||
const oneMinuteAgo = new Date(now.getTime() - 1 * MS_PER_MINUTE); | ||
|
||
const updateObj = { | ||
[REACTIVATION_EXPIRY]: oneMinuteAgo, | ||
}; | ||
|
||
updatedAccount = await api.updateAccount(account.id, updateObj); | ||
}); | ||
|
||
it(`should redirect to ${VERIFY_EMAIL_LINK_EXPIRED} and render core page elements`, () => { | ||
cy.navigateToUrl(`${verifyEmailUrl}?token=${updatedAccount[REACTIVATION_HASH]}`); | ||
|
||
cy.assertUrl(verifyEmailLinkExpiredUrl); | ||
|
||
cy.corePageChecks({ | ||
pageTitle: CONTENT_STRINGS.PAGE_TITLE, | ||
currentHref: verifyEmailUrl, | ||
assertBackLink: false, | ||
assertAuthenticatedHeader: false, | ||
assertSubmitButton: false, | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.