Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(EMS-3662-3665): task list - export contract requirements, improve e2e test coverage #2885

Merged
merged 7 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

## [2.30.0](https://github.com/UK-Export-Finance/exip/compare/v2.29.0...v2.30.0) (2024-08-02)


### Features

* **EMS-3665:** export contract - how was contract awarded - data saving ([#2883](https://github.com/UK-Export-Finance/exip/issues/2883)) ([d91a5d9](https://github.com/UK-Export-Finance/exip/commit/d91a5d9b186209cc07311b6ed0eb53c3f8464287))
- **EMS-3665:** export contract - how was contract awarded - data saving ([#2883](https://github.com/UK-Export-Finance/exip/issues/2883)) ([d91a5d9](https://github.com/UK-Export-Finance/exip/commit/d91a5d9b186209cc07311b6ed0eb53c3f8464287))

## [2.29.0](https://github.com/UK-Export-Finance/exip/compare/v2.28.2...v2.29.0) (2024-08-01)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @param {Boolean} agentChargeMethodPercentage: Agent charge method is "percentage"
* @param {Boolean} alternativeCurrency: Should submit an "alternative currency". Defaults to false.
* @param {Boolean} attemptedPrivateMarketCover: Has attempted to insure through the private market
* @param {Boolean} contractAwardedOtherMethod: "How was the contract awarded" method as "other"
* @param {Boolean} finalDestinationKnown: "Final destination known"
* @param {Boolean} isUsingAgent: Exporter is using an agent
* @param {Boolean} submitCheckYourAnswers: Click export contract "check your answers" submit button
Expand All @@ -20,6 +21,7 @@ const completeExportContractSection = ({
agentChargeMethodPercentage = false,
alternativeCurrency = false,
attemptedPrivateMarketCover = false,
contractAwardedOtherMethod = false,
finalDestinationKnown,
isUsingAgent = false,
submitCheckYourAnswers = false,
Expand All @@ -28,7 +30,7 @@ const completeExportContractSection = ({
}) => {
cy.startInsuranceExportContractSection({ viaTaskList });

cy.completeAndSubmitHowWasTheContractAwardedForm({});
cy.completeAndSubmitHowWasTheContractAwardedForm({ otherMethod: contractAwardedOtherMethod });

cy.completeAndSubmitAboutGoodsOrServicesForm({ finalDestinationKnown });
cy.completeAndSubmitHowYouWillGetPaidForm({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const { POLICY_TYPE } = APPLICATION;
* @param {Boolean} attemptedPrivateMarketCover: Should submit "yes" to "attempted to insure through the private market" form.
* @param {Boolean} buyerOutstandingPayments: Exporter has outstanding payments with the buyer.
* @param {Boolean} buyerFailedToPayOnTime: Buyer has failed to pay the exporter on the time.
* @param {Boolean} contractAwardedOtherMethod: "How was the contract awarded" method as "other"
* @param {Boolean} differentPolicyContact: Should submit an application with a different policy contact to the owner.
* @param {Boolean} differentTradingName: Should submit "yes" to "have a different trading name" in the "company details" form.
* @param {Boolean} differentTradingAddress: Should submit "yes" to "trade from a different address" in the "company details" form.
Expand Down Expand Up @@ -49,6 +50,7 @@ const completePrepareApplicationMultiplePolicyType = ({
attemptedPrivateMarketCover = false,
buyerOutstandingPayments = false,
buyerFailedToPayOnTime = false,
contractAwardedOtherMethod = false,
differentPolicyContact = false,
differentTradingName = false,
differentTradingAddress = false,
Expand Down Expand Up @@ -110,6 +112,7 @@ const completePrepareApplicationMultiplePolicyType = ({
agentChargeMethodPercentage,
alternativeCurrency: alternativeCurrencyExportContract,
attemptedPrivateMarketCover,
contractAwardedOtherMethod,
finalDestinationKnown,
isUsingAgent,
submitCheckYourAnswers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const { POLICY_TYPE } = FIELD_VALUES;
* @param {Boolean} attemptedPrivateMarketCover: Should submit "yes" to "attempted to insure through the private market" form.
* @param {Boolean} buyerOutstandingPayments: Exporter has outstanding payments with the buyer.
* @param {Boolean} buyerFailedToPayOnTime: Buyer has failed to pay the exporter on the time.
* @param {Boolean} contractAwardedOtherMethod: "How was the contract awarded" method as "other"
* @param {Boolean} differentPolicyContact: Should submit an application with a different policy contact to the owner.
* @param {Boolean} differentTradingName: Should submit "yes" to "have a different trading name" in the "company details" form.
* @param {Boolean} differentTradingAddress: Should submit "yes" to "trade from a different address" in the "company details" form.
Expand All @@ -38,36 +39,37 @@ const { POLICY_TYPE } = FIELD_VALUES;
* @param {Boolean} usingBroker: Should submit "yes" or "no" to "using a broker".
*/
const completePrepareApplicationSinglePolicyType = ({
agentChargeMethodFixedSum = false,
agentChargeFixedSumAmount,
agentChargeMethodPercentage = false,
agentIsCharging = false,
alternativeCurrencyBuyer = false,
alternativeCurrencyExportContract = false,
alternativeCurrencyTurnover = false,
alternativeCurrencyPolicy = false,
attemptedPrivateMarketCover = false,
buyerOutstandingPayments = false,
buyerFailedToPayOnTime = false,
contractAwardedOtherMethod = false,
differentPolicyContact = false,
differentTradingName = false,
differentTradingAddress = false,
hasCreditControlProcess = false,
hasConnectionToBuyer = false,
exporterHasBuyerFinancialAccounts = false,
exporterHasTradedWithBuyer = false,
buyerOutstandingPayments = false,
buyerFailedToPayOnTime = false,
finalDestinationKnown = false,
fullyPopulatedBuyerTradingHistory = false,
hasCreditControlProcess = false,
hasConnectionToBuyer = false,
hasHadCreditInsuranceCoverWithBuyer = false,
exporterHasBuyerFinancialAccounts = false,
finalDestinationKnown = false,
usingBroker = false,
otherCompanyInvolved = false,
isAppointingLossPayee = false,
isUsingAgent = false,
lossPayeeIsLocatedInUK = false,
policyValueOverMvpMaximum = false,
differentPolicyContact = false,
needPreCreditPeriod = false,
otherCompanyInvolved = false,
policyValueOverMvpMaximum = false,
totalContractValueOverThreshold = false,
attemptedPrivateMarketCover = false,
isUsingAgent = false,
agentIsCharging = false,
agentChargeMethodFixedSum = false,
agentChargeFixedSumAmount,
agentChargeMethodPercentage = false,
submitCheckYourAnswers = true,
usingBroker = false,
}) => {
cy.completeBusinessSection({
differentTradingName,
Expand Down Expand Up @@ -110,6 +112,7 @@ const completePrepareApplicationSinglePolicyType = ({
agentChargeMethodPercentage,
alternativeCurrency: alternativeCurrencyExportContract,
attemptedPrivateMarketCover,
contractAwardedOtherMethod,
finalDestinationKnown,
isUsingAgent,
submitCheckYourAnswers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import completeSignInAndGoToApplication from './account/complete-sign-in-and-go-
* @param {Boolean} buyerOutstandingPayments: Exporter has outstanding payments with the buyer.
* @param {Boolean} buyerFailedToPayOnTime: Buyer has failed to pay the exporter on the time.
* @param {String} companyNumber: Company number/Companies house number
* @param {Boolean} contractAwardedOtherMethod: "How was the contract awarded" method as "other"
* @param {Boolean} createApplicationViaApi: Flag whether to create the application via API instead of going through the eligibility journey.
* @param {Boolean} differentPolicyContact: Should submit an application with a different policy contact to the owner.
* @param {Boolean} differentTradingName: Should submit "yes" to "have a different trading name" in the "company details" form.
Expand Down Expand Up @@ -54,6 +55,7 @@ const completeSignInAndSubmitAnApplication = ({
buyerFailedToPayOnTime = false,
createApplicationViaApi,
companyNumber,
contractAwardedOtherMethod = false,
differentPolicyContact = false,
differentTradingName = false,
differentTradingAddress = false,
Expand Down Expand Up @@ -92,6 +94,7 @@ const completeSignInAndSubmitAnApplication = ({
alternativeCurrencyPolicy,
buyerOutstandingPayments,
buyerFailedToPayOnTime,
contractAwardedOtherMethod,
differentPolicyContact,
differentTradingName,
differentTradingAddress,
Expand Down Expand Up @@ -123,6 +126,7 @@ const completeSignInAndSubmitAnApplication = ({
attemptedPrivateMarketCover,
buyerFailedToPayOnTime,
buyerOutstandingPayments,
contractAwardedOtherMethod,
differentPolicyContact,
differentTradingName,
differentTradingAddress,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { APPLICATION } from '../../../../../../../constants';

context('Insurance - submit an application - Multiple policy type, contract awarded with `other` method', () => {
let referenceNumber;

before(() => {
cy.completeSignInAndSubmitAnApplication({
contractAwardedOtherMethod: true,
policyType: APPLICATION.POLICY_TYPE.MULTIPLE,
}).then((refNumber) => {
referenceNumber = refNumber;
});
});

beforeEach(() => {
cy.saveSession();
});

after(() => {
cy.deleteApplication(referenceNumber);
});

it('should successfully submit the application and redirect to `application submitted`', () => {
cy.assertApplicationSubmittedUrl(referenceNumber);
});

it('should render in a `submitted` state in the dashboard', () => {
cy.assertDashboardApplicationSubmitted(referenceNumber);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ context('Insurance - submit an application - Multiple policy type, fully populat
agentIsCharging: true,
agentChargeMethodFixedSum: true,
attemptedPrivateMarketCover: true,
contractAwardedOtherMethod: true,
isUsingAgent: true,
finalDestinationKnown: true,
policyType: APPLICATION.POLICY_TYPE.MULTIPLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ context(
lossPayeeIsLocatedInUK: true,
totalContractValueOverThreshold: true,
attemptedPrivateMarketCover: true,
contractAwardedOtherMethod: true,
isUsingAgent: true,
agentIsCharging: true,
agentChargeMethodFixedSum: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
context('Insurance - submit an application - Single policy type, contract awarded with `other` method', () => {
let referenceNumber;

before(() => {
cy.completeSignInAndSubmitAnApplication({ contractAwardedOtherMethod: true }).then((refNumber) => {
referenceNumber = refNumber;
});
});

beforeEach(() => {
cy.saveSession();
});

after(() => {
cy.deleteApplication(referenceNumber);
});

it('should successfully submit the application and redirect to `application submitted`', () => {
cy.assertApplicationSubmittedUrl(referenceNumber);
});

it('should render in a `submitted` state in the dashboard', () => {
cy.assertDashboardApplicationSubmitted(referenceNumber);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ context('Insurance - submit an application - Single policy type, fully populated
agentIsCharging: true,
agentChargeMethodFixedSum: true,
attemptedPrivateMarketCover: true,
contractAwardedOtherMethod: true,
isUsingAgent: true,
finalDestinationKnown: true,
totalContractValueOverThreshold: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
context('Insurance - submit an application - Single policy type, using an agent, fixed sum method, alternative currency', () => {
context('Insurance - submit an application - Single policy type, using an agent, fixed sum method, alternative currency', () => {
let referenceNumber;

before(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ context(
lossPayeeIsLocatedInUK: true,
totalContractValueOverThreshold: true,
attemptedPrivateMarketCover: true,
contractAwardedOtherMethod: true,
isUsingAgent: true,
agentIsCharging: true,
agentChargeMethodFixedSum: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ context('Insurance - Export contract - About goods or services page - Save and g
cy.assertAllSectionsUrl(referenceNumber);
});

it('should retain the `export contract` task status as `not started`', () => {
cy.checkTaskExportContractStatusIsNotStartedYet();
it('should retain the `export contract` task status as `in progress`', () => {
cy.checkTaskExportContractStatusIsInProgress();
});
});

Expand All @@ -71,7 +71,7 @@ context('Insurance - Export contract - About goods or services page - Save and g
cy.assertAllSectionsUrl(referenceNumber);
});

it('should update the `export contract` task status to `in progress`', () => {
it('should retain the `export contract` task status as `in progress`', () => {
cy.checkTaskExportContractStatusIsInProgress();
});

Expand Down Expand Up @@ -112,8 +112,8 @@ context('Insurance - Export contract - About goods or services page - Save and g
cy.assertAllSectionsUrl(referenceNumber);
});

it('should update the `export contract` task status to `not started`', () => {
cy.checkTaskExportContractStatusIsNotStartedYet();
it('should retain the `export contract` task status as `in progress`', () => {
cy.checkTaskExportContractStatusIsInProgress();
});

it(`should have no value in '${FIELD_ID}' when going back to the page`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('controllers/insurance/all-sections', () => {
const { buyerTradingHistory, relationship } = buyer;
const { exporterIsConnectedWithBuyer, exporterHasPreviousCreditInsuranceWithBuyer } = relationship;
const { outstandingPayments, exporterHasTradedWithBuyer } = buyerTradingHistory;
const { awardMethod } = exportContract;

const flatApplicationData = flattenApplicationData(mockApplication);

Expand All @@ -83,6 +84,7 @@ describe('controllers/insurance/all-sections', () => {
isUsingAgent,
agentIsCharging,
agentChargeMethod,
awardMethod?.id,
);

const expectedTaskListData = generateTaskList(taskListStructure, flatApplicationData);
Expand Down
2 changes: 2 additions & 0 deletions src/ui/server/controllers/insurance/all-sections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const get = (req: Request, res: Response) => {
const { buyerTradingHistory, relationship } = buyer;
const { exporterIsConnectedWithBuyer, exporterHasPreviousCreditInsuranceWithBuyer } = relationship;
const { outstandingPayments, exporterHasTradedWithBuyer } = buyerTradingHistory;
const { awardMethod } = exportContract;

const flatApplicationData = flattenApplicationData(application);

Expand All @@ -76,6 +77,7 @@ export const get = (req: Request, res: Response) => {
isUsingAgent,
agentIsCharging,
agentChargeMethod,
awardMethod?.id,
);

const taskListData = generateTaskList(taskListStructure, flatApplicationData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const {
charge: { method: agentChargeMethod },
},
},
awardMethod,
} = exportContract;

describe('controllers/insurance/check-your-answers/export-contract', () => {
Expand Down Expand Up @@ -102,6 +103,7 @@ describe('controllers/insurance/check-your-answers/export-contract', () => {
isUsingAgent,
agentIsCharging,
agentChargeMethod,
awardMethodId: awardMethod?.id,
});

const status = sectionStatus(exportContractFields, mockApplication);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const get = async (req: Request, res: Response) => {
charge: { method: agentChargeMethod },
},
},
awardMethod,
} = exportContract;

const checkAndChange = true;
Expand All @@ -75,6 +76,7 @@ export const get = async (req: Request, res: Response) => {
isUsingAgent,
agentIsCharging,
agentChargeMethod,
awardMethodId: awardMethod?.id,
});

const status = sectionStatus(exportContractFields, application);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ const applicationByReferenceNumberQuery = gql`
}
exportContract {
id
awardMethod {
id
value
}
otherAwardMethod
goodsOrServicesDescription
finalDestinationKnown
finalDestinationCountryCode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Application } from '../../../types';
* Check if an application has submitted previous fields/sections required before accessing the "submit your application" group/sections/routes.
* The "submit your application" group includes all routes for "check your answers" and "declarations".
* @param {Application}
* @param {String} Current URL
* @returns {Boolean}
*/
const canAccessSubmitYourApplicationRoutes = (application: Application) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ describe('server/helpers/flatten-application-data', () => {
...contact,
...getTrueAndFalseAnswers(declaration),
...exportContract,
...exportContract.awardMethod,
...getTrueAndFalseAnswers(exportContract),
...exportContract.privateMarket,
...getTrueAndFalseAnswers(exportContract.privateMarket),
Expand Down
1 change: 1 addition & 0 deletions src/ui/server/helpers/flatten-application-data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const flattenApplicationData = (application: Application): ApplicationFlat => {
...company,
...contact,
...exportContract,
...exportContract.awardMethod,
...getTrueAndFalseAnswers(exportContract),
...exportContract.privateMarket,
...getTrueAndFalseAnswers(exportContract.privateMarket),
Expand Down
Loading
Loading