Skip to content

Commit

Permalink
feat(EMS-2433): no PDF - Eligibility - No short term cover redirect (#…
Browse files Browse the repository at this point in the history
…2621)

* feat(EMS-2433): added redirect if noShortTermCover

* feat(EMS-2433): code and test fixes

* feat(EMS-2433): removed apply-offline, added correct mapping for cis countries and tests

* feat(EMS-2433): fixed failing test

* feat(EMS-2433): code and test fixes

* feat(EMS-2433): lint fix

* feat(EMS-2433): fixed failing tests

* feat(EMS-2433): removed cannot apply offline page

---------

Co-authored-by: Zain Kassam <zkassam@ukexportfinance.gov.uk>
  • Loading branch information
Zainzzkk and Zain Kassam authored Jul 2, 2024
1 parent 965e618 commit 1753a3a
Show file tree
Hide file tree
Showing 41 changed files with 564 additions and 701 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ jobs:
"declarations/how-your-data-will-be-used/**/*.spec.js",
"eligibility/*.spec.js",
"eligibility/buyer-country/**/*.spec.js",
"eligibility/cannot-apply/**/*.spec.js",
"eligibility/cannot-apply-multiple-risks/**/*.spec.js",
"eligibility/cannot-skip-flow/**/*.spec.js",
"eligibility/contract-too-short/**/*.spec.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { FIELD_IDS } from '../../../constants';

const FIELD_ID = FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY;

const baseUrl = Cypress.config('baseUrl');

/**
* enterCountryAndAssertExitPageUrlBuyerCountry
* can assert if url is correct after entering country that leads to exit page
* @param {String} country to input
* @param {String} url to check for exit page
*/
const enterCountryAndAssertExitPageUrlBuyerCountry = (country, url) => {
cy.autocompleteKeyboardInput(FIELD_ID, country);

cy.clickSubmitButton();

const expectedUrl = `${baseUrl}${url}`;

cy.assertUrl(expectedUrl);
};

export default enterCountryAndAssertExitPageUrlBuyerCountry;
1 change: 0 additions & 1 deletion e2e-tests/constants/routes/insurance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const INSURANCE_ROUTES = {
NEED_TO_START_AGAIN: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/need-to-start-again`,
CONTRACT_TOO_SHORT: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/contract-too-short`,
},
APPLY_OFFLINE: `${INSURANCE_ROOT}/apply-using-our-form`,
PAGE_NOT_FOUND: `${INSURANCE_ROOT}/page-not-found`,
NO_ACCESS_TO_APPLICATION: `${INSURANCE_ROOT}/no-access-to-application`,
NO_ACCESS_APPLICATION_SUBMITTED: `${INSURANCE_ROOT}/no-access-application-submitted`,
Expand Down
74 changes: 41 additions & 33 deletions e2e-tests/fixtures/countries.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,43 @@ export const BRA = {
ISO_CODE: 'BRA',
};

export const AFG = {
NAME: 'Afghanistan',
ISO_CODE: 'AFG',
};

export const AUS = {
NAME: 'Australia',
ISO_CODE: 'AUS',
};

export const BLR = {
NAME: 'Belarus',
ISO_CODE: 'BLR',
};

export const RUS = {
NAME: 'Russia',
ISO_CODE: 'RUS',
};

export const MMR = {
NAME: 'Burma',
ISO_CODE: 'MMR',
};

export const GBR = {
NAME: 'United Kingdom',
ISO_CODE: 'GBR',
};

const mockCountries = [
{
NAME: 'Abu Dhabi',
ISO_CODE: 'XAD',
},
{
NAME: 'Algeria',
ISO_CODE: 'DZA',
},
{
NAME: 'Angola',
ISO_CODE: 'AGO',
},
{
NAME: 'France',
ISO_CODE: 'FRA',
},
{
NAME: 'Brazil',
ISO_CODE: 'BRA',
},
{
NAME: 'United Kingdom',
ISO_CODE: 'GBR',
},
];
const mockCountries = [XAD, AFG, DZA, AGO, AUS, BLR, BRA, MMR, FRA, RUS, GBR];

/**
* COUNTRY_QUOTE_SUPPORT
* Different types of country support for a quote.
*/
const { 1: QUOTE_ONLINE, 2: QUOTE_BY_EMAIL, 3: QUOTE_UNSUPPORTED } = mockCountries;
const { 2: QUOTE_ONLINE, 3: QUOTE_BY_EMAIL, 8: QUOTE_UNSUPPORTED } = mockCountries;

