Skip to content

Commit

Permalink
feat: CE-517 closing complaint criteria (#455)
Browse files Browse the repository at this point in the history
Co-authored-by: afwilcox <[email protected]>
  • Loading branch information
Scarlett-Truong and afwilcox authored Jun 14, 2024
1 parent dc6a460 commit b9b192a
Show file tree
Hide file tree
Showing 26 changed files with 1,212 additions and 859 deletions.
21 changes: 20 additions & 1 deletion frontend/cypress/e2e/change-complaint-status-details-view.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("Complaint Change Status spec - Details View", () => {
});

Cypress._.times(complaintTypes.length, (index) => {
it("Changes status of complaint to open, closed, and back to open", () => {
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);
} else {
Expand Down Expand Up @@ -47,4 +47,23 @@ describe("Complaint Change Status spec - Details View", () => {
cy.get("#comp-details-status-text-id").contains("Open").should("exist");
});
});

it("Changes status of unclosable hwcr complaint from open to closed", () => {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000078", true);

cy.get("#details-screen-update-status-button").click({ force: true });

cy.get("#complaint_status_dropdown").click();

// Select the option with value "Closed"
cy.get(".comp-select__option").contains("Closed").click();

cy.get("#update_complaint_status_button").click();

//validate error message
cy.get("#outcome-assessment").find(".section-error-message").should("exist");
cy.get(".section-error-message").should(($error) => {
expect($error).to.contain.text("Complete section before closing the complaint.");
});
});
});
3 changes: 2 additions & 1 deletion frontend/cypress/e2e/change-complaint-status.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ describe("Complaint Assign and Status Popover spec", { scrollBehavior: false },
});

Cypress._.times(complaintTypes.length, (index) => {
it("Changes status of open complaint to closed and back to open", () => {
//Skip this test as users are not allowed to close complaints from the list view for now
it.skip("Changes status of open complaint to closed and back to open", () => {
cy.visit("/");

//Need to make sure the filters are loaded before switching tabs.
Expand Down
1 change: 0 additions & 1 deletion frontend/cypress/e2e/complaint-search.v2.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ describe("Complaint Search Functionality", () => {
cy.get("#multi-point-map")
.find("div.leaflet-marker-icon")
.should(({ length }) => {
console.log(length);
expect(length).to.eq(5);
});
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/hwcr-outcomes-attachments.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ describe("Display HWCR Outcome Attachments", () => {
it("outcomes attachments is displayed", () => {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076", true);

cy.verifyAttachmentsCarousel(true, "outcome_attachments_div_id");
cy.verifyAttachmentsCarousel(true, "outcome-attachments");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -86,47 +86,49 @@ export const ComplaintActionItems: FC<Props> = ({
></i>
</Button>
</OverlayTrigger>
<OverlayTrigger
placement="top"
key={`tt-update-${complaint_identifier}`}
overlay={
<Tooltip
id={`tt-update-${complaint_identifier}`}
className="comp-tooltip"
>
Update Status
</Tooltip>
}
>
<Button
variant="light"
className="icon-btn"
aria-label="Update status"
onClick={openStatusChangeModal}
>
<i
className="bi bi-arrow-repeat"
id="update-status-icon"
></i>
</Button>
</OverlayTrigger>
{config.SHOW_EXPERIMENTAL_FEATURES === "true" && (
<OverlayTrigger
placement="top"
key={`tt-refer-${complaint_identifier}`}
overlay={
<Tooltip
id="tt-refer"
className="comp-tooltip"
<>
<OverlayTrigger
placement="top"
key={`tt-update-${complaint_identifier}`}
overlay={
<Tooltip
id={`tt-update-${complaint_identifier}`}
className="comp-tooltip"
>
Update Status
</Tooltip>
}
>
<Button
variant="light"
className="icon-btn"
aria-label="Update status"
onClick={openStatusChangeModal}
>
Refer
</Tooltip>
}
>
<span>
<BsSend className="comp-table-row-hover-icons comp-table-icon comp-table-icon-weighted" />
</span>
</OverlayTrigger>
<i
className="bi bi-arrow-repeat"
id="update-status-icon"
></i>
</Button>
</OverlayTrigger>
<OverlayTrigger
placement="top"
key={`tt-refer-${complaint_identifier}`}
overlay={
<Tooltip
id="tt-refer"
className="comp-tooltip"
>
Refer
</Tooltip>
}
>
<span>
<BsSend className="comp-table-row-hover-icons comp-table-icon comp-table-icon-weighted" />
</span>
</OverlayTrigger>
</>
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import { useParams } from "react-router-dom";
import { formatDate, getAvatarInitials, getSelectedOfficer } from "../../../../common/methods";
import { CompSelect } from "../../../common/comp-select";
import { ValidationCheckboxGroup } from "../../../../common/validation-checkbox-group";
import { resetAssessment } from "../../../../store/reducers/cases";
import { resetAssessment, setIsInEdit } from "../../../../store/reducers/cases";
import { openModal } from "../../../../store/reducers/app";
import { CANCEL_CONFIRM } from "../../../../types/modal/modal-types";
import { ToggleError } from "../../../../common/toast";
import "react-toastify/dist/ReactToastify.css";
import { Assessment } from "../../../../types/outcomes/assessment";
import { ValidationDatePicker } from "../../../../common/validation-date-picker";
import { BsPencil } from "react-icons/bs";
import { BsPencil, BsExclamationCircleFill } from "react-icons/bs";
import { CompTextIconButton } from "../../../common/comp-text-icon-button";

import "../../../../../assets/sass/hwcr-assessment.scss";
Expand Down Expand Up @@ -63,6 +63,16 @@ export const HWCRComplaintAssessment: FC = () => {
const { id = "", complaintType = "" } = useParams<ComplaintParams>();
const { ownedByAgencyCode } = useAppSelector(selectComplaintCallerInformation);
const officersInAgencyList = useAppSelector(selectOfficersByAgency(ownedByAgencyCode?.agency));
const cases = useAppSelector((state) => state.cases);

const hasAssessment = Object.keys(cases.assessment).length > 0;
const showSectionErrors = (!hasAssessment || editable) && cases.isInEdit.showSectionErrors;

useEffect(() => {
if (!hasAssessment && editable) {
dispatch(setIsInEdit({ assessment: false }));
} else dispatch(setIsInEdit({ assessment: editable }));
}, [editable, hasAssessment]);

const assignableOfficers: Option[] =
officersInAgencyList !== null
Expand Down Expand Up @@ -302,9 +312,22 @@ export const HWCRComplaintAssessment: FC = () => {
}`;

return (
<div className="comp-outcome-report-block">
<div
className="comp-outcome-report-block"
id="outcome-assessment"
>
<h6>Complaint assessment</h6>
<div className="comp-outcome-report-complaint-assessment">
{showSectionErrors && (
<div className="section-error-message">
<BsExclamationCircleFill />
{hasAssessment ? (
<span>Save section before closing the complaint.</span>
) : (
<span>Complete section before closing the complaint.</span>
)}
</div>
)}
<div className={`comp-outcome-report-complaint-assessment ${showSectionErrors ? "section-error" : ""}`}>
<div className="comp-details-edit-container">
<div className="assessment-details-edit-column">
<div className="comp-details-edit-container">
Expand Down
Loading

0 comments on commit b9b192a

Please sign in to comment.