-
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-289): add "buyer body" page/flow (#93)
* feat(EMS-289): add buyer body page/flow * tech(EMS-289): render specific descriptions in 'get a quote by email' exit page depending on the reason * feat(EMS-289): update/fix e2e tests
- Loading branch information
Showing
53 changed files
with
839 additions
and
114 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
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
61 changes: 61 additions & 0 deletions
61
e2e-tests/cypress/e2e/journeys/quote/buyer-body/buyer-body-answer-yes.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,61 @@ | ||
import { | ||
buyerBodyPage, | ||
getAQuoteByEmailPage, | ||
} from '../../../pages/quote'; | ||
import partials from '../../../partials'; | ||
import { PAGES } from '../../../../../content-strings'; | ||
import CONSTANTS from '../../../../../constants'; | ||
import { completeAndSubmitBuyerCountryForm } from '../../../../support/quote/forms'; | ||
|
||
const CONTENT_STRINGS = PAGES.BUYER_BODY_PAGE; | ||
const { ROUTES, FIELD_IDS } = CONSTANTS; | ||
|
||
context('Buyer body page - as an exporter, I want to check if I can get an EXIP online quote for my buyers country - submit `buyer is a government or public sector body`', () => { | ||
before(() => { | ||
cy.login(); | ||
completeAndSubmitBuyerCountryForm(); | ||
|
||
cy.url().should('include', ROUTES.QUOTE.BUYER_BODY); | ||
|
||
buyerBodyPage[FIELD_IDS.VALID_BUYER_BODY].yes().click(); | ||
buyerBodyPage.submitButton().click(); | ||
}); | ||
|
||
beforeEach(() => { | ||
Cypress.Cookies.preserveOnce('_csrf'); | ||
Cypress.Cookies.preserveOnce('connect.sid'); | ||
}); | ||
|
||
it('redirects to exit page', () => { | ||
cy.url().should('include', ROUTES.QUOTE.GET_A_QUOTE_BY_EMAIL); | ||
}); | ||
|
||
it('renders a back link with correct url', () => { | ||
partials.backLink().should('exist'); | ||
|
||
partials.backLink().should('have.attr', 'href', ROUTES.QUOTE.BUYER_BODY); | ||
}); | ||
|
||
it('renders a specific reason and description', () => { | ||
getAQuoteByEmailPage.reason().invoke('text').then((text) => { | ||
const expected = PAGES.GET_A_QUOTE_BY_EMAIL_PAGE.REASON.BUYER_BODY; | ||
|
||
expect(text.trim()).equal(expected); | ||
}); | ||
|
||
getAQuoteByEmailPage.description().invoke('text').then((text) => { | ||
const expected = PAGES.GET_A_QUOTE_BY_EMAIL_PAGE.REASON.BUYER_BODY_DESCRIPTION; | ||
|
||
expect(text.trim()).equal(expected); | ||
}); | ||
}); | ||
|
||
describe('navigating back to the buyer body page', () => { | ||
it('auto checks the previously submitted answer', () => { | ||
partials.backLink().click(); | ||
|
||
const yesRadio = buyerBodyPage[FIELD_IDS.VALID_BUYER_BODY].yesInput(); | ||
yesRadio.should('be.checked'); | ||
}); | ||
}); | ||
}); |
118 changes: 118 additions & 0 deletions
118
e2e-tests/cypress/e2e/journeys/quote/buyer-body/buyer-body.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,118 @@ | ||
import { buyerBodyPage } from '../../../pages/quote'; | ||
import partials from '../../../partials'; | ||
import { | ||
BUTTONS, | ||
ERROR_MESSAGES, | ||
FIELDS, | ||
LINKS, | ||
ORGANISATION, | ||
PAGES, | ||
} from '../../../../../content-strings'; | ||
import CONSTANTS from '../../../../../constants'; | ||
import { completeAndSubmitBuyerCountryForm } from '../../../../support/quote/forms'; | ||
|
||
const CONTENT_STRINGS = PAGES.BUYER_BODY_PAGE; | ||
const { ROUTES, FIELD_IDS } = CONSTANTS; | ||
|
||
context('Buyer body page - as an exporter, I want to check if I can get an EXIP online quote for my buyers country', () => { | ||
beforeEach(() => { | ||
cy.login(); | ||
completeAndSubmitBuyerCountryForm(); | ||
|
||
cy.url().should('include', ROUTES.QUOTE.BUYER_BODY); | ||
}); | ||
|
||
it('passes the audits', () => { | ||
cy.lighthouse({ | ||
accessibility: 100, | ||
performance: 80, | ||
'best-practices': 100, | ||
seo: 60, | ||
}); | ||
}); | ||
|
||
it('renders a phase banner', () => { | ||
cy.checkPhaseBanner(); | ||
}); | ||
|
||
it('renders a back link with correct url', () => { | ||
partials.backLink().should('exist'); | ||
partials.backLink().invoke('text').then((text) => { | ||
expect(text.trim()).equal(LINKS.BACK); | ||
}); | ||
|
||
const expected = `${Cypress.config('baseUrl')}${ROUTES.QUOTE.BUYER_COUNTRY}`; | ||
partials.backLink().should('have.attr', 'href', expected); | ||
}); | ||
|
||
it('renders a page title and heading', () => { | ||
const expectedPageTitle = `${CONTENT_STRINGS.PAGE_TITLE} - ${ORGANISATION}`; | ||
cy.title().should('eq', expectedPageTitle); | ||
|
||
buyerBodyPage.heading().invoke('text').then((text) => { | ||
expect(text.trim()).equal(CONTENT_STRINGS.HEADING); | ||
}); | ||
}); | ||
|
||
it('renders yes and no radio buttons', () => { | ||
const yesRadio = buyerBodyPage[FIELD_IDS.VALID_BUYER_BODY].yes(); | ||
yesRadio.should('exist'); | ||
|
||
yesRadio.invoke('text').then((text) => { | ||
expect(text.trim()).equal('Yes'); | ||
}); | ||
|
||
const noRadio = buyerBodyPage[FIELD_IDS.VALID_BUYER_BODY].no(); | ||
noRadio.should('exist'); | ||
|
||
noRadio.invoke('text').then((text) => { | ||
expect(text.trim()).equal('No'); | ||
}); | ||
}); | ||
|
||
it('renders a submit button', () => { | ||
const button = buyerBodyPage.submitButton(); | ||
button.should('exist'); | ||
|
||
button.invoke('text').then((text) => { | ||
expect(text.trim()).equal(BUTTONS.CONTINUE); | ||
}); | ||
}); | ||
|
||
describe('form submission', () => { | ||
describe('when submitting an empty form', () => { | ||
it('should render validation errors', () => { | ||
buyerBodyPage.submitButton().click(); | ||
|
||
partials.errorSummaryListItems().should('exist'); | ||
partials.errorSummaryListItems().should('have.length', 1); | ||
|
||
const expectedMessage = ERROR_MESSAGES[FIELD_IDS.VALID_BUYER_BODY]; | ||
|
||
partials.errorSummaryListItems().first().invoke('text').then((text) => { | ||
expect(text.trim()).equal(expectedMessage); | ||
}); | ||
|
||
buyerBodyPage[FIELD_IDS.VALID_BUYER_BODY].errorMessage().invoke('text').then((text) => { | ||
expect(text.trim()).includes(expectedMessage); | ||
}); | ||
}); | ||
|
||
it('should focus on input when clicking summary error message', () => { | ||
buyerBodyPage.submitButton().click(); | ||
|
||
partials.errorSummaryListItemLinks().eq(0).click(); | ||
buyerBodyPage[FIELD_IDS.VALID_BUYER_BODY].yesInput().should('have.focus'); | ||
}); | ||
}); | ||
|
||
describe('when submitting the answer as `no`', () => { | ||
it(`should redirect to ${ROUTES.QUOTE.COMPANY_BASED}`, () => { | ||
buyerBodyPage[FIELD_IDS.VALID_BUYER_BODY].no().click(); | ||
buyerBodyPage.submitButton().click(); | ||
|
||
cy.url().should('include', ROUTES.QUOTE.COMPANY_BASED); | ||
}); | ||
}); | ||
}); | ||
}); |
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
17 changes: 17 additions & 0 deletions
17
.../cypress/e2e/journeys/quote/cannot-skip-flow/navigate-to-buyer-body-page-directly.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,17 @@ | ||
import CONSTANTS from '../../../../../constants'; | ||
const { ROUTES } = CONSTANTS; | ||
|
||
context('Manually going to the `Buyer body` via URL page without completing the previous forms', () => { | ||
beforeEach(() => { | ||
cy.visit(ROUTES.QUOTE.BUYER_BODY, { | ||
auth: { | ||
username: Cypress.config('basicAuthKey'), | ||
password: Cypress.config('basicAuthSecret'), | ||
}, | ||
}); | ||
}); | ||
|
||
it('should redirect to the `need to start again` exit page', () => { | ||
cy.url().should('include', ROUTES.QUOTE.NEED_TO_START_AGAIN); | ||
}); | ||
}); |
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
Oops, something went wrong.