Skip to content

Commit

Permalink
little more test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
taraepp committed Nov 8, 2024
1 parent 0285dab commit d0c98fe
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ exports[`DocumentTable renders properly 1`] = `
</tr>
<tr
class="ant-table-row ant-table-row-level-0 table-row-align-middle no-sub-table-expandable-rows fade-in"
data-row-key="1c77f818-3d7a-461c-902d-7546755f4661"
data-row-key="1c77f818-3d7a-461c-902d-7546755f4662"
>
<td
class="ant-table-cell ant-table-cell-with-append"
Expand Down
3 changes: 1 addition & 2 deletions services/common/src/components/forms/RenderSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { FormConsumer, IFormContext } from "./FormWrapper";
interface SelectProps extends BaseInputProps {
data: IOption[];
onSelect?: (value, option) => void;
usedOptions: string[];
allowClear?: boolean;
}

Expand All @@ -25,7 +24,7 @@ export const RenderSelect: FC<SelectProps> = ({
input,
placeholder = "Please select",
data = [],
onSelect = () => {},
onSelect = () => { },
allowClear = true,
disabled = false,
required = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ export const AuthorizationsInvolved: FC<ProjectSummaryFormComponentProps> = ({ f
checked={checked}
onChange={(e) => handleChange(e, child.code)}
>
<b className={!isEditMode && "view-item-label"}>{child.description}</b>
<b className={!isEditMode ? "view-item-label" : ""}>{child.description}</b>
</Checkbox>
{checked && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const { Paragraph, Title } = Typography;

const unassignedProjectLeadEntry = {
label: "Unassigned",
value: null,
value: undefined,
};

export const ProjectManagement: FC = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { LegalLandOwnerInformation } from "./LegalLandOwnerInformation";
import { ReduxWrapper } from "@mds/common/tests/utils/ReduxWrapper";
import * as MOCK from "@mds/common/tests/mocks/dataMocks";
import { AUTHENTICATION, PERMITS, PROJECTS, STATIC_CONTENT } from "@mds/common/constants/reducerTypes";
import { formatProjectSummary } from "@mds/common/redux/selectors/projectSelectors";
import { exportForTesting } from "@mds/common/redux/selectors/projectSelectors";
import BasicInformation from "./BasicInformation";
import ProjectLinks from "./ProjectLinks";
import ProjectContacts from "./ProjectContacts";
Expand All @@ -21,6 +21,9 @@ import DocumentUpload from "./DocumentUpload";
import { FacilityOperator } from "./FacilityOperator";
import { BrowserRouter } from "react-router-dom";

const { formatProjectSummary } = exportForTesting;


const amsAuthTypes = ['AIR_EMISSIONS_DISCHARGE_PERMIT', 'EFFLUENT_DISCHARGE_PERMIT', 'REFUSE_DISCHARGE_PERMIT'];
const project = { project_lead_party_guid: "project_lead_party_guid" };
const formattedProjectSummary = formatProjectSummary(MOCK.PROJECT_SUMMARY, project, amsAuthTypes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ exports[`AuthorizationsInvolved renders properly 1`] = `
/>
</span>
<span>
<b>
<b
class=""
>
Mines Act permit
</b>
</span>
Expand Down Expand Up @@ -558,7 +560,9 @@ exports[`AuthorizationsInvolved renders properly 1`] = `
/>
</span>
<span>
<b>
<b
class=""
>
Air emissions discharge permit
</b>
</span>
Expand Down Expand Up @@ -692,7 +696,9 @@ exports[`AuthorizationsInvolved renders properly 1`] = `
/>
</span>
<span>
<b>
<b
class=""
>
Effluent discharge permit
</b>
</span>
Expand Down Expand Up @@ -727,7 +733,9 @@ exports[`AuthorizationsInvolved renders properly 1`] = `
/>
</span>
<span>
<b>
<b
class=""
>
Refuse discharge permit
</b>
</span>
Expand Down Expand Up @@ -771,7 +779,9 @@ exports[`AuthorizationsInvolved renders properly 1`] = `
/>
</span>
<span>
<b>
<b
class=""
>
Change approval
</b>
</span>
Expand Down Expand Up @@ -806,7 +816,9 @@ exports[`AuthorizationsInvolved renders properly 1`] = `
/>
</span>
<span>
<b>
<b
class=""
>
Use approval
</b>
</span>
Expand Down Expand Up @@ -842,7 +854,9 @@ exports[`AuthorizationsInvolved renders properly 1`] = `
/>
</span>
<span>
<b>
<b
class=""
>
Water licence
</b>
</span>
Expand Down Expand Up @@ -1109,7 +1123,9 @@ exports[`AuthorizationsInvolved renders properly 1`] = `
/>
</span>
<span>
<b>
<b
class=""
>
Occupant licence to cut
</b>
</span>
Expand Down Expand Up @@ -1376,7 +1392,9 @@ exports[`AuthorizationsInvolved renders properly 1`] = `
/>
</span>
<span>
<b>
<b
class=""
>
Other legislation
</b>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,7 @@ exports[`ProjectDocumentsTab renders properly 1`] = `
</tr>
<tr
class="ant-table-row ant-table-row-level-0 table-row-align-middle no-sub-table-expandable-rows fade-in"
data-row-key="1c77f818-3d7a-461c-902d-7546755f4661"
data-row-key="1c77f818-3d7a-461c-902d-7546755f4662"
>
<td
class="ant-table-cell ant-table-selection-column"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ exports[`ProjectDocumentsTab renders properly 1`] = `
</tr>
<tr
class="ant-table-row ant-table-row-level-0 table-row-align-middle no-sub-table-expandable-rows fade-in"
data-row-key="1c77f818-3d7a-461c-902d-7546755f4661"
data-row-key="1c77f818-3d7a-461c-902d-7546755f4662"
>
<td
class="ant-table-cell ant-table-selection-column"
Expand Down
6 changes: 5 additions & 1 deletion services/common/src/redux/selectors/projectSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const getFormattedProjectApplication = createSelector(
}
);

