diff --git a/frontend/cypress/e2e/change-complaint-status-details-view.cy.ts b/frontend/cypress/e2e/change-complaint-status-details-view.cy.ts index 8c57f2430..788088293 100644 --- a/frontend/cypress/e2e/change-complaint-status-details-view.cy.ts +++ b/frontend/cypress/e2e/change-complaint-status-details-view.cy.ts @@ -12,10 +12,30 @@ describe("Complaint Change Status spec - Details View", () => { cy.kcLogout().kcLogin(); }); + function fillInAssessmentSection() { + let sectionParams = { + section: "ASSESSMENT", + checkboxes: ["#ASSESSRISK"], + officer: "TestAcct, ENV", + date: "01", + actionRequired: "Yes", + toastText: "Assessment has been updated", + }; + cy.get(".comp-outcome-report-complaint-assessment").then(function ($assessment) { + if ($assessment.find("#outcome-save-button").length) { + cy.fillInHWCSection(sectionParams).then(() => { + sectionParams.checkboxes = ["Assessed public safety risk"]; + cy.validateHWCSection(sectionParams); + }); + } + }); + } + Cypress._.times(complaintTypes.length, (index) => { it("Changes status of closeable complaint to open, closed, and back to open", () => { if ("#hwcr-tab".includes(complaintTypes[index])) { cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076", true); + fillInAssessmentSection(); } else { cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-006888", true); } diff --git a/frontend/cypress/e2e/hwcr-outcome-assessment.cy.ts b/frontend/cypress/e2e/hwcr-outcome-assessment.cy.ts index 7db270779..8f2a9bb13 100644 --- a/frontend/cypress/e2e/hwcr-outcome-assessment.cy.ts +++ b/frontend/cypress/e2e/hwcr-outcome-assessment.cy.ts @@ -24,19 +24,8 @@ describe("HWCR Outcome Assessments", () => { expect($error).to.contain.text("Required"); }); - //validate Action Required is required - cy.get("#action-required-div").find(".error-message").should("exist"); - - //validate officer is required - cy.get("#outcome-officer-div").find(".error-message").should("exist"); - - //validate the date is required - cy.get("#assessment-checkbox-div").find(".error-message").should("exist"); - - //validate the toast - cy.get(".Toastify__toast-body").then(($toast) => { - expect($toast).to.contain.text("Errors in form"); - }); + let inputs = ["#action-required-div", "#outcome-officer-div", "#assessment-checkbox-div"]; + cy.hasErrorMessage(inputs, "Errors in form"); } else { cy.log("Test was previously run. Skip the Test"); this.skip(); @@ -57,7 +46,7 @@ describe("HWCR Outcome Assessments", () => { let sectionParams = { section: "ASSESSMENT", checkboxes: ["#ASSESSRISK"], - officer: "Benson, Olivia", + officer: "TestAcct, ENV", date: "01", actionRequired: "Yes", toastText: "Assessment has been saved", @@ -124,7 +113,7 @@ describe("HWCR Outcome Assessments", () => { let sectionParams = { section: "ASSESSMENT", checkboxes: ["#ASSESSHIST"], - officer: "Peralta, Jake", + officer: "TestAcct, ENV", date: "01", actionRequired: "No", justification: "No public safety concern", diff --git a/frontend/cypress/e2e/hwcr-outcome-equipment.cy.ts b/frontend/cypress/e2e/hwcr-outcome-equipment.cy.ts index 7c3899e62..ab6daa477 100644 --- a/frontend/cypress/e2e/hwcr-outcome-equipment.cy.ts +++ b/frontend/cypress/e2e/hwcr-outcome-equipment.cy.ts @@ -8,7 +8,7 @@ describe("HWCR Outcome Equipment", () => { }); function deleteAllEquipments() { - cy.get(".comp-outcome-report-complaint-assessment").then(function ($equipment) { + cy.get(".comp-equipment-items").then(function ($equipment) { const isVisible = $equipment.find("#equipment-delete-button").is(":visible"); if (isVisible) { cy.get("#equipment-delete-button").click(); @@ -16,42 +16,32 @@ describe("HWCR Outcome Equipment", () => { deleteAllEquipments(); } }); + + cy.get(".comp-outcome-equipment").then(function ($equipment) { + cy.get("#outcome-report-add-equipment").click(); + }); } it("it requires valid user input", () => { - cy.get(".comp-outcome-report-button").then(function ($equipment) { - if ($equipment.find("#outcome-report-add-equipment").length > 0) { - deleteAllEquipments(); - cy.get("#outcome-report-add-equipment").click(); - } else { - cy.log("Test was previously run. Skip the Test"); - this.skip(); - } - }); - cy.get(".comp-outcome-report-complaint-assessment").then(function ($equipment) { + //Run before exery test in order to make re-runnable. + deleteAllEquipments(); + + cy.get(".comp-outcome-equipment").then(function ($equipment) { if ($equipment.find("#equipment-save-button").length) { cy.validateComplaint("23-032456", "Racoon"); //click Save Button cy.get("#equipment-save-button").click(); - //validate Equipment type is required - cy.get("#equipment-type-div").find(".error-message").should("exist"); - - //validate Address is required - cy.get("#equipment-address-container").find(".equipment-form-error-msg").should("exist"); - - //validate XY coordinates is required - cy.get("#equipment-x-coordinate-container").find(".equipment-form-error-msg").should("exist"); - cy.get("#equipment-y-coordinate-container").find(".equipment-form-error-msg").should("exist"); - - //validate the Set-by is required - cy.get("#equipment-officer-set-div").find(".error-message").should("exist"); - - // //validate the toast - cy.get(".Toastify__toast-body").then(($toast) => { - expect($toast).to.contain.text("Errors creating equipment"); - }); + //validate + let inputs = [ + "#equipment-type-div", + "#equipment-address-div", + "#equipment-coordinate-div", + "#equipment-coordinate-div", + "#equipment-officer-set-div", + ]; + cy.hasErrorMessage(inputs, "Errors creating equipment"); } else { cy.log("Test was previously run. Skip the Test"); this.skip(); @@ -60,20 +50,14 @@ describe("HWCR Outcome Equipment", () => { }); it("it can save equipment", () => { - cy.get(".comp-outcome-report-button").then(function ($equipment) { - if ($equipment.find("#outcome-report-add-equipment").length > 0) { - cy.get("#outcome-report-add-equipment").click(); - } else { - cy.log("Test was previously run. Skip the Test"); - this.skip(); - } - }); + //Run before exery test in order to make re-runnable. + deleteAllEquipments(); - cy.get(".comp-outcome-report-complaint-assessment").then(function ($equipment) { + cy.get(".comp-outcome-equipment").then(function ($equipment) { if ($equipment.find("#equipment-save-button").length) { let sectionParams = { section: "EQUIPMENT", - officer: "Benson, Olivia", + officer: "TestAcct, ENV", date: "01", toastText: "Equipment has been updated", equipmentType: "Bear snare", @@ -94,13 +78,13 @@ describe("HWCR Outcome Equipment", () => { it("it can edit an existing equipment", () => { cy.validateComplaint("23-032456", "Racoon"); - cy.get(".comp-outcome-report-complaint-assessment").then(function ($equipment) { + cy.get(".comp-outcome-equipment").then(function ($equipment) { if ($equipment.find("#equipment-edit-button").length) { cy.get("#equipment-edit-button").click(); let sectionParams = { section: "EQUIPMENT", - officer: "Nancy Drew", + officer: "TestAcct, ENV", date: "02", toastText: "Equipment has been updated", equipmentType: "Bear live trap", @@ -117,7 +101,7 @@ describe("HWCR Outcome Equipment", () => { }); it("it can delete an existing equipment", () => { - cy.get(".comp-outcome-report-complaint-assessment").then(function ($equipment) { + cy.get(".comp-outcome-equipment").then(function ($equipment) { if ($equipment.find("#equipment-delete-button").length) { cy.get("#equipment-delete-button").click(); cy.get(".modal-footer > .btn-primary").click(); diff --git a/frontend/cypress/e2e/hwcr-outcome-review.cy.ts b/frontend/cypress/e2e/hwcr-outcome-review.cy.ts index 85733bfc2..278894282 100644 --- a/frontend/cypress/e2e/hwcr-outcome-review.cy.ts +++ b/frontend/cypress/e2e/hwcr-outcome-review.cy.ts @@ -153,7 +153,7 @@ describe("HWCR File Review", () => { //validate the officer appeared cy.get("#file-review-officer-id").should(($div) => { - expect($div).to.contain.text("OfficerC&E Test Acct 1, ENV"); + expect($div).to.contain.text("OfficerCE Test Acct 1, ENV"); }); cy.get("#file-review-save-button").click(); diff --git a/frontend/cypress/support/commands.ts b/frontend/cypress/support/commands.ts index c8dc4fbf2..3d1f7ea66 100644 --- a/frontend/cypress/support/commands.ts +++ b/frontend/cypress/support/commands.ts @@ -127,6 +127,18 @@ Cypress.Commands.add("kcLogout", () => { }); }); +Cypress.Commands.add("hasErrorMessage", (inputs: Array, toastText: string) => { + //validate all the inputs + Cypress._.times(inputs.length, (index) => { + cy.get(inputs[index]).find(".error-message").should("exist"); + }); + + //validate the toast + cy.get(".Toastify__toast-body").then(($toast) => { + expect($toast).to.contain.text(toastText); + }); +}); + Cypress.Commands.add("applyRoles", (roles: Array) => { Cypress.log({ name: "Apply User Roles" }); const apiUrl = Cypress.env("css_api_url"); @@ -401,8 +413,8 @@ Cypress.Commands.add( if (section === "ASSESSMENT") { checkboxDiv = "#assessment-checkbox-div"; - officerDiv = "#outcome-officer-div"; - dateDiv = "#complaint-outcome-date-div"; + officerDiv = "#assessment-officer-div"; + dateDiv = "#assessment-date-div"; } else if (section === "EQUIPMENT") { officerDiv = "#equipment-officer-set-div"; dateDiv = "#equipment-date-set-div"; diff --git a/frontend/cypress/support/index.ts b/frontend/cypress/support/index.ts index 95061f8f3..6779480ff 100644 --- a/frontend/cypress/support/index.ts +++ b/frontend/cypress/support/index.ts @@ -30,6 +30,7 @@ declare namespace Cypress { validateComplaint(complaintIdentifier: string, species: string): Chainable; fillInHWCSection(section: HwcSection): Chainable; validateHWCSection(section: HwcSection): Chainable; + hasErrorMessage(inputs: Array, toastText: string): Chainable; applyRoles(roles: Array): Chainable; resetRoles(): Chainable; } diff --git a/frontend/src/app/components/containers/complaints/outcomes/hwcr-complaint-assessment.tsx b/frontend/src/app/components/containers/complaints/outcomes/hwcr-complaint-assessment.tsx index 302534980..03748df68 100644 --- a/frontend/src/app/components/containers/complaints/outcomes/hwcr-complaint-assessment.tsx +++ b/frontend/src/app/components/containers/complaints/outcomes/hwcr-complaint-assessment.tsx @@ -314,6 +314,7 @@ export const HWCRComplaintAssessment: FC = () => { {!editable && (
) : (
-
+
Action Required
{selectedActionRequired?.value}
-
+
Justification
{selectedJustification?.label || ""}
-
+
Actions
    @@ -480,10 +487,10 @@ export const HWCRComplaintAssessment: FC = () => {
    Officer
    - {selectedOfficer?.label ?? ""} + {selectedOfficer?.label ?? ""}
    -
    +
    Date
    {formatDate(`${selectedDate}`)}
    diff --git a/frontend/src/app/components/containers/complaints/outcomes/hwcr-equipment/equipment-form.tsx b/frontend/src/app/components/containers/complaints/outcomes/hwcr-equipment/equipment-form.tsx index 710173879..aa9a79b2b 100644 --- a/frontend/src/app/components/containers/complaints/outcomes/hwcr-equipment/equipment-form.tsx +++ b/frontend/src/app/components/containers/complaints/outcomes/hwcr-equipment/equipment-form.tsx @@ -375,7 +375,10 @@ export const EquipmentForm: FC = ({ equipment, assignedOffic
    {/* ADDRESS */} -
    +
    = ({ equipment, assignedOffic {/* COORDINATES */}
    Latitude / Longitude -
    +