Skip to content

Commit 71fada4

Browse files
authored
[Comp-795] fix strict lint, remove unused mock data, removed unused e… (#749)
1 parent e346fa3 commit 71fada4

33 files changed

+40
-782
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Change to the front-end directory:
8080
* `cd compliance-web`
8181

8282
### 2. Requirements
83-
- [Node.js](https://nodejs.org/en/) 18
83+
- [Node.js](https://nodejs.org/en/) 24
8484

8585
### 3. Install Dependencies
8686
Install necessary npm packages:
Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,9 @@
11
/// <reference types="cypress" />
22
import {
33
exportToCsv,
4-
getSelectFilterOptions,
5-
rowsPerPageOptions,
6-
searchFilter,
74
} from "@/components/Shared/MasterDataTable/utils";
85
import { MRT_RowData, MRT_TableInstance } from "material-react-table";
96

10-
describe("Utility Functions", () => {
11-
describe("getSelectFilterOptions", () => {
12-
it("returns formatted options with proper labels and values", () => {
13-
const mockData = [
14-
{ id: 1, name: "Option 1" },
15-
{ id: 2, name: "Option 2" },
16-
{ id: 3, name: null },
17-
];
18-
19-
const options = getSelectFilterOptions(mockData, "name");
20-
21-
expect(options).to.deep.equal([
22-
{ text: "(Blanks)", value: "" },
23-
{ text: "Option 1", value: "Option 1" },
24-
{ text: "Option 2", value: "Option 2" },
25-
]);
26-
});
27-
28-
it("sorts options correctly, placing blanks at the top", () => {
29-
const mockData = [
30-
{ id: 1, name: "Zebra" },
31-
{ id: 2, name: "Apple" },
32-
{ id: 3, name: null },
33-
];
34-
35-
const options = getSelectFilterOptions(mockData, "name");
36-
37-
expect(options).to.deep.equal([
38-
{ text: "(Blanks)", value: "" },
39-
{ text: "Apple", value: "Apple" },
40-
{ text: "Zebra", value: "Zebra" },
41-
]);
42-
});
43-
});
44-
45-
describe("rowsPerPageOptions", () => {
46-
it("returns default options when no data size is provided", () => {
47-
const options = rowsPerPageOptions();
48-
expect(options).to.deep.equal([
49-
{ value: 15, label: "15" },
50-
{ value: 10, label: "All" },
51-
]);
52-
});
53-
54-
it("returns options with a custom data size", () => {
55-
const options = rowsPerPageOptions(20);
56-
expect(options).to.deep.equal([
57-
{ value: 15, label: "15" },
58-
{ value: 20, label: "All" },
59-
]);
60-
});
61-
});
627

638
describe("exportToCsv", () => {
649
it("exports table data to CSV correctly", async () => {
@@ -105,42 +50,3 @@ describe("Utility Functions", () => {
10550
cy.get("@createObjectURL").should("be.calledOnce");
10651
});
10752
});
108-
109-
describe("searchFilter", () => {
110-
it("returns true when filter value is a substring of the row value", () => {
111-
const row = {
112-
getValue: () => "apple pie",
113-
};
114-
115-
const result = searchFilter(row, "id", "apple");
116-
expect(result).to.be.true;
117-
});
118-
119-
it("returns false when filter value is not present in the row value", () => {
120-
const row = {
121-
getValue: () => "apple pie",
122-
};
123-
124-
const result = searchFilter(row, "id", "banana");
125-
expect(result).to.be.false;
126-
});
127-
128-
it("returns true when filter value is an array containing a matching substring", () => {
129-
const row = {
130-
getValue: () => "apple pie",
131-
};
132-
133-
const result = searchFilter(row, "id", ["apple", "banana"]);
134-
expect(result).to.be.true;
135-
});
136-
137-
it("returns false when filter value is an array not containing any matching substrings", () => {
138-
const row = {
139-
getValue: () => "apple pie",
140-
};
141-
142-
const result = searchFilter(row, "id", ["banana", "cherry"]);
143-
expect(result).to.be.false;
144-
});
145-
});
146-
});

compliance-web/cypress/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../tsconfig.json",
2+
"extends": "../tsconfig.app.json",
33
"compilerOptions": {
44
"target": "es6",
55
"lib": ["es6", "dom"],

compliance-web/src/components/App/CaseFiles/Profile/CaseFileComplaintsTable.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { INITIATION } from "@/utils/constants";
55
import dateUtils from "@/utils/dateUtils";
66
import { ChevronRight, ExpandLessRounded } from "@mui/icons-material";
77
import {
8-
Link,
98
Chip,
109
Accordion,
1110
AccordionSummary,
@@ -92,16 +91,14 @@ const CaseFileComplaintsTable = ({ caseFile }: { caseFile: CaseFile }) => {
9291
>
9392
<Box display={"flex"} alignItems={"center"} gap={0.5}>
9493
{isExpanded ? <ExpandLessRounded /> : <ChevronRight />}
95-
<Link
96-
component={RouterLink}
94+
<RouterLink
9795
to="/ce-database/complaints/$complaintNumber"
9896
params={{
9997
complaintNumber: complaint.complaint_number,
10098
}}
101-
underline="hover"
10299
>
103100
{complaint.complaint_number}
104-
</Link>
101+
</RouterLink>
105102
<Chip
106103
label={complaint.status}
107104
data-testid="status-chip"

compliance-web/src/components/App/CaseFiles/Profile/CaseFileInspectionsTable.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ const CaseFileInspectionsTable = ({ caseFile }: { caseFile: CaseFile }) => {
103103
inspection={inspection as Inspection}
104104
enforcementOrder={order}
105105
staffUsersList={staffUsersList || []}
106-
isReadonlyMode={true}
107106
/>
108107
),
109108
width: DRAWER_WIDTHS.ENFORCEMENT_DRAWER,
@@ -211,16 +210,14 @@ const CaseFileInspectionsTable = ({ caseFile }: { caseFile: CaseFile }) => {
211210
>
212211
<Box display={"flex"} alignItems={"center"} gap={0.5}>
213212
{isExpanded ? <ExpandLessRounded /> : <ChevronRight />}
214-
<Link
215-
component={RouterLink}
213+
<RouterLink
216214
to="/ce-database/inspections/$inspectionNumber"
217215
params={{
218216
inspectionNumber: inspection.ir_number,
219217
}}
220-
underline="hover"
221218
>
222219
{inspection.ir_number}
223-
</Link>
220+
</RouterLink>
224221
<Chip
225222
label={inspection.inspection_status}
226223
data-testid="status-chip"

compliance-web/src/components/App/Inspections/InspectionFormUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ export const formatInAttendance = (
205205
} else if (typeof attendance.data === "string") {
206206
return attendance.data;
207207
}
208+
return attendance.attendance_option.name;
208209
} else {
209210
if (
210211
attendance.attendance_option.id ===

compliance-web/src/components/App/Inspections/Profile/Enforcements/AdministrativePenalty/AdministrativePenaltyCreationOptions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ const AdministrativePenaltyCreationOptions: FC<AdministrativePenaltyCreationOpti
184184
options={openAPs ?? []}
185185
getOptionLabel={(option) => {
186186
if (typeof option === 'number') {
187-
const foundOption = openAPs.find(ap => ap.id === option);
187+
const foundOption = openAPs?.find(ap => ap.id === option);
188188
return foundOption?.administrative_penalty_number || '';
189189
}
190190
return option.administrative_penalty_number;

compliance-web/src/components/App/Inspections/Profile/Enforcements/EnforcementUtils.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -43,36 +43,6 @@ export const orderSchema = baseEnforcementSchema.shape({
4343

4444
export type OrderFormType = yup.InferType<typeof orderSchema>;
4545

46-
export const initOrderFormData: OrderFormType = {
47-
requirements: [],
48-
isHistoricalRecord: false,
49-
manualOrderNumber: undefined,
50-
linkedOrderNumber: undefined,
51-
};
52-
53-
// Enforcement type detection functions
54-
export const isEnforcementOrder = (requirement: InspectionRequirement): boolean => {
55-
return requirement.enforcement_action_data.some(
56-
(enforcement) => enforcement.id === EnforcementActionEnum.ORDER
57-
);
58-
};
59-
60-
export const isEnforcementWarningLetter = (requirement: InspectionRequirement): boolean => {
61-
return requirement.enforcement_action_data.some(
62-
(enforcement) => enforcement.id === EnforcementActionEnum.WARNING_LETTER
63-
);
64-
};
65-
66-
export const getEnforcementTypeFromRequirement = (requirement: InspectionRequirement): EnforcementActionEnum | null => {
67-
if (isEnforcementOrder(requirement)) {
68-
return EnforcementActionEnum.ORDER;
69-
}
70-
if (isEnforcementWarningLetter(requirement)) {
71-
return EnforcementActionEnum.WARNING_LETTER;
72-
}
73-
return null;
74-
};
75-
7646
// Requirement data processing functions
7747
export const prepNonProceededRequirements = (
7848
{

compliance-web/src/components/App/Inspections/Profile/Enforcements/Orders/OrderCreationOptions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ const OrderCreationOptions: FC<OrderCreationOptionsProps> = ({
173173
options={openOrders ?? []}
174174
getOptionLabel={(option) => {
175175
if (typeof option === 'number') {
176-
const foundOption = openOrders.find(o => o.id === option);
176+
const foundOption = openOrders?.find(o => o.id === option);
177177
return foundOption?.order_number || '';
178178
}
179-
return option.order_number;
179+
return option.order_number || '';
180180
}}
181181
isOptionEqualToValue={(option, value) => {
182182
if (typeof value === 'number') {

compliance-web/src/components/App/Inspections/Profile/Enforcements/ViolationTicket/ViolationTicketCreateModal.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ type ViolationTicketCreateModalProps = {
4747
requirement?: InspectionRequirement;
4848
nonProceededRequirements?: InspectionRequirement[];
4949
enforcementAction: EnforcementActionEnum;
50-
isPrimaryOfficerOrSuperUser: boolean;
5150
onSubmit: (data: ViolationTicket) => void;
5251
};
5352

@@ -56,7 +55,6 @@ const ViolationTicketCreateModal: FC<ViolationTicketCreateModalProps> = ({
5655
requirementsList,
5756
requirement,
5857
nonProceededRequirements,
59-
isPrimaryOfficerOrSuperUser,
6058
enforcementAction,
6159
onSubmit,
6260
}) => {
@@ -129,7 +127,6 @@ const ViolationTicketCreateModal: FC<ViolationTicketCreateModalProps> = ({
129127
requirement={requirement}
130128
nonProceededRequirements={nonProceededRequirements}
131129
enforcementAction={enforcementAction}
132-
isPrimaryOfficerOrSuperUser={isPrimaryOfficerOrSuperUser}
133130
title="Create Violation Ticket"
134131
onSubmit={handleBaseSubmit}
135132
isLoading={isPendingViolationTicket}

0 commit comments

Comments
 (0)