export const formatProjectSummary = (summary, project, amsAuthTypes) => {
const formatProjectSummary = (summary, project, amsAuthTypes) => {
const documents = formatProjectSummaryDocuments(summary.documents);
const contacts = formatProjectContact(project.contacts);
const agent = formatProjectSummaryParty(summary.agent);
Expand All @@ -165,3 +165,7 @@ export const getFormattedProjectSummary = createSelector(
return formatProjectSummary(summary, project, amsAuthTypes);
}
);

export const exportForTesting = {
formatProjectSummary
}
11 changes: 10 additions & 1 deletion services/common/src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Adapter from "enzyme-adapter-react-16";
import path from "path";
import "@testing-library/jest-dom";
import server from "@mds/common/tests/server";
import { rejectHandler } from "./redux/createAppSlice";

require("jest-localstorage-mock");

Expand Down Expand Up @@ -53,6 +54,14 @@ jest.mock("@mds/common/providers/featureFlags/useFeatureFlag", () => ({
isFeatureEnabled: () => true,
}),
}));

jest.mock("@mds/common/redux/createAppSlice", () => {
const original = jest.requireActual("@mds/common/redux/createAppSlice");
return {
...original,
rejectHandler: jest.fn(),
};
});
window.scrollTo = jest.fn();
const location = JSON.stringify(window.location);
delete window.location;
Expand Down Expand Up @@ -86,7 +95,7 @@ global.document.createElementNS = function (namespaceURI, qualifiedName) {
if (namespaceURI === "http://www.w3.org/2000/svg" && qualifiedName === "svg") {
// eslint-disable-next-line prefer-rest-params
const element = createElementNSOrig.apply(this, arguments);
element.createSVGRect = function () {};
element.createSVGRect = function () { };
return element;
}
// eslint-disable-next-line prefer-rest-params
Expand Down
2 changes: 1 addition & 1 deletion services/common/src/tests/mocks/dataMocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7638,7 +7638,7 @@ export const PROJECT_SUMMARY: IProjectSummary = {
project_summary_document_type_code: "SPR",
mine_document_guid: "b869134f-bcf8-47d9-ac61-c90835e20601",
mine_guid: "60300a07-376c-46f1-a984-88a813f91438",
document_manager_guid: "1c77f818-3d7a-461c-902d-7546755f4661",
document_manager_guid: "1c77f818-3d7a-461c-902d-7546755f4662",
document_name: "shape.shx",
upload_date: "2024-06-26 19:51:43.058986+00:00",
create_user: "idir\\username",
Expand Down

0 comments on commit d0c98fe

Please sign in to comment.