-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(EMS-3662): export contract - how was contract awarded - save and…
… back (#2892) * feat(EMS-3662): export contract - how was contract awarded - save and back * chore(EMS-3665): address todo comments * chore(docs): minor documentation improvements * feat(EMS-3662): export contract - how was contract awarded - save and back * feat(EMS-3662): fix/update e2e test * feat(EMS-3662): simplify e2e test
- Loading branch information
Showing
26 changed files
with
435 additions
and
121 deletions.
There are no files selected for viewing
65 changes: 15 additions & 50 deletions
65
e2e-tests/commands/insurance/complete-and-submit-how-was-the-contract-awarded-form.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
e2e-tests/commands/insurance/complete-how-was-the-contract-awarded-form.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { field, radios } from '../../pages/shared'; | ||
import { EXPORT_CONTRACT as EXPORT_CONTRACT_FIELD_IDS } from '../../constants/field-ids/insurance/export-contract'; | ||
import { EXPORT_CONTRACT_FIELDS as FIELDS } from '../../content-strings/fields/insurance'; | ||
import application from '../../fixtures/application'; | ||
|
||
const { | ||
HOW_WAS_THE_CONTRACT_AWARDED: { AWARD_METHOD, OTHER_AWARD_METHOD }, | ||
} = EXPORT_CONTRACT_FIELD_IDS; | ||
|
||
const { OPEN_TENDER, NEGOTIATED_CONTRACT, DIRECT_AWARD, COMPETITIVE_BIDDING, OTHER } = FIELDS.HOW_WAS_THE_CONTRACT_AWARDED[AWARD_METHOD].OPTIONS; | ||
|
||
/** | ||
* completeHowWasTheContractAwardedForm | ||
* Complete the "How was the contract awarded" form | ||
* @param {Boolean} openTender: Award method as OPEN_TENDER. Defaults to true | ||
* @param {Boolean} negotiatedContract: Award method as NEGOTIATED_CONTRACT. Defaults to false | ||
* @param {Boolean} directAward: Award method as DIRECT_AWARD. Defaults to false | ||
* @param {Boolean} competitiveBidding: Award method as COMPETITIVE_BIDDING. Defaults to false | ||
* @param {Boolean} otherMethod: Award method as OTHER. Defaults to false | ||
* @param {String} otherMethodText: OTHER award method text | ||
*/ | ||
const completeHowWasTheContractAwardedForm = ({ | ||
openTender = true, | ||
negotiatedContract = false, | ||
directAward = false, | ||
competitiveBidding = false, | ||
otherMethod = false, | ||
otherMethodText = application.EXPORT_CONTRACT[OTHER_AWARD_METHOD], | ||
}) => { | ||
let selector; | ||
|
||
if (openTender) { | ||
selector = radios(OPEN_TENDER.ID).option; | ||
} | ||
|
||
if (negotiatedContract) { | ||
selector = radios(NEGOTIATED_CONTRACT.ID).option; | ||
} | ||
|
||
if (directAward) { | ||
selector = radios(DIRECT_AWARD.ID).option; | ||
} | ||
|
||
if (competitiveBidding) { | ||
selector = radios(COMPETITIVE_BIDDING.ID).option; | ||
} | ||
|
||
if (otherMethod) { | ||
selector = radios(OTHER.ID).option; | ||
|
||
selector.label().click(); | ||
|
||
if (otherMethodText) { | ||
cy.keyboardInput(field(OTHER_AWARD_METHOD).input(), otherMethodText); | ||
} | ||
} | ||
|
||
selector.label().click(); | ||
}; | ||
|
||
export default completeHowWasTheContractAwardedForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...e/cypress/e2e/journeys/export-contract/how-was-the-contract-awarded/save-and-back.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance'; | ||
|
||
const { | ||
ROOT, | ||
EXPORT_CONTRACT: { HOW_WAS_THE_CONTRACT_AWARDED }, | ||
} = INSURANCE_ROUTES; | ||
|
||
const baseUrl = Cypress.config('baseUrl'); | ||
|
||
context('Insurance - Export contract - How was the contract awarded page - Save and go back', () => { | ||
let referenceNumber; | ||
let url; | ||
|
||
before(() => { | ||
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => { | ||
referenceNumber = refNumber; | ||
|
||
// go to the page we want to test. | ||
cy.startInsuranceExportContractSection({}); | ||
|
||
url = `${baseUrl}${ROOT}/${referenceNumber}${HOW_WAS_THE_CONTRACT_AWARDED}`; | ||
|
||
cy.assertUrl(url); | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.saveSession(); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteApplication(referenceNumber); | ||
}); | ||
|
||
describe('when submitting an empty form via `save and go back` button', () => { | ||
beforeEach(() => { | ||
cy.navigateToUrl(url); | ||
|
||
cy.clickSaveAndBackButton(); | ||
}); | ||
|
||
it('should redirect to `all sections`', () => { | ||
cy.assertAllSectionsUrl(referenceNumber); | ||
}); | ||
|
||
it('should retain the `export contract` task status as `not started yet`', () => { | ||
cy.checkTaskExportContractStatusIsNotStartedYet(); | ||
}); | ||
}); | ||
|
||
describe('when fields are partially completed', () => { | ||
beforeEach(() => { | ||
cy.navigateToUrl(url); | ||
}); | ||
|
||
it('should update the status of task `export contract` to `in progress`', () => { | ||
cy.completeHowWasTheContractAwardedForm({ | ||
otherMethod: true, | ||
otherMethodText: null, | ||
}); | ||
|
||
cy.clickSaveAndBackButton(); | ||
|
||
cy.assertAllSectionsUrl(referenceNumber); | ||
|
||
cy.checkTaskExportContractStatusIsInProgress(); | ||
}); | ||
|
||
describe('when going back to the page', () => { | ||
it('should have the submitted value', () => { | ||
cy.assertHowWasTheContractAwardedFieldValues({ | ||
otherMethodText: '', | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('when all fields are provided', () => { | ||
it('should retain the status of task `export contract` as `in progress`', () => { | ||
cy.navigateToUrl(url); | ||
|
||
cy.completeHowWasTheContractAwardedForm({ otherMethod: true }); | ||
|
||
cy.clickSaveAndBackButton(); | ||
|
||
cy.navigateToAllSectionsUrl(referenceNumber); | ||
|
||
cy.checkTaskExportContractStatusIsInProgress(); | ||
}); | ||
|
||
describe('when going back to the page', () => { | ||
it('should have the submitted values', () => { | ||
cy.navigateToAllSectionsUrl(referenceNumber); | ||
|
||
cy.startInsuranceExportContractSection({}); | ||
|
||
cy.assertHowWasTheContractAwardedFieldValues({ otherMethod: true }); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.