@@ -10,7 +10,11 @@ import {
10
10
import {
11
11
downloadUrl ,
12
12
downloadUrl2 ,
13
- } from "libs/components/src/form/widgets/FileWidget.test" ;
13
+ mock21MBFile ,
14
+ mockFile ,
15
+ mockFile2 ,
16
+ mockFileUnaccepted ,
17
+ } from "libs/testConfig/src/constants" ;
14
18
15
19
import { createAdministrationOperationInformationSchema } from "apps/administration/app/data/jsonSchema/operationInformation/administrationOperationInformation" ;
16
20
import { Apps , FrontEndRoles , OperationStatus } from "@bciers/utils/src/enums" ;
@@ -30,10 +34,6 @@ useSearchParams.mockReturnValue({
30
34
get : vi . fn ( ) ,
31
35
} ) ;
32
36
33
- global . URL . createObjectURL = vi . fn (
34
- ( ) => "this is the link to download the File" ,
35
- ) ;
36
-
37
37
// Just using a simple schema for testing purposes
38
38
const testSchema : RJSFSchema = {
39
39
type : "object" ,
@@ -176,6 +176,9 @@ const newEntrantFormData = {
176
176
const operationId = "8be4c7aa-6ab3-4aad-9206-0ef914fea063" ;
177
177
178
178
describe ( "the OperationInformationForm component" , ( ) => {
179
+ global . URL . createObjectURL = vi . fn (
180
+ ( ) => "this is the link to download the File" ,
181
+ ) ;
179
182
beforeEach ( ( ) => {
180
183
vi . clearAllMocks ( ) ;
181
184
} ) ;
@@ -346,15 +349,15 @@ describe("the OperationInformationForm component", () => {
346
349
expect ( actionHandler ) . toHaveBeenCalledTimes ( 1 ) ;
347
350
expect ( actionHandler ) . toHaveBeenCalledWith (
348
351
`registration/operations/${ operationId } ` ,
349
- "PUT " ,
352
+ "POST " ,
350
353
"" ,
351
354
{
352
- body : JSON . stringify ( {
353
- name : "Operation 4" ,
354
- type : "Single Facility Operation" ,
355
- } ) ,
355
+ body : expect . any ( FormData ) ,
356
356
} ,
357
357
) ;
358
+ const formData = actionHandler . mock . calls [ 0 ] [ 3 ] . body ;
359
+ expect ( formData . get ( "name" ) ) . toBe ( "Operation 4" ) ;
360
+ expect ( formData . get ( "type" ) ) . toBe ( "Single Facility Operation" ) ;
358
361
359
362
// Expect the form to be submitted
360
363
expect ( screen . getByText ( / O p e r a t i o n 4 / i) ) . toBeVisible ( ) ;
@@ -835,9 +838,7 @@ describe("the OperationInformationForm component", () => {
835
838
) ;
836
839
837
840
await userEvent . click ( afterAprilRadioButton ) ;
838
- const mockFile = new File ( [ "test" ] , "mock_file.pdf" , {
839
- type : "application/pdf" ,
840
- } ) ;
841
+
841
842
const newEntrantApplicationDocument = screen . getByLabelText (
842
843
/ n e w e n t r a n t a p p l i c a t i o n a n d s t a t u t o r y d e c l a r a t i o n / i,
843
844
) ;
@@ -850,19 +851,21 @@ describe("the OperationInformationForm component", () => {
850
851
expect ( actionHandler ) . toHaveBeenCalledTimes ( 1 ) ;
851
852
expect ( actionHandler ) . toHaveBeenCalledWith (
852
853
`registration/operations/${ operationId } ` ,
853
- "PUT " ,
854
+ "POST " ,
854
855
"" ,
855
856
{
856
- body : JSON . stringify ( {
857
- name : "Operation 5" ,
858
- type : "Single Facility Operation" ,
859
- registration_purpose : "New Entrant Operation" ,
860
- date_of_first_shipment : "On or after April 1, 2024" ,
861
- new_entrant_application :
862
- "data:application/pdf;name=mock_file.pdf;base64,dGVzdA==" ,
863
- } ) ,
857
+ body : expect . any ( FormData ) ,
864
858
} ,
865
859
) ;
860
+ const formData = actionHandler . mock . calls [ 0 ] [ 3 ] . body ;
861
+
862
+ expect ( formData . get ( "name " ) ) . toBe ( "Operation 5" ) ;
863
+ expect ( formData . get ( "type " ) ) . toBe ( "Single Facility Operation" ) ;
864
+ expect ( formData . get ( "registration_purpose " ) ) . toBe ( "New Entrant Operation" ) ;
865
+ expect ( formData . get ( "date_of_first_shipment " ) ) . toBe (
866
+ "On or after April 1, 2024" ,
867
+ ) ;
868
+ expect ( formData . get ( "new_entrant_application" ) ) . toBe ( mockFile ) ;
866
869
} ) ;
867
870
868
871
it ( "should not allow external users to remove their operation rep" , async ( ) => {
@@ -903,7 +906,7 @@ describe("the OperationInformationForm component", () => {
903
906
expect ( screen . getByText ( / M u s t n o t h a v e f e w e r t h a n 1 i t e m s / i) ) . toBeVisible ( ) ;
904
907
} ) ;
905
908
906
- it (
909
+ it . only (
907
910
"should allow external users to replace their operation rep" ,
908
911
{ timeout : 100000 } ,
909
912
async ( ) => {
@@ -919,7 +922,7 @@ describe("the OperationInformationForm component", () => {
919
922
opt_in : false ,
920
923
operation_representatives : [ 1 ] ,
921
924
boundary_map : downloadUrl ,
922
- process_flow_diagram : downloadUrl ,
925
+ process_flow_diagram : downloadUrl2 ,
923
926
} ;
924
927
useSession . mockReturnValue ( {
925
928
data : {
@@ -970,23 +973,25 @@ describe("the OperationInformationForm component", () => {
970
973
expect ( actionHandler ) . toHaveBeenCalledTimes ( 1 ) ;
971
974
expect ( actionHandler ) . toHaveBeenCalledWith (
972
975
`registration/operations/${ operationId } ` ,
973
- "PUT " ,
976
+ "POST " ,
974
977
"" ,
975
978
{
976
- body : JSON . stringify ( {
977
- name : "Operation 3" ,
978
- type : "Single Facility Operation" ,
979
- naics_code_id : 1 ,
980
- secondary_naics_code_id : 2 ,
981
- process_flow_diagram : downloadUrl ,
982
- boundary_map : downloadUrl2 ,
983
- operation_has_multiple_operators : false ,
984
- registration_purpose : "Reporting Operation" ,
985
- operation_representatives : [ 2 ] ,
986
- activities : [ 1 , 2 ] ,
987
- } ) ,
979
+ body : expect . any ( FormData ) ,
988
980
} ,
989
981
) ;
982
+ const formData = actionHandler . mock . calls [ 0 ] [ 3 ] . body ;
983
+
984
+ expect ( formData . get ( "name" ) ) . toBe ( "Operation 3" ) ;
985
+ expect ( formData . get ( "type" ) ) . toBe ( "Single Facility Operation" ) ;
986
+ expect ( formData . get ( "naics_code_id" ) ) . toBe ( "1" ) ;
987
+ expect ( formData . get ( "secondary_naics_code_id" ) ) . toBe ( "2" ) ;
988
+ expect ( formData . get ( "boundary_map" ) ) . toBe ( downloadUrl ) ;
989
+ expect ( formData . get ( "process_flow_diagram" ) ) . toBe ( downloadUrl2 ) ;
990
+ expect ( formData . get ( "operation_has_multiple_operators" ) ) . toBe ( "false" ) ;
991
+ expect ( formData . get ( "registration_purpose" ) ) . toBe ( "Reporting Operation" ) ,
992
+ expect ( formData . get ( "operation_representatives" ) ) . toBe ( "2" ) ;
993
+ expect ( formData . get ( "activities" ) ) . toBe ( "1" ) ;
994
+ expect ( formData . get ( "activities" ) ) . toBe ( "2" ) ;
990
995
} ,
991
996
) ;
992
997
0 commit comments