Skip to content

Commit

Permalink
CIV-0000 - Add UI Hearing test to pipeline (#4887)
Browse files Browse the repository at this point in the history
* Tidy up new test code
* update config
* update codecept config file
* refactor due to slowness of AAT
---------

Co-authored-by: Harry H <[email protected]>
  • Loading branch information
douglasrice and HarryH96 authored Oct 11, 2024
1 parent 5fbe1c3 commit 9101144
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 63 deletions.
20 changes: 14 additions & 6 deletions e2e/api/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,12 +715,12 @@ module.exports = {
solicitorSetup(solicitor);

let defendantResponseData;

if (mpScenario !== 'ONE_V_TWO_TWO_LEGAL_REP') {
defendantResponseData = eventData['defendantResponses'][mpScenario](allocatedTrack);
} else {
defendantResponseData = eventData['defendantResponses'][mpScenario][solicitor](allocatedTrack);
}
console.log(defendantResponseData);

//Todo: Remove after fast track uplifts release
if(!await checkFastTrackUpliftsEnabled()) {
Expand Down Expand Up @@ -755,9 +755,16 @@ module.exports = {
deleteCaseFields('respondent1Witnesses');
deleteCaseFields('respondent1DetailsForClaimDetailsTab');
}

await validateEventPages(defendantResponseData, solicitor);

// need to add partyID back into respondent object
if (solicitor === 'solicitorOne'){
caseData.respondent1.partyID = caseData.respondent1Copy.partyID;
}
if (solicitor === 'solicitorTwo'){
caseData.respondent2.partyID = caseData.respondent2Copy.partyID;
}

await assertError('ConfirmDetails', defendantResponseData.invalid.ConfirmDetails.futureDateOfBirth,
'The date entered cannot be in the future');
await assertError('Experts', defendantResponseData.invalid.Experts.emptyDetails, 'Expert details required');
Expand All @@ -770,14 +777,14 @@ module.exports = {
'From Date should be less than To Date');
// In a 1v2 different solicitor case, when the first solicitor responds, civil service would not change the state
// to AWAITING_APPLICANT_INTENTION until the all solicitor response.
// console.log('Hearing>>>', caseData);
if (solicitor === 'solicitorOne') {
// when only one solicitor has responded in a 1v2 different solicitor case
await assertSubmittedEvent('AWAITING_RESPONDENT_ACKNOWLEDGEMENT', {
header: 'You have submitted the Defendant\'s defence',
body: 'Once the other defendant\'s legal representative has submitted their defence, we will send the '
+ 'claimant\'s legal representative a notification.'
});

await waitForFinishedBusinessProcess(caseId);
await assertCorrectEventsAreAvailableToUser(config.applicantSolicitorUser, 'AWAITING_RESPONDENT_ACKNOWLEDGEMENT');
await assertCorrectEventsAreAvailableToUser(config.defendantSolicitorUser, 'AWAITING_RESPONDENT_ACKNOWLEDGEMENT');
Expand Down Expand Up @@ -1404,13 +1411,11 @@ module.exports = {
// Functions
const validateEventPages = async (data, solicitor) => {
//transform the data
console.log('validateEventPages....');
for (let pageId of Object.keys(data.valid)) {
if (pageId === 'DefendantLitigationFriend' || pageId === 'DocumentUpload' || pageId === 'Upload' || pageId === 'DraftDirections'|| pageId === 'ApplicantDefenceResponseDocument' || pageId === 'DraftDirections' || pageId === 'FinalOrderPreview' || pageId === 'FixedRecoverableCosts') {
const document = await testingSupport.uploadDocument();
data = await updateCaseDataWithPlaceholders(data, document);
}
// data = await updateCaseDataWithPlaceholders(data);
await assertValidData(data, pageId, solicitor);
}
};
Expand All @@ -1420,7 +1425,9 @@ const assertValidData = async (data, pageId, solicitor) => {
let sdoR2Flag = await checkToggleEnabled(SDOR2);

const validDataForPage = data.valid[pageId];

caseData = {...caseData, ...validDataForPage};

caseData = adjustDataForSolicitor(solicitor, caseData);
const response = await apiRequest.validatePage(
eventName,
Expand Down Expand Up @@ -2029,7 +2036,7 @@ const isDifferentSolicitorForDefendantResponseOrExtensionDate = () => {
};

const adjustDataForSolicitor = (user, data) => {
let fixtureClone = cloneDeep(data);
let fixtureClone = cloneDeep(data);
if (mpScenario !== 'ONE_V_TWO_TWO_LEGAL_REP') {
delete fixtureClone['defendantSolicitorNotifyClaimOptions'];
}
Expand All @@ -2038,6 +2045,7 @@ const adjustDataForSolicitor = (user, data) => {
} else if (user === 'solicitorTwo') {
delete fixtureClone['respondent1ResponseDeadline'];
}

return fixtureClone;
};

Expand Down
5 changes: 3 additions & 2 deletions e2e/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ module.exports = {
url: 'http://localhost:5555'
},
url: {
// manageCase: process.env.URL || 'https://manage-case-wa-int.demo.platform.hmcts.net',
// manageCase: process.env.URL || 'https://manage-case-int.demo.platform.hmcts.net',
// //manageCase: process.env.URL || 'https://manage-case-wa-int.demo.platform.hmcts.net',
// authProviderApi: process.env.SERVICE_AUTH_PROVIDER_API_BASE_URL || 'http://rpe-service-auth-provider-demo.service.core-compute-demo.internal',
// ccdDataStore: process.env.CCD_DATA_STORE_URL || 'http://ccd-data-store-api-demo.service.core-compute-demo.internal',
// dmStore:process.env.DM_STORE_URL || 'http://dm-store-demo.service.core-compute-demo.internal',
// idamApi: process.env.IDAM_API_URL || 'https://idam-api.demo.platform.hmcts.net',
// civilService: process.env.CIVIL_SERVICE_URL || 'http://civil-service-demo.service.core-compute-demo.internal',
// // waTaskMgmtApi: process.env.WA_TASK_MGMT_URL || 'http://wa-task-management-api-demo.service.core-compute-demo.internal'
// waTaskMgmtApi: process.env.WA_TASK_MGMT_URL || 'http://wa-task-management-api-demo.service.core-compute-demo.internal'

// for preview
// manageCase: 'https://xui-civil-ccd-pr-3186.preview.platform.hmcts.net',
Expand Down
10 changes: 5 additions & 5 deletions e2e/pages/hearing/cancelHearing.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ module.exports = {
viewDetails: 'a[id^="link-view-details"]',
cancelEle: 'a[id^="link-cancel"]',
cancelOption: '#listerr',
cancellationRequestedText: 'Cancellation requested',
},

async clickCancelHearing() {
await I.waitForElement(this.fields.cancelEle);
await I.seeElement(this.fields.cancelEle);
await I.click(this.fields.cancelEle);
await I.clickHearingHyperLinkOrButton(this.fields.cancelEle);
await I.waitForText('Are you sure you want to cancel this hearing?');
await I.runAccessibilityTest();
await I.forceClick(this.fields.cancelOption);
await I.click('Continue');
await I.clickContinue();
},

async verifyHearingCancellation() {
await I.waitForText('Current and upcoming');
await I.runAccessibilityTest();
await I.see('CANCELLATION REQUESTED');
await I.see(this.fields.cancellationRequestedText.toUpperCase());
await I.dontSeeElement(this.fields.cancelEle);
await I.click(this.fields.viewDetails);
await I.waitForText('Cancellation requested');
await I.waitForText(this.fields.cancellationRequestedText);
}
};
33 changes: 17 additions & 16 deletions e2e/pages/hearing/requestHearing.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
fields: {
selectFacilities: '//input[@value="Laptop"]',
selectHearingStage: '#AAA7-DIS',
selectAttendanceType: '//input[@value="Telephone"]',
selectAttendanceType: '//input[@value="In Person"]',
partyChannel: '#partyChannel',
noOfAttendees: '#attendance-number',
hearingLocationEle: '//li[contains(@class, "location-selection")]',
Expand All @@ -17,6 +17,7 @@ module.exports = {
additionalInstructions: '#additionalInstructionsTextarea',
viewEle: 'a[id^="link-view-or-edit"]',
cancelEle: 'a[id^="link-cancel"]',
waitingToBeListedText: 'WAITING TO BE LISTED',
},

async openHearingTab() {
Expand All @@ -29,24 +30,24 @@ module.exports = {

}, urlBefore);
await I.waitForText('Current and upcoming');
await I.click('Request a hearing');
await I.clickHearingHyperLinkOrButton(locate('div > exui-case-hearings > div > a').withText('Request a hearing'));
await I.waitForText('Hearing requirements');
await I.runAccessibilityTest();
await I.click('Continue');
await I.clickContinue();
},

async selectAdditionalFacilities() {
await I.waitForText('Do you require any additional facilities?');
await I.click(this.fields.selectFacilities);
await I.runAccessibilityTest();
await I.click('Continue');
await I.clickContinue();
},

async selectHearingStage() {
await I.waitForText('What stage is this hearing at?');
await I.click(this.fields.selectHearingStage);
await I.runAccessibilityTest();
await I.click('Continue');
await I.clickContinue();
},

async selectParticipantAttendance() {
Expand All @@ -56,19 +57,19 @@ module.exports = {
let noOfIndividuals = await I.grabNumberOfVisibleElements('.party-row');

for (let i=0; i<noOfIndividuals; i++) {
await I.selectOption(`${this.fields.partyChannel}`+i, 'Telephone');
await I.selectOption(`${this.fields.partyChannel}`+i, 'In Person');
}

await I.clearField(this.fields.noOfAttendees);
await I.fillField(this.fields.noOfAttendees, '8');
await I.runAccessibilityTest();
await I.click('Continue');
await I.clickContinue();
},

async selectHearingVenues() {
await I.waitForText('What are the hearing venue details?');
await I.seeElement(this.fields.hearingLocationEle);
await I.click('Continue');
await I.waitForElement(this.fields.hearingLocationEle);
await I.clickContinue();
},

async selectJudges() {
Expand All @@ -78,36 +79,36 @@ module.exports = {
await I.click(this.fields.districtJudgeTypeEle);
await I.click(this.fields.deputyDistrictJudgeTypeEle);
await I.runAccessibilityTest();
await I.click('Continue');
await I.clickContinue();
},

async selectLengthDatePriority() {
await I.waitForText('Length of hearing');
await I.fillField(this.fields.hearingDuration, '2');
await I.runAccessibilityTest();
await I.click('Continue');
await I.clickContinue();
},

async enterAdditionalInstructions() {
await I.waitForText('Enter any additional instructions for the hearing');
await I.fillField(this.fields.additionalInstructions, 'Text generated by automation test');
await I.runAccessibilityTest();
await I.click('Continue');
await I.clickContinue();
},

async submitHearing() {
await I.waitForText('Check your answers before sending your request');
await I.click('Submit request');
await I.clickHearingHyperLinkOrButton('Submit request');
await I.waitForText('Hearing request submitted');
await I.runAccessibilityTest();
await I.click('view the status of this hearing in the hearings tab');
await I.waitForText('WAITING TO BE LISTED');
await I.clickHearingHyperLinkOrButton(locate('#content a').withText('view the status of this hearing in the hearings tab'));
await I.waitForText(this.fields.waitingToBeListedText);
await I.seeElement(this.fields.viewEle);
await I.seeElement(this.fields.cancelEle);
},

async verifyWaitingForHearingToBeListed() {
await I.waitForText('WAITING TO BE LISTED');
await I.waitForText(this.fields.waitingToBeListedText);
await I.seeElement(this.fields.viewEle);
await I.seeElement(this.fields.cancelEle);
}
Expand Down
88 changes: 55 additions & 33 deletions e2e/pages/hearing/updateHearing.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,84 @@ module.exports = {

fields: {
viewEle: 'a[id^="link-view-or-edit"]',
updateJudgeType: '#judgeTypes',
deputyDistrictJudgeTypeEle: '//input[@value="24"]',
updateHearingLength: '#hearingLength',
hearingDurationHours: '#durationhours',
amendReason: '#partyreq',
editHearingButton: '//*[@id="edit-hearing"]/button',
submitUpdateButton: '//*[@id="content"]/button',
additionFacilitiesLink: '#additionalFacilitiesRequired',
judgeTypesLink: '#judgeTypes',
selectFacilities: '//input[@value="Laptop"]',
districtJudgeTypeEle: '//input[@value="45"]',
hearingLengthLink: '#hearingLength',
hearingDurationHours: '#durationhours',
viewHearingText: 'View hearing',
editHearingText: 'Edit hearing',
originalJudgeListSummary: 'Deputy District Judge- Fee-Paid, District Judge',
updatedJudgeListSummary: 'Deputy District Judge- Fee-Paid',
originalHearingLengthHoursSummary: '2 Hours',
updatedHearingLengthHoursSummary: '3 Hours',
originalAdditionalFacilitiesSummary: 'Laptop',
amendedLabel: 'AMENDED',
updateRequestedLabel: 'UPDATE REQUESTED',
},

async clickOnUpdateHearing() {
await I.seeElement(this.fields.viewEle);
await I.click(this.fields.viewEle);
await I.waitForText('View or edit hearing');
async clickOnViewEditHearing() {
await I.waitForElement(this.fields.viewEle);
await I.clickHearingHyperLinkOrButton(this.fields.viewEle);
await I.runAccessibilityTest();
},

async clickOnEditHearing() {
await I.waitForText(this.fields.viewHearingText);
await I.clickHearingHyperLinkOrButton(this.fields.editHearingButton);
await I.waitForText(this.fields.editHearingText);
await I.runAccessibilityTest();
await I.see('WAITING TO BE LISTED');
},

async updateHearingValues() {
await I.see('District Judge, Deputy District Judge- Fee-Paid');
await I.click(this.fields.updateJudgeType);
await I.waitForText('Do you want a specific judge?');
await I.click(this.fields.deputyDistrictJudgeTypeEle);
await I.clickHearingHyperLinkOrButton(this.fields.additionFacilitiesLink);
await I.click(this.fields.selectFacilities);
await I.clickContinue();
await I.clickHearingHyperLinkOrButton(this.fields.judgeTypesLink);
await I.waitForText('Select all judge types that apply');
await I.click(this.fields.districtJudgeTypeEle);
await I.clickContinue();
await I.runAccessibilityTest();
await I.click('Continue');
await I.see('District Judge');
await I.dontSee('Deputy District Judge- Fee-Paid');
await I.see('AMENDED');
await I.see('2 Hours');
await I.click(this.fields.updateHearingLength);
await I.waitForText(this.fields.editHearingText);
await I.dontSee(this.fields.originalJudgeListSummary);
await I.see(this.fields.updatedJudgeListSummary);
await I.see(this.fields.amendedLabel);
await I.see(this.fields.originalHearingLengthHoursSummary);
await I.clickHearingHyperLinkOrButton(this.fields.hearingLengthLink);
await I.waitForText('Length of hearing');
await I.clearField(this.fields.hearingDurationHours);
await I.fillField(this.fields.hearingDurationHours, '3');
await I.click('Continue');
await I.see('3 Hours');
await I.dontSee('2 Hours');

await I.clickContinue();
await I.see(this.fields.updatedHearingLengthHoursSummary);
await I.dontSee(this.fields.originalHearingLengthHoursSummary);
await I.runAccessibilityTest();
},

async submitUpdatedHearing() {
await I.click('Submit updated request');
await I.clickHearingHyperLinkOrButton(this.fields.submitUpdateButton);
await I.waitForText('Provide a reason for changing this hearing');
await I.click(this.fields.amendReason);
await I.runAccessibilityTest();
await I.click('Submit change request');
await I.clickHearingHyperLinkOrButton(this.fields.submitUpdateButton);
await I.see('Hearing request submitted');
await I.click('view the status of this hearing in the hearings tab');
await I.clickHearingHyperLinkOrButton(locate('#content a').withText('view the status of this hearing in the hearings tab'));
await I.waitForText('Current and upcoming');
},

async verifyUpdatedHearingDetails() {
await I.see('UPDATE REQUESTED');
await I.click(this.fields.viewEle);
await I.waitForText('View or edit hearing');
await I.see('District Judge');
await I.dontSee('Deputy District Judge- Fee-Paid');
await I.see('3 Hours');
await I.dontSee('2 Hours');
await I.click('Back');
await I.waitForText(this.fields.updateRequestedLabel);
await this.clickOnViewEditHearing();
await I.see(this.fields.originalAdditionalFacilitiesSummary);
await I.dontSee(this.fields.originalJudgeListSummary);
await I.see(this.fields.updatedJudgeListSummary);
await I.see(this.fields.updatedHearingLengthHoursSummary);
await I.dontSee(this.fields.originalHearingLengthHoursSummary);
await I.clickHearingHyperLinkOrButton(locate('//*[@id="content"]/a').withText('Back'));
},

};
7 changes: 6 additions & 1 deletion e2e/steps_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,10 @@ module.exports = function () {
let urlBefore = await this.grabCurrentUrl();
await this.retryUntilUrlChanges(() => this.forceClick('Continue'), urlBefore);
},
async clickHearingHyperLinkOrButton(element) {
let urlBefore = await this.grabCurrentUrl();
await this.retryUntilUrlChanges(() => this.forceClick(element), urlBefore);
},

async getCaseId(){
console.log(`case created: ${caseId}`);
Expand Down Expand Up @@ -1247,7 +1251,8 @@ module.exports = function () {
async updateHearing() {
eventName = 'Update Hearing';
await this.triggerStepsWithScreenshot([
() => updateHearingPage.clickOnUpdateHearing(),
() => updateHearingPage.clickOnViewEditHearing(),
() => updateHearingPage.clickOnEditHearing(),
() => updateHearingPage.updateHearingValues(),
() => updateHearingPage.submitUpdatedHearing(),
() => updateHearingPage.verifyUpdatedHearingDetails()
Expand Down
Loading

0 comments on commit 9101144

Please sign in to comment.