Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface OperationRow {
sfo_facility_name: string | null;
operation__bcghg_id: string | null;
operation__bc_obps_regulated_operation: string | null;
operation__registration_purpose: string;
operation__registration_purpose?: string;
id: number;
operator__legal_name: string;
status: string;
Expand Down
13 changes: 10 additions & 3 deletions bciers/apps/administration/proxies/withRulesAppliedAdmin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getToken } from "@bciers/testConfig/mocks";
import { mockIndustryUserToken } from "@bciers/testConfig/data/tokens";
import { DashboardRoutes } from "@bciers/proxies";
import getCurrentUserOperator from "@/administration/app/components/userOperators/getCurrentUserOperator";
import { UserOperator } from "@/administration/app/components/userOperators/types";

vi.mock("@/administration/app/components/userOperators/getCurrentUserOperator");

Expand All @@ -18,7 +19,9 @@ describe("withRulesAppliedAdmin proxy", () => {

it("redirects /operations for industry users if their userOperator is not found", async () => {
getToken.mockResolvedValue(mockIndustryUserToken);
vi.mocked(getCurrentUserOperator).mockResolvedValueOnce(undefined);
vi.mocked(getCurrentUserOperator).mockResolvedValueOnce(
undefined as unknown as UserOperator,
);

const result = await proxy(
mockRequest("/administration/operations"),
Expand Down Expand Up @@ -106,7 +109,9 @@ describe("withRulesAppliedAdmin proxy", () => {

it("proceeds /select-operator when userOperator resolves to undefined", async () => {
getToken.mockResolvedValue(mockIndustryUserToken);
vi.mocked(getCurrentUserOperator).mockResolvedValueOnce(undefined);
vi.mocked(getCurrentUserOperator).mockResolvedValueOnce(
undefined as unknown as UserOperator,
);

const result = await proxy(
mockRequest("/administration/select-operator"),
Expand Down Expand Up @@ -138,7 +143,9 @@ describe("withRulesAppliedAdmin proxy", () => {

it("redirects /contacts for industry users if their userOperator is not found", async () => {
getToken.mockResolvedValue(mockIndustryUserToken);
vi.mocked(getCurrentUserOperator).mockResolvedValueOnce(undefined);
vi.mocked(getCurrentUserOperator).mockResolvedValueOnce(
undefined as unknown as UserOperator,
);

const result = await proxy(
mockRequest("/administration/contacts"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import {
useSearchParams,
useParams,
} from "@bciers/testConfig/mocks";
import {
contactsSchema,
contactsUiSchema,
} from "apps/administration/app/data/jsonSchema/contact";
import { contactsSchema } from "apps/administration/app/data/jsonSchema/contact";
import ContactForm from "apps/administration/app/components/contacts/ContactForm";
import { createContactSchema } from "apps/administration/app/components/contacts/createContactSchema";
import { FrontendMessages } from "@bciers/utils/src/enums";
import { ContactFormData } from "@/administration/app/components/contacts/types";

const mockReplace = vi.fn();
const mockRouterPush = vi.fn();
Expand All @@ -28,7 +26,7 @@ useParams.mockReturnValue({
contactId: "123",
});

const contactFormData = {
const contactFormData: ContactFormData = {
id: 123,
first_name: "John",
last_name: "Doe",
Expand Down Expand Up @@ -178,7 +176,6 @@ describe("ContactForm component", () => {
render(
<ContactForm
schema={createContactSchema(contactsSchema, true)}
uiSchema={contactsUiSchema}
formData={{}}
isCreating
/>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { useSearchParams } from "@bciers/testConfig/mocks";
import FacilityDataGrid from "apps/administration/app/components/facilities/FacilitiesDataGrid";
import { QueryParams } from "@bciers/testConfig/types";
import { FacilityInitialData } from "@/administration/app/components/facilities/types";
import extractParams from "@bciers/testConfig/helpers/extractParams";
import userEvent from "@testing-library/user-event";

Expand All @@ -18,21 +19,27 @@ useSearchParams.mockReturnValue({
get: vi.fn(),
} as QueryParams);

const mockResponse = {
const mockResponse: FacilityInitialData = {
rows: [
{
id: 1,
id: "3b5b95ea-2a1a-450d-8e2e-2e15feed96c1",
facility__name: "Facility 1",
facility__type: "Single Facility",
facility__bcghg_id__id: "12111130001",
facility__id: 1,
facility__id: "3b5b95ea-2a1a-450d-8e2e-2e15feed96c1",
status: "Active",
facility__latitude_of_largest_emissions: "48.4",
facility__longitude_of_largest_emissions: "-123.4",
},
{
id: 2,
id: "d99725a7-1c3a-47cb-a59b-e2388ce0fa18",
facility__name: "Facility 2",
facility__type: "Large Facility",
facility__bcghg_id__id: "1-211113-0002",
facility__id: 2,
facility__id: "d99725a7-1c3a-47cb-a59b-e2388ce0fa18",
status: "Active",
facility__latitude_of_largest_emissions: "49.2",
facility__longitude_of_largest_emissions: "-123.1",
},
],
row_count: 2,
Expand Down Expand Up @@ -78,11 +85,11 @@ describe("FacilitiesDataGrid component", () => {
// we don't care about the exact href, just that it contains the facilityId
expect(viewDetailsLinks[0]).toHaveAttribute(
"href",
"/administration/operations/randomOperationUUID/facilities/1?operations_title=undefined&facilities_title=Facility 1",
"/administration/operations/randomOperationUUID/facilities/3b5b95ea-2a1a-450d-8e2e-2e15feed96c1?operations_title=undefined&facilities_title=Facility 1",
);
expect(viewDetailsLinks[1]).toHaveAttribute(
"href",
"/administration/operations/randomOperationUUID/facilities/2?operations_title=undefined&facilities_title=Facility 2",
"/administration/operations/randomOperationUUID/facilities/d99725a7-1c3a-47cb-a59b-e2388ce0fa18?operations_title=undefined&facilities_title=Facility 2",
);
});
it("makes API call with correct params when sorting", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ useRouter.mockReturnValue({
const sfoFormData = {
name: "Monkeyfuzz",
type: "Single Facility",
latitude_of_largest_emissions: "3.000000",
longitude_of_largest_emissions: "4.000000",
latitude_of_largest_emissions: 3,
longitude_of_largest_emissions: 4,
street_address: "adf",
municipality: "ad",
postal_code: "h0h0h0",
Expand All @@ -66,8 +66,8 @@ const lfoFormData = {
name: "Monkeyfuzz",
type: "Large Facility",
well_authorization_numbers: ["24546", "54321"],
latitude_of_largest_emissions: "3.000000",
longitude_of_largest_emissions: "4.000000",
latitude_of_largest_emissions: 3,
longitude_of_largest_emissions: 4,
street_address: "adf",
municipality: "ad",
postal_code: "h0h0h0",
Expand Down Expand Up @@ -480,10 +480,10 @@ describe("FacilityForm component", () => {
).toHaveTextContent("h0h0h0");
expect(
container.querySelector("#root_section2_latitude_of_largest_emissions"),
).toHaveTextContent("3.000000");
).toHaveTextContent("3");
expect(
container.querySelector("#root_section2_longitude_of_largest_emissions"),
).toHaveTextContent(".000000");
).toHaveTextContent("4");
});
it("loads existing readonly LFO (Large Facility) form data", async () => {
const { container } = render(
Expand Down Expand Up @@ -530,10 +530,10 @@ describe("FacilityForm component", () => {
).toHaveTextContent("h0h0h0");
expect(
container.querySelector("#root_section1_latitude_of_largest_emissions"),
).toHaveTextContent("3.000000");
).toHaveTextContent("3");
expect(
container.querySelector("#root_section1_longitude_of_largest_emissions"),
).toHaveTextContent(".000000");
).toHaveTextContent("4");
});
it("loads existing readonly LFO (Small Aggregate) form data", async () => {
const { container } = render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ const optInFormData = {
meets_producing_gger_schedule_a1_regulated_product: true,
meets_reporting_and_regulated_obligations: true,
meets_notification_to_director_on_criteria_change: true,
final_reporting_year: null,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe("the OperationInformationPage component", () => {
});
});
it("renders the OperationInformationPage component without Registration Information", async () => {
getOperationWithDocuments.mockResolvedValueOnce(formData);
vi.mocked(getOperationWithDocuments).mockResolvedValueOnce(formData);
render(await OperationInformationPage({ operationId }));

expect(
Expand All @@ -112,7 +112,7 @@ describe("the OperationInformationPage component", () => {
});

it("should render the form without Registration Information", async () => {
getOperationWithDocuments.mockResolvedValueOnce(formData);
vi.mocked(getOperationWithDocuments).mockResolvedValueOnce(formData);

render(await OperationInformationPage({ operationId }));

Expand All @@ -121,7 +121,7 @@ describe("the OperationInformationPage component", () => {
expect(screen.getByText(/212114 - Bituminous coal mining/i)).toBeVisible();
});
it("should render the form with Registration Information", async () => {
getOperationWithDocuments.mockResolvedValueOnce({
vi.mocked(getOperationWithDocuments).mockResolvedValueOnce({
status: OperationStatus.REGISTERED,
});

Expand Down
Loading