export const COUNTRY_QUOTE_SUPPORT = {
ONLINE: QUOTE_ONLINE,
Expand All @@ -72,17 +72,25 @@ export const COUNTRY_QUOTE_SUPPORT = {
* Different types of country support for an application
*/
const {
1: APPLICATION_ONLINE,
2: APPLICATION_BY_EMAIL,
3: APPLICATION_OFFLINE,
5: APPLICATION_UNSUPPORTED,
2: APPLICATION_ONLINE,
3: APPLICATION_BY_EMAIL,
8: APPLICATION_NO_SHORT_TERM_COVER_1,
4: APPLICATION_NO_SHORT_TERM_COVER_2,
1: APPLICATION_UNSUPPORTED_1,
5: APPLICATION_UNSUPPORTED_2,
7: APPLICATION_UNSUPPORTED_3,
9: APPLICATION_UNSUPPORTED_4,
} = mockCountries;

export const COUNTRY_APPLICATION_SUPPORT = {
ONLINE: APPLICATION_ONLINE,
BY_EMAIL: APPLICATION_BY_EMAIL,
OFFLINE: APPLICATION_OFFLINE,
UNSUPPORTED: APPLICATION_UNSUPPORTED,
UNSUPPORTED_1: APPLICATION_UNSUPPORTED_1,
UNSUPPORTED_2: APPLICATION_UNSUPPORTED_2,
UNSUPPORTED_3: APPLICATION_UNSUPPORTED_3,
UNSUPPORTED_4: APPLICATION_UNSUPPORTED_4,
NO_SHORT_TERM_COVER_1: APPLICATION_NO_SHORT_TERM_COVER_1,
NO_SHORT_TERM_COVER_2: APPLICATION_NO_SHORT_TERM_COVER_2,
};

export default mockCountries;

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
import { COUNTRY_APPLICATION_SUPPORT } from '../../../../../../fixtures/countries';

const {
START,
ELIGIBILITY: { CONTRACT_TOO_SHORT },
} = INSURANCE_ROUTES;

const COUNTRY_NAME_1 = COUNTRY_APPLICATION_SUPPORT.NO_SHORT_TERM_COVER_1.NAME;
const COUNTRY_NAME_2 = COUNTRY_APPLICATION_SUPPORT.NO_SHORT_TERM_COVER_2.NAME;

context(
'Insurance - Buyer country page - As an exporter, I want to check if UKEF offer credit insurance policy for where my buyer is based - submit no short term country cover',
() => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(START);

cy.completeStartForm();
cy.completeCheckIfEligibleForm();
cy.completeExporterLocationForm();
cy.completeCompaniesHouseNumberForm();
cy.completeAndSubmitCompaniesHouseSearchForm({});
cy.completeEligibilityCompanyDetailsForm();
});

describe(COUNTRY_NAME_1, () => {
it(`redirects to ${CONTRACT_TOO_SHORT} exit page`, () => {
cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_1, CONTRACT_TOO_SHORT);
});
});

describe(COUNTRY_NAME_2, () => {
it(`redirects to ${CONTRACT_TOO_SHORT} exit page`, () => {
cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_2, CONTRACT_TOO_SHORT);
});
});
},
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';
import { COUNTRY_APPLICATION_SUPPORT } from '../../../../../../fixtures/countries';

const {
START,
ELIGIBILITY: { CANNOT_APPLY },
} = INSURANCE_ROUTES;

const COUNTRY_NAME_1 = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_1.NAME;
const COUNTRY_NAME_2 = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_2.NAME;
const COUNTRY_NAME_3 = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_3.NAME;
const COUNTRY_NAME_4 = COUNTRY_APPLICATION_SUPPORT.UNSUPPORTED_4.NAME;

const contextString = 'As an exporter I want to enter the country where my buyer is based So that I can ascertain if I can obtain UKEF Credit Insurance for the country where my buyer is based';

context(`Insurance - Buyer country page - ${contextString} - Unsupported countries`, () => {
beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(START);

cy.completeStartForm();
cy.completeCheckIfEligibleForm();
cy.completeExporterLocationForm();
cy.completeCompaniesHouseNumberForm();
cy.completeAndSubmitCompaniesHouseSearchForm({});
cy.completeEligibilityCompanyDetailsForm();
});

describe(COUNTRY_NAME_1, () => {
it(`redirects to ${CANNOT_APPLY} exit page`, () => {
cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_1, CANNOT_APPLY);
});
});

describe(COUNTRY_NAME_2, () => {
it(`redirects to ${CANNOT_APPLY} exit page`, () => {
cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_2, CANNOT_APPLY);
});
});

describe(COUNTRY_NAME_3, () => {
it(`redirects to ${CANNOT_APPLY} exit page`, () => {
cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_3, CANNOT_APPLY);
});
});

describe(COUNTRY_NAME_4, () => {
it(`redirects to ${CANNOT_APPLY} exit page`, () => {
cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_4, CANNOT_APPLY);
});
});
});
Loading

0 comments on commit 1753a3a

Please sign in to comment.