diff --git a/bciers/apps/administration/tests/components/operations/OperationInformationForm.test.tsx b/bciers/apps/administration/tests/components/operations/OperationInformationForm.test.tsx index 82406f1e5c..531492ea1d 100644 --- a/bciers/apps/administration/tests/components/operations/OperationInformationForm.test.tsx +++ b/bciers/apps/administration/tests/components/operations/OperationInformationForm.test.tsx @@ -257,7 +257,7 @@ describe("the OperationInformationForm component", () => { expect(screen.getByRole("button", { name: "Edit" })).toBeVisible(); }); - it("should render the form with the correct values when formData is provided", async () => { + it("should render the form with the correct values for a non-EIO when formData is provided", async () => { fetchFormEnums(); const createdFormSchema = await createAdministrationOperationInformationSchema( @@ -310,6 +310,36 @@ describe("the OperationInformationForm component", () => { expect(screen.getByText(/Reporting Operation/i)).toBeVisible(); }); + it("should render the form with the correct form for an EIO when formData is provided", async () => { + fetchFormEnums(); + const createdFormSchema = + await createAdministrationOperationInformationSchema( + RegistrationPurposes.ELECTRICITY_IMPORT_OPERATION, + OperationStatus.REGISTERED, + ); + render( + , + ); + //name + expect(screen.getByText(/Operation 3/i)).toBeVisible(); + // type + expect(screen.getByText(/Electricity Import Operation/i)).toBeVisible(); + // primary naics code + expect(screen.queryByText(/naics/i)).not.toBeInTheDocument(); + + // registration info & purpose + expect( + screen.getByText( + /The purpose of this registration is to register as a\:/i, + ), + ).toBeVisible(); + expect(screen.getByText(/Electricity Import Operation/i)).toBeVisible(); + }); + it("should enable editing when the Edit button is clicked", async () => { render( { ); }); - it("should render the Operation Representative Form and 4 steps", async () => { + it("should render the Operation Representative Form and 3 steps if the purpose is Electricity Import Operation", async () => { // purpose actionHandler.mockResolvedValueOnce({ - registration_purpose: "OBPS Regulated Operation", + registration_purpose: "Electricity Import Operation", }); // contacts @@ -164,7 +164,7 @@ describe("the OperationRegistrationPage component", () => { render( await OperationRegistrationPage({ operation: "002d5a9e-32a6-4191-938c-2c02bfec592d", - step: 3, + step: 2, searchParams: {}, }), ); diff --git a/bciers/apps/registration/tests/components/operations/registration/OperationInformationForm.test.tsx b/bciers/apps/registration/tests/components/operations/registration/OperationInformationForm.test.tsx index c287fb43de..313ae13964 100644 --- a/bciers/apps/registration/tests/components/operations/registration/OperationInformationForm.test.tsx +++ b/bciers/apps/registration/tests/components/operations/registration/OperationInformationForm.test.tsx @@ -183,7 +183,7 @@ describe("the OperationInformationForm component", () => { ); it( - "should submit a new operation with regulated products and multiple operators", + "should submit a new OBPS regulated operation with regulated products and multiple operators", { timeout: 60000, }, @@ -349,6 +349,67 @@ describe("the OperationInformationForm component", () => { }, ); + it( + "should submit a new EIO operation", + { + timeout: 60000, + }, + async () => { + fetchFormEnums(); + actionHandler.mockResolvedValueOnce({ + id: "b974a7fc-ff63-41aa-9d57-509ebe2553a4", + name: "EIO Op Name", + }); // mock the POST response from the submit handler + render( + , + ); + + const purposeInput = screen.getByRole("combobox", { + name: /The purpose of this registration+/i, + }); + await fillComboboxWidgetField( + purposeInput, + "Electricity Import Operation", + ); + + await userEvent.type( + screen.getByLabelText(/Operation Name/i), + "EIO Op Name", + ); + + // EIO is the default operation type if purpose is EIO so we don't have to fill it in + + // submit + + await userEvent.click( + screen.getByRole("button", { name: /save and continue/i }), + ); + await waitFor(() => { + expect(actionHandler).toHaveBeenLastCalledWith( + "registration/operations", + "POST", + "", + { + body: JSON.stringify({ + registration_purpose: "Electricity Import Operation", + name: "EIO Op Name", + type: "Electricity Import Operation", + operation_has_multiple_operators: false, + }), + }, + ); + }); + expect(mockPush).toHaveBeenCalledWith( + "/register-an-operation/b974a7fc-ff63-41aa-9d57-509ebe2553a4/2?operations_title=EIO%20Op%20Name", + ); + }, + ); + it("should show the correct help text when selecting a purpose", async () => { fetchFormEnums(); render(