Skip to content

Commit

Permalink
Merge pull request #3458 from UK-Export-Finance/chore/EMS-4097
Browse files Browse the repository at this point in the history
chore(EMS-4097): merge main-country-risk-logic into main
  • Loading branch information
ttbarnes authored Jan 7, 2025
2 parents 1f97104 + 8d465a7 commit b438d73
Show file tree
Hide file tree
Showing 97 changed files with 2,529 additions and 1,133 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ jobs:
'eligibility/cannot-apply/**/*.spec.js',
'eligibility/cannot-apply-multiple-risks/**/*.spec.js',
'eligibility/cannot-skip-flow/**/*.spec.js',
'eligibility/contract-too-short/**/*.spec.js',
'eligibility/change-your-answers/**/*.spec.js',
'eligibility/check-your-answers/**/*.spec.js',
'eligibility/companies-house/**/*.spec.js',
Expand All @@ -535,6 +534,7 @@ jobs:
'eligibility/member-of-a-group/**/*.spec.js',
'eligibility/no-companies-house-number/**/*.spec.js',
'eligibility/party-to-consortium/**/*.spec.js',
'eligibility/talk-to-an-export-finance-manager/**/*.spec.js',
'eligibility/total-value-insured/**/*.spec.js',
'eligibility/uk-goods-or-services/**/*.spec.js',
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const completeAboutGoodsOrServicesForm = ({
cy.clickYesRadioInput();

if (includeFinalDestination) {
cy.keyboardInput(autoCompleteField(FINAL_DESTINATION).input(), COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME);
cy.keyboardInput(autoCompleteField(FINAL_DESTINATION).input(), COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME);
}
} else {
cy.clickNoRadioInput();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { autoCompleteField } from '../../../pages/shared';
import { FIELD_IDS } from '../../../constants';
import { DZA } from '../../../fixtures/countries';
import { COUNTRY_QUOTE_SUPPORT } from '../../../fixtures/countries';

const FIELD_ID = FIELD_IDS.ELIGIBILITY.BUYER_COUNTRY;

const { ONLINE_SUPPORT_1 } = COUNTRY_QUOTE_SUPPORT;
/**
* completeAndSubmitBuyerCountryForm
* Complete and submit a buyer country form.
* @param {String} countryName to input - defaults to Algeria mock country
* @param {String} countryName to input - defaults to ONLINE_SUPPORT_1 mock country
*/
export const completeAndSubmitBuyerCountryForm = ({ countryName = DZA.NAME }) => {
export const completeAndSubmitBuyerCountryForm = ({ countryName = ONLINE_SUPPORT_1.NAME }) => {
cy.keyboardInput(autoCompleteField(FIELD_ID).input(), countryName);
const results = autoCompleteField(FIELD_ID).results();
results.first().click();
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/constants/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

export const API = {
CIS: {
RISK: {
ESRA_CLASSIFICATION: {
VERY_HIGH: 'Very High',
HIGH: 'High',
STANDARD: 'Standard Risk',
},
SHORT_TERM_COVER_AVAILABLE: {
SHORT_TERM_COVER: {
YES: 'Yes',
ILC: 'ILC Only',
CILC: 'CILC Only',
Expand Down
23 changes: 19 additions & 4 deletions e2e-tests/constants/external-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

export const EXTERNAL_API_DEFINITIONS = {
CIS: {
RISK: {
ESRA_CLASSIFICATION: {
VERY_HIGH: 'Very High',
HIGH: 'High',
STANDARD: 'Standard Risk',
NONE: 'None',
},
SHORT_TERM_COVER_AVAILABLE: {
SHORT_TERM_COVER: {
YES: 'Yes',
NO: 'No',
ILC: 'ILC Only',
Expand All @@ -20,8 +21,22 @@ export const EXTERNAL_API_DEFINITIONS = {
NO: 'N',
},
NO_COVER: 'Off cover',
INVALID_COUNTRIES: ['EC Market n/k', 'Non EC Market n/k', 'Non UK', 'Third Country', 'Eastern and Southern African Trade and Development Bank'],
INVALID_COUNTRIES: [
'CABEI',
'Cor Andino Fom',
'Eastern and Southern African Trade and Development Bank',
'EC Market n/k',
'Non EC Market n/k',
'Non UK',
'Third Country',
],
INVALID_CURRENCIES: ['Gold'],
COUNTRY_RATINGS: {
A: ['AAA', 'AA+', 'AA', 'AA-', 'A+', 'A', 'A-'],
B: ['BBB+', 'BBB', 'BBB-', 'BB+', 'BB', 'BB-', 'B+', 'B', 'B-'],
C: ['CCC+', 'CCC', 'CCC-', 'CC', 'C'],
D: ['D'],
},
},
COMPANIES_HOUSE: {
COMPANY_STATUS: {
Expand All @@ -32,7 +47,7 @@ export const EXTERNAL_API_DEFINITIONS = {

export const EXTERNAL_API_MAPPINGS = {
CIS: {
RISK: {
ESRA_CLASSIFICATION: {
VERY_HIGH: 'Very High',
HIGH: 'High',
STANDARD: 'Standard',
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/constants/routes/insurance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const INSURANCE_ROUTES = {
ELIGIBLE_TO_APPLY_ONLINE: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/eligible-to-apply-online`,
HAVE_AN_ACCOUNT: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/do-you-have-an-account`,
NEED_TO_START_AGAIN: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/need-to-start-again`,
CONTRACT_TOO_SHORT_EXIT: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/contract-too-short`,
TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/contract-too-short`,
PARTY_TO_CONSORTIUM: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/party-to-any-consortium`,
PARTY_TO_CONSORTIUM_CHANGE: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/party-to-any-consortium/change`,
MEMBER_OF_A_GROUP: `${INSURANCE_ROOT}${ELIGIBILITY_ROOT}/member-of-a-group`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const HAVE_AN_ACCOUNT = {
PAGE_TITLE: 'Do you have an account with us?',
};

export const CONTRACT_TOO_SHORT_EXIT = {
export const TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT = {
PAGE_TITLE: 'Talk to an export finance manager',
INTRO: "We do not normally offer short term cover for the country you've selected.",
CONTACT_EFM: {
Expand Down
16 changes: 8 additions & 8 deletions e2e-tests/fixtures/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const endDate = new Date(date.setMonth(date.getMonth() + 6)); // Add 6 mo

const application = {
ELIGIBILITY: {
buyerCountryIsoCode: COUNTRY_APPLICATION_SUPPORT.ONLINE.ISO_CODE,
buyerCountryIsoCode: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.ISO_CODE,
[COVER_PERIOD_ID]: COVER_PERIOD_CONSTANTS.LESS_THAN_2_YEARS.DB_ID,
[HAS_COMPANIES_HOUSE_NUMBER]: true,
[HAS_END_BUYER]: false,
Expand All @@ -111,7 +111,7 @@ const application = {
[IS_PARTY_TO_CONSORTIUM]: false,
[IS_MEMBER_OF_A_GROUP]: false,
},
[BUYER_COUNTRY]: COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME,
[BUYER_COUNTRY]: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME,
COMPANY: mockCompanies[COMPANIES_HOUSE_NUMBER],
YOUR_COMPANY: {
[DIFFERENT_TRADING_NAME]: 'Mock different trading name',
Expand Down Expand Up @@ -149,14 +149,14 @@ const application = {
},
REQUESTED_JOINTLY_INSURED_PARTY: {
[COMPANY_NAME]: 'Mock jointly insured company name',
[COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME,
[COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME,
[COMPANY_NUMBER]: 'Mock jointly insured company number',
},
EXPORT_CONTRACT: {
[AWARD_METHOD]: EXPORT_CONTRACT_AWARD_METHOD.OTHER.DB_ID,
[OTHER_AWARD_METHOD]: 'Mock other award method description',
[DESCRIPTION]: 'Mock description',
[FINAL_DESTINATION]: COUNTRY_APPLICATION_SUPPORT.ONLINE.ISO_CODE,
[FINAL_DESTINATION]: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.ISO_CODE,
HOW_WILL_YOU_GET_PAID: {
[PAYMENT_TERMS_DESCRIPTION]: mockAddress0,
},
Expand All @@ -166,7 +166,7 @@ const application = {
},
AGENT_DETAILS: {
[AGENT_NAME]: "Mock export contract agent name O'Neill",
[AGENT_COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME,
[AGENT_COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME,
[AGENT_FULL_ADDRESS]: mockAddress0,
},
AGENT_SERVICE: {
Expand All @@ -178,7 +178,7 @@ const application = {
[FIXED_SUM_AMOUNT]: '1500',
[FIXED_SUM_CURRENCY_CODE]: GBP_CURRENCY_CODE,
[METHOD]: AGENT_SERVICE_CHARGE.METHOD.FIXED_SUM,
[PAYABLE_COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME,
[PAYABLE_COUNTRY_CODE]: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME,
},
},
EXPORTER_BUSINESS: {
Expand All @@ -199,7 +199,7 @@ const application = {
BUYER: {
[COMPANY_OR_ORGANISATION_NAME]: 'Test name',
[ADDRESS]: 'Test address',
[COUNTRY]: COUNTRY_APPLICATION_SUPPORT.ONLINE.NAME,
[COUNTRY]: COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1.NAME,
[REGISTRATION_NUMBER]: '12345',
[WEBSITE]: WEBSITE_EXAMPLES.VALID,
[CONNECTION_WITH_BUYER]: FIELD_VALUES.NO,
Expand All @@ -223,6 +223,6 @@ const application = {
},
};

export const country = COUNTRY_APPLICATION_SUPPORT.ONLINE;
export const country = COUNTRY_APPLICATION_SUPPORT.ONLINE_SUPPORT_1;

export default application;
108 changes: 54 additions & 54 deletions e2e-tests/fixtures/countries.js
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
export const XAD = {
NAME: 'Abu Dhabi',
ISO_CODE: 'XAD',
export const AGO = {
NAME: 'Angola',
ISO_CODE: 'AGO',
};

export const ARG = {
NAME: 'Argentina',
ISO_CODE: 'AGO',
};

export const BRA = {
NAME: 'Brazil',
ISO_CODE: 'BRA',
};

export const DZA = {
NAME: 'Algeria',
ISO_CODE: 'DZA',
};

export const AGO = {
NAME: 'Angola',
ISO_CODE: 'AGO',
export const ERI = {
NAME: 'Eritrea',
ISO_CODE: 'ERI',
};

export const FRA = {
NAME: 'France',
ISO_CODE: 'FRA',
};

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

export const AFG = {
NAME: 'Afghanistan',
ISO_CODE: 'AFG',
export const IOT = {
NAME: 'British Indian Ocean Territory',
ISO_CODE: 'IOT',
};

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

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

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

export const MMR = {
NAME: 'Burma',
ISO_CODE: 'MMR',
};
const mockCountries = [DZA, FRA, AGO, GBR, XAD, BRA];

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

const NO_ONLINE_SUPPORT_1 = FRA;
const NO_ONLINE_SUPPORT_2 = AGO;
const NO_ONLINE_SUPPORT_3 = ARG;
const NO_ONLINE_SUPPORT_4 = TN;

const mockCountries = [XAD, AFG, DZA, AGO, AUS, BLR, BRA, MMR, FRA, RUS, GBR];
const NOT_SUPPORTED_1 = GBR;
const NOT_SUPPORTED_2 = ERI;
const NOT_SUPPORTED_3 = IOT;
const NOT_SUPPORTED_4 = NCL;

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

export const COUNTRY_QUOTE_SUPPORT = {
ONLINE: QUOTE_ONLINE,
BY_EMAIL: QUOTE_BY_EMAIL,
UNSUPPORTED: QUOTE_UNSUPPORTED,
ONLINE_SUPPORT_1,
NO_ONLINE_SUPPORT_1,
NOT_SUPPORTED_1,
};

/**
* COUNTRY_APPLICATION_SUPPORT
* Different types of country support for an application
*/
const {
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,
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,
ONLINE_SUPPORT_1,
NO_ONLINE_SUPPORT_1,
NO_ONLINE_SUPPORT_2,
NO_ONLINE_SUPPORT_3,
NO_ONLINE_SUPPORT_4,
NOT_SUPPORTED_1,
NOT_SUPPORTED_2,
NOT_SUPPORTED_3,
NOT_SUPPORTED_4,
};

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

const {
ELIGIBILITY: { TALK_TO_AN_EXPORT_FINANCE_MANAGER_EXIT },
} = INSURANCE_ROUTES;

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;

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',
() => {
beforeEach(() => {
cy.saveSession();

cy.completeAndSubmitEligibilityForms({ stopSubmittingAfter: 'companyDetails' });
});

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

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

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

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

0 comments on commit b438d73

Please sign in to comment.