Skip to content

Commit

Permalink
Merged in r2-2643-ghn (pull request #6551)
Browse files Browse the repository at this point in the history
R2-2643 - GHN Insight: Issue with multiples-violation indicator
  • Loading branch information
jtoliver-quoin committed Oct 19, 2023
2 parents a407855 + 5886a7b commit c3d0803
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 164 deletions.
8 changes: 6 additions & 2 deletions app/javascript/components/insights-sub-report/container.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useMemo } from "react";
import { useParams } from "react-router-dom";
import { fromJS } from "immutable";
import { fromJS, List } from "immutable";
import { useDispatch } from "react-redux";
import isNil from "lodash/isNil";
import isString from "lodash/isString";
Expand Down Expand Up @@ -168,7 +168,11 @@ const Component = () => {
.entrySeq()
.map(([valueKey, value]) => {
const hasTotalColumn = isGrouped
? value.some(elem => elem.get("data", fromJS([])).some(row => !isNil(row.get("total"))))
? value.some(
elem =>
List.isList(elem.get("data")) &&
elem.get("data", fromJS([])).some(row => !isNil(row.get("total")))
)
: value.some(row => !isNil(row.get("total")));

const indicatorSubColumnKeys = getIndicatorSubcolumnKeys(value);
Expand Down
129 changes: 129 additions & 0 deletions app/javascript/components/insights-sub-report/container.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import { fromJS } from "immutable";

import { mountedComponent, screen } from "../../test-utils";

import InsightsSubReport from "./container";

describe("<InsightsSubReport />", () => {
const initialState = fromJS({
records: {
insights: {
selectedReport: {
id: "ghn_report",
name: "managed_reports.ghn_report.name",
description: "managed_reports.ghn_report.description",
module_id: "primeromodule-mrm",
subreports: ["ghn_report"],
report_data: {
ghn_report: {
data: {
verified_information: [
{
group_id: "boys",
data: [
{
id: "killing",
total: 2
}
]
},
{
group_id: "girls",
data: []
},
{
group_id: "unknown",
data: []
},
{
group_id: "total",
data: [
{
id: "killing",
total: 2
}
]
}
],
verified_information_violations: [],
late_verification: [],
late_verification_violations: [],
unverified_information: [
{
group_id: "boys",
data: [
{
id: "killing",
total: 1
}
]
},
{
group_id: "girls",
data: []
},
{
group_id: "unknown",
data: []
},
{
group_id: "total",
data: [
{
id: "killing",
total: 1
}
]
}
],
unverified_information_violations: [],
multiple_violations: [
{
data: {
unique_id: "26c0dfd0-4731-41d2-a6f5-689370cca821",
violations: ["killing"],
incident_id: "bb763213-2202-4e3d-a302-05bc96ed599b",
individual_age: null,
individual_sex: "male",
incident_short_id: "21ac674"
}
}
]
},
metadata: {
display_graph: false,
lookups: {
multiple_violations: ["lookup-gender-unknown-total", "lookup-violation-type"]
},
table_type: "ghn_report",
order: [
"verified_information",
"verified_information_violations",
"late_verification",
"late_verification_violations",
"unverified_information",
"unverified_information_violations",
"multiple_violations"
],
indicators_rows: {},
indicators_subcolumns: {}
}
}
}
}
}
}
});

it("should render a MultipleViolationsIndicator component", () => {
mountedComponent(
<InsightsSubReport />,
initialState,
{},
["/insights/primeromodule-mrm/ghn_report/ghn_report"],
{},
"/insights/:moduleID/:id/:subReport"
);
expect(screen.getByText("managed_reports.ghn_report.sub_reports.multiple_violations")).toBeInTheDocument();
});
});
161 changes: 0 additions & 161 deletions app/javascript/components/insights-sub-report/container.unit.test.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/javascript/test-utils/mounted-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const FormikForm = ({ children }) => {
);
};

function mountedComponent(Component, state = {}, options = {}, initialEntries = {}, formProps = {}, path = "") {
function mountedComponent(Component, state = {}, options = {}, initialEntries = [], formProps = {}, path = "") {
const { store, history } = createMockStore(DEFAULT_STATE, state);

function FormProvider({ children }) {
Expand Down

0 comments on commit c3d0803

Please sign in to comment.