Skip to content

Commit

Permalink
fix(EMS-3755): fix failing e2e tests (#2949)
Browse files Browse the repository at this point in the history
* fix(EMS-3755): fixed failing e2e tests

* fix(EMS-3755): added to dockerfile

* fix(EMS-3755): fix updated link

* fix(EMS-3755): fix updated link

* fix(EMS-3755): fix updated link

* fix(EMS-3755): code fixes and added helpers

* fix(EMS-3755): fix typos

* fix(EMS-3755): code improvements

* fix(EMS-3755): revert package.json change

---------

Co-authored-by: Zain Kassam <zkassam@ukexportfinance.gov.uk>
  • Loading branch information
Zainzzkk and Zain Kassam authored Aug 16, 2024
1 parent b2d4e4f commit 994e19a
Show file tree
Hide file tree
Showing 33 changed files with 4,348 additions and 1,194 deletions.
23 changes: 14 additions & 9 deletions e2e-tests/commands/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ const queryStrings = {
}
`,
createApplications: () => gql`
mutation createApplications($data: [ApplicationCreateInput!]!) {
createApplications(data: $data) {
id
referenceNumber
mutation createManyApplications($accountId: String!, $count: Int!) {
createManyApplications(accountId: $accountId, count: $count) {
success
applications {
id
referenceNumber
}
}
}
`,
Expand Down Expand Up @@ -252,24 +255,26 @@ const createAnAbandonedApplication = (accountId, eligibilityAnswers, company, se
/**
* createApplications
* Create multiple applications
* @param {Array} Array of applications
* @param {String} Account id
* @param {Number} Count of applications to create
* @returns {Array} Created applications
*/
const createApplications = (applications) => {
const createApplications = (accountId, count) => {
try {
const responseBody = apollo
.query({
query: queryStrings.createApplications(),
variables: {
data: applications,
accountId,
count,
},
context: APOLLO_CONTEXT,
})
.then((response) => response.data.createApplications);
.then((response) => response.data.createManyApplications.applications);

return responseBody;
} catch (error) {
console.error(error);
console.error('Creating applications', error);

throw new Error('Creating applications', { error });
}
Expand Down
53 changes: 3 additions & 50 deletions e2e-tests/commands/insurance/create-applications.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,20 @@
import api from '../api';
import { APPLICATION } from '../../constants';

const { STATUS } = APPLICATION;

/**
* mockApplication
* Create a mock application
* @param {String} Account ID for the application owner
* @param {String} Buyer ID for the application
* @returns {Object} Application
*/
const mockApplication = (accountId, buyerId) => ({
referenceNumber: 123,
status: STATUS.IN_PROGRESS,
owner: {
connect: {
id: accountId,
},
},
buyer: {
connect: {
id: buyerId,
},
},
});

/**
* mockApplications
* Create an array of mock applications
* @param {String} Account ID for the application owner
* @param {Number} Amount of applications to create
* @returns {Array} Applications
*/
const mockApplications = (accountId, countryId, count) => {
const mocks = new Array(count).fill(mockApplication(accountId, countryId));

return mocks;
};

/**
* createApplications
* Create multiple applications directly via the API
* 1) Get a country
* 2) Create a buyer with country ID
* 3) Generate mock applications with owner and buyer relationships
* 4) Create applications
* Calls API with number of applications to create and accountId
* API handles application creation and data
* @param {String} Account ID for the application owner
* @param {Number} Amount of applications to create
* @returns {Array} Created applications
*/
const createApplications = (accountId, count) => {
if (accountId && count) {
try {
return api.getACountry().then((country) =>
api.createBuyer(country.id).then((buyer) => {
const applicationsData = mockApplications(accountId, buyer.id, count);

return api.createApplications(applicationsData).then((applications) => applications);
}),
);
return api.createApplications(accountId, count).then((applications) => applications);
} catch (error) {
console.error('Creating applications', error);

return error;
}
}
Expand Down
6 changes: 3 additions & 3 deletions e2e-tests/content-strings/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const LINKS = {
GIVE_FEEDBACK_LOWERCASE: 'give feedback',
SKIP_TO_MAIN_CONTENT: 'Skip to main content',
EXTERNAL: {
GUIDANCE: 'https://www.gov.uk/guidance/export-insurance-policy#eligibility',
BEFORE_YOU_START: 'https://www.gov.uk/guidance/get-a-quote-for-ukef-export-insurance',
GUIDANCE: 'https://www.gov.uk/guidance/credit-insurance-policy#eligibility',
BEFORE_YOU_START: 'https://www.gov.uk/guidance/get-a-quote-for-ukef-credit-insurance',
PRIVACY: 'https://www.gov.uk/government/publications/ukef-privacy-notice/ukef-privacy-notice--2',
FEEDBACK: 'https://forms.office.com/r/TacytrRCgJ',
RESEARCH: 'https://forms.office.com/pages/responsepage.aspx?id=jhOEgACUnkCm2ka1KB4LCkj8OKxLpCpDmTbrMyQ3j2JUOUFHNUc0QUhUOFdLNkJXWkRUS0wyMUZFNiQlQCN0PWcu',
Expand All @@ -24,7 +24,7 @@ export const LINKS = {
'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1075267/10489_UKEF_Export_Insurance_Proposal_Form_20220513-fillable.pdf',
NBI_FORM:
'https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/1041659/export-insurance-non-binding-indication-request-form_20170609.pdf',
FULL_APPLICATION: 'https://www.gov.uk/guidance/apply-for-ukef-export-insurance',
FULL_APPLICATION: 'https://www.gov.uk/guidance/apply-for-ukef-credit-insurance',
ABILITY_NET: 'https://mcmw.abilityNet.org.uk',
EQUALITY_ADVISORY_SERVICE: 'https://www.equalityadvisoryservice.com',
ACCESSIBILITY_GUIDLINES: 'https://www.w3.org/TR/WCAG21',
Expand Down
Loading

0 comments on commit 994e19a

Please sign in to comment.