Skip to content

Commit

Permalink
fix(EMS-4100): country risk logic - short term cover (#3465)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttbarnes authored Jan 9, 2025
1 parent ae06129 commit 09038c7
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 50 deletions.
8 changes: 4 additions & 4 deletions e2e-tests/fixtures/countries.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ const NO_ONLINE_SUPPORT_1 = AGO;
const NO_ONLINE_SUPPORT_2 = ARG;
const NO_ONLINE_SUPPORT_3 = BLZ;
const NO_ONLINE_SUPPORT_4 = TN;
const NO_ONLINE_SUPPORT_5 = IRL;
const NO_ONLINE_SUPPORT_6 = FRA;

const NOT_SUPPORTED_1 = GBR;
const NOT_SUPPORTED_2 = ERI;
const NOT_SUPPORTED_3 = IOT;
const NOT_SUPPORTED_4 = NCL;
const NOT_SUPPORTED_5 = IRL;
const NOT_SUPPORTED_6 = FRA;

/**
* COUNTRY_QUOTE_SUPPORT
Expand All @@ -99,12 +99,12 @@ export const COUNTRY_APPLICATION_SUPPORT = {
NO_ONLINE_SUPPORT_2,
NO_ONLINE_SUPPORT_3,
NO_ONLINE_SUPPORT_4,
NO_ONLINE_SUPPORT_5,
NO_ONLINE_SUPPORT_6,
NOT_SUPPORTED_1,
NOT_SUPPORTED_2,
NOT_SUPPORTED_3,
NOT_SUPPORTED_4,
NOT_SUPPORTED_5,
NOT_SUPPORTED_6,
};

export default mockCountries;
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const COUNTRY_NAME_1 = COUNTRY_APPLICATION_SUPPORT.NO_ONLINE_SUPPORT_1.NAME;
const COUNTRY_NAME_2 = COUNTRY_APPLICATION_SUPPORT.NO_ONLINE_SUPPORT_2.NAME;
const COUNTRY_NAME_3 = COUNTRY_APPLICATION_SUPPORT.NO_ONLINE_SUPPORT_3.NAME;
const COUNTRY_NAME_4 = COUNTRY_APPLICATION_SUPPORT.NO_ONLINE_SUPPORT_4.NAME;
const COUNTRY_NAME_5 = COUNTRY_APPLICATION_SUPPORT.NO_ONLINE_SUPPORT_5.NAME;
const COUNTRY_NAME_6 = COUNTRY_APPLICATION_SUPPORT.NO_ONLINE_SUPPORT_6.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 countries that have no online insurance support',
Expand Down Expand Up @@ -42,5 +44,17 @@ context(
cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_4, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT);
});
});

describe(COUNTRY_NAME_5, () => {
it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => {
cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_5, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT);
});
});

describe(COUNTRY_NAME_6, () => {
it(`should redirect to ${TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT} exit page`, () => {
cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_6, TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT);
});
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ const COUNTRY_NAME_1 = COUNTRY_APPLICATION_SUPPORT.NOT_SUPPORTED_1.NAME;
const COUNTRY_NAME_2 = COUNTRY_APPLICATION_SUPPORT.NOT_SUPPORTED_2.NAME;
const COUNTRY_NAME_3 = COUNTRY_APPLICATION_SUPPORT.NOT_SUPPORTED_3.NAME;
const COUNTRY_NAME_4 = COUNTRY_APPLICATION_SUPPORT.NOT_SUPPORTED_4.NAME;
const COUNTRY_NAME_5 = COUNTRY_APPLICATION_SUPPORT.NOT_SUPPORTED_5.NAME;
const COUNTRY_NAME_6 = COUNTRY_APPLICATION_SUPPORT.NOT_SUPPORTED_6.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 - submit countries that cannot apply';
Expand Down Expand Up @@ -45,16 +43,4 @@ context(`Insurance - Buyer country page - ${contextString} - Unsupported countri
cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_4, CANNOT_APPLY_EXIT);
});
});

describe(COUNTRY_NAME_5, () => {
it(`should redirect to ${CANNOT_APPLY_EXIT} exit page`, () => {
cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_5, CANNOT_APPLY_EXIT);
});
});

describe(COUNTRY_NAME_6, () => {
it(`should redirect to ${CANNOT_APPLY_EXIT} exit page`, () => {
cy.enterCountryAndAssertExitPageUrlBuyerCountry(COUNTRY_NAME_6, CANNOT_APPLY_EXIT);
});
});
});
19 changes: 11 additions & 8 deletions src/api/.keystone/config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {
CIS: {
COUNTRY_RATINGS,
ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH },
SHORT_TERM_COVER: { ILC, CILC },
SHORT_TERM_COVER: { ILC, CILC, NO },
},
} = EXTERNAL_API_DEFINITIONS;

Expand All @@ -20,14 +20,17 @@ const params = {
STANDARD: {
[ILC]: createMockParams(STANDARD, ILC),
[CILC]: createMockParams(STANDARD, CILC),
[NO]: createMockParams(STANDARD, NO),
},
HIGH: {
[ILC]: createMockParams(HIGH, ILC),
[CILC]: createMockParams(HIGH, CILC),
[NO]: createMockParams(HIGH, NO),
},
VERY_HIGH: {
[ILC]: createMockParams(VERY_HIGH, ILC),
[CILC]: createMockParams(VERY_HIGH, CILC),
[NO]: createMockParams(VERY_HIGH, NO),
},
};

Expand All @@ -48,6 +51,14 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-ra
expect(result).toEqual(true);
});
});

describe.each(params.STANDARD[NO])(`when the short term cover is ${NO}`, (countryObj) => {
it(`should return true for ${countryObj.countryRating}`, () => {
const result = aAndBRatingConditions(countryObj);

expect(result).toEqual(true);
});
});
});

describe(`when the ESRA classification is ${HIGH}`, () => {
Expand All @@ -66,6 +77,14 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-ra
expect(result).toEqual(true);
});
});

describe.each(params.HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => {
it(`should return true for ${countryObj.countryRating}`, () => {
const result = aAndBRatingConditions(countryObj);

expect(result).toEqual(true);
});
});
});

describe(`when the ESRA classification is ${VERY_HIGH}`, () => {
Expand All @@ -84,5 +103,13 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-ra
expect(result).toEqual(true);
});
});

describe.each(params.VERY_HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => {
it(`should return true for ${countryObj.countryRating}`, () => {
const result = aAndBRatingConditions(countryObj);

expect(result).toEqual(true);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {
CIS: {
COUNTRY_RATINGS,
ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH },
SHORT_TERM_COVER: { ILC, CILC },
SHORT_TERM_COVER: { ILC, CILC, NO },
},
} = EXTERNAL_API_DEFINITIONS;

Expand All @@ -20,14 +20,17 @@ const params = {
STANDARD: {
[ILC]: createMockParams(STANDARD, ILC),
[CILC]: createMockParams(STANDARD, CILC),
[NO]: createMockParams(STANDARD, NO),
},
HIGH: {
[ILC]: createMockParams(HIGH, ILC),
[CILC]: createMockParams(HIGH, CILC),
[NO]: createMockParams(HIGH, NO),
},
VERY_HIGH: {
[ILC]: createMockParams(VERY_HIGH, ILC),
[CILC]: createMockParams(VERY_HIGH, CILC),
[NO]: createMockParams(VERY_HIGH, NO),
},
};

Expand All @@ -48,6 +51,14 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-ra
expect(result).toEqual(true);
});
});

describe.each(params.STANDARD[NO])(`when the short term cover is ${NO}`, (countryObj) => {
it(`should return true for ${countryObj.countryRating}`, () => {
const result = aAndBRatingConditions(countryObj);

expect(result).toEqual(true);
});
});
});

describe(`when the ESRA classification is ${HIGH}`, () => {
Expand All @@ -66,6 +77,14 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-ra
expect(result).toEqual(true);
});
});

describe.each(params.HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => {
it(`should return true for ${countryObj.countryRating}`, () => {
const result = aAndBRatingConditions(countryObj);

expect(result).toEqual(true);
});
});
});

describe(`when the ESRA classification is ${VERY_HIGH}`, () => {
Expand All @@ -84,5 +103,13 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/a-and-b-ra
expect(result).toEqual(true);
});
});

describe.each(params.VERY_HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => {
it(`should return true for ${countryObj.countryRating}`, () => {
const result = aAndBRatingConditions(countryObj);

expect(result).toEqual(true);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const aAndBRatingConditions = ({ countryRating, esraClassification, shortTermCov
if (shortTermCover === CILC) {
return true;
}

if (shortTermCover === NO) {
return true;
}
}

if (esraClassification === NONE && shortTermCover === NO) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {
CIS: {
COUNTRY_RATINGS,
ESRA_CLASSIFICATION: { STANDARD, HIGH, VERY_HIGH },
SHORT_TERM_COVER: { YES, ILC, CILC, REFER, UNLISTED },
SHORT_TERM_COVER: { YES, ILC, CILC, NO, REFER, UNLISTED },
},
} = EXTERNAL_API_DEFINITIONS;

Expand All @@ -23,20 +23,23 @@ const params = {
[CILC]: createMockParams(STANDARD, CILC),
[REFER]: createMockParams(STANDARD, REFER),
[UNLISTED]: createMockParams(STANDARD, UNLISTED),
[NO]: createMockParams(STANDARD, NO),
},
HIGH: {
[YES]: createMockParams(HIGH, YES),
[ILC]: createMockParams(HIGH, ILC),
[CILC]: createMockParams(HIGH, CILC),
[REFER]: createMockParams(HIGH, REFER),
[UNLISTED]: createMockParams(HIGH, UNLISTED),
[NO]: createMockParams(HIGH, NO),
},
VERY_HIGH: {
[YES]: createMockParams(VERY_HIGH, YES),
[ILC]: createMockParams(VERY_HIGH, ILC),
[CILC]: createMockParams(VERY_HIGH, CILC),
[REFER]: createMockParams(VERY_HIGH, REFER),
[UNLISTED]: createMockParams(VERY_HIGH, UNLISTED),
[NO]: createMockParams(VERY_HIGH, NO),
},
};

Expand Down Expand Up @@ -81,6 +84,14 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-ra
expect(result).toEqual(true);
});
});

describe.each(params.STANDARD[NO])(`when the short term cover is ${NO}`, (countryObj) => {
it(`should return true for ${countryObj.countryRating}`, () => {
const result = cAndDRatingConditions(countryObj);

expect(result).toEqual(true);
});
});
});

describe(`when the ESRA classification is ${HIGH}`, () => {
Expand Down Expand Up @@ -123,6 +134,14 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-ra
expect(result).toEqual(true);
});
});

describe.each(params.HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => {
it(`should return true for ${countryObj.countryRating}`, () => {
const result = cAndDRatingConditions(countryObj);

expect(result).toEqual(true);
});
});
});

describe(`when the ESRA classification is ${VERY_HIGH}`, () => {
Expand Down Expand Up @@ -165,5 +184,13 @@ describe('helpers/map-CIS-countries/map-CIS-country/no-online-support/c-and-d-ra
expect(result).toEqual(true);
});
});

describe.each(params.VERY_HIGH[NO])(`when the short term cover is ${NO}`, (countryObj) => {
it(`should return true for ${countryObj.countryRating}`, () => {
const result = cAndDRatingConditions(countryObj);

expect(result).toEqual(true);
});
});
});
});
Loading

0 comments on commit 09038c7

Please sign in to comment.