Skip to content

Commit

Permalink
Merge branch 'release/lions-mane-jellyfish' into chore/dockerfile-upd…
Browse files Browse the repository at this point in the history
…ates
  • Loading branch information
afwilcox authored Oct 9, 2024
2 parents ec6b621 + 91c1b3b commit c3c601b
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 66 deletions.
20 changes: 20 additions & 0 deletions frontend/cypress/e2e/change-complaint-status-details-view.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
19 changes: 4 additions & 15 deletions frontend/cypress/e2e/hwcr-outcome-assessment.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
66 changes: 25 additions & 41 deletions frontend/cypress/e2e/hwcr-outcome-equipment.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,40 @@ 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();
cy.get(".modal-footer > .btn-primary").click();
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();
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/hwcr-outcome-review.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 14 additions & 2 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,18 @@ Cypress.Commands.add("kcLogout", () => {
});
});

Cypress.Commands.add("hasErrorMessage", (inputs: Array<string>, 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<string>) => {
Cypress.log({ name: "Apply User Roles" });
const apiUrl = Cypress.env("css_api_url");
Expand Down Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions frontend/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ declare namespace Cypress {
validateComplaint(complaintIdentifier: string, species: string): Chainable<void>;
fillInHWCSection(section: HwcSection): Chainable<void>;
validateHWCSection(section: HwcSection): Chainable<void>;
hasErrorMessage(inputs: Array<string>, toastText: string): Chainable<void>;
applyRoles(roles: Array<string>): Chainable<void>;
resetRoles(): Chainable<void>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export const HWCRComplaintAssessment: FC = () => {
{!editable && (
<div className="comp-details-section-header-actions">
<Button
id="assessment-edit-button"
variant="outline-primary"
size="sm"
onClick={toggleEdit}
Expand Down Expand Up @@ -452,17 +453,23 @@ export const HWCRComplaintAssessment: FC = () => {
</div>
) : (
<dl>
<div>
<div id="action-required-div">
<dt>Action Required</dt>
<dd>{selectedActionRequired?.value}</dd>
</div>
<div className={justificationLabelClass}>
<div
id="justification-div"
className={justificationLabelClass}
>
<dt>Justification</dt>
<dd>
<span>{selectedJustification?.label || ""}</span>
</dd>
</div>
<div className={assessmentDivClass}>
<div
id="assessment-checkbox-div"
className={assessmentDivClass}
>
<dt>Actions</dt>
<dd>
<ul>
Expand All @@ -480,10 +487,10 @@ export const HWCRComplaintAssessment: FC = () => {
<div>
<dt>Officer</dt>
<dd>
<span id="comp-review-required-officer">{selectedOfficer?.label ?? ""}</span>
<span id="assessment-officer-div">{selectedOfficer?.label ?? ""}</span>
</dd>
</div>
<div>
<div id="assessment-date-div">
<dt>Date</dt>
<dd>{formatDate(`${selectedDate}`)}</dd>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,10 @@ export const EquipmentForm: FC<EquipmentFormProps> = ({ equipment, assignedOffic
</div>

{/* ADDRESS */}
<div className="comp-details-form-row">
<div
id="equipment-address-div"
className="comp-details-form-row"
>
<label htmlFor="equipment-address">Address</label>
<div className="comp-details-input full-width">
<input
Expand Down Expand Up @@ -417,7 +420,10 @@ export const EquipmentForm: FC<EquipmentFormProps> = ({ equipment, assignedOffic
{/* COORDINATES */}
<fieldset className="comp-details-form-row">
<legend>Latitude / Longitude</legend>
<div className="comp-details-input full-width">
<div
id="equipment-coordinate-div"
className="comp-details-input full-width"
>
<div className="comp-lat-long-input">
<div>
<input
Expand Down

0 comments on commit c3c601b

Please sign in to comment.