@@ -100,4 +100,62 @@ describe('[endpoint] documents', () => {
100
100
expect ( skjemabyggingproxyScope . isDone ( ) ) . toBe ( true ) ;
101
101
expect ( mergePdfScope . isDone ( ) ) . toBe ( true ) ;
102
102
} , 10000 ) ;
103
+
104
+ it ( 'Create front page and application - english' , async ( ) => {
105
+ vi . spyOn ( forstesideUtils , 'genererFoerstesideData' ) . mockImplementation (
106
+ ( ) =>
107
+ ( {
108
+ foerstesidetype : 'ETTERSENDELSE' ,
109
+ navSkjemaId : 'NAV 10.10.10' ,
110
+ spraakkode : 'en' ,
111
+ overskriftstittel : 'Tittel' ,
112
+ arkivtittel : 'Tittel' ,
113
+ tema : 'HJE' ,
114
+ } ) as ForstesideRequestBody ,
115
+ ) ;
116
+
117
+ const forstesidePdf = readFileSync ( filePathForsteside ) ;
118
+ const soknadPdf = readFileSync ( filePathSoknad ) ;
119
+ const mergedPdf = readFileSync ( filePathMerged ) ;
120
+ const encodedForstesidedPdf = forstesidePdf . toString ( 'base64' ) ;
121
+ const encodedSoknadPdf = soknadPdf . toString ( 'base64' ) ;
122
+
123
+ const recipientsMock = nock ( formsApiUrl ) . get ( '/v1/recipients' ) . reply ( 200 , [ ] ) ;
124
+ const generateFileMock = nock ( skjemabyggingProxyUrl ! )
125
+ . post ( '/foersteside' )
126
+ . reply ( 200 , { foersteside : encodedForstesidedPdf } ) ;
127
+ const skjemabyggingproxyScope = nock ( process . env . SKJEMABYGGING_PROXY_URL as string )
128
+ . post ( '/exstream' )
129
+ . reply ( 200 , { data : { result : [ { content : { data : encodedSoknadPdf } } ] } } ) ;
130
+
131
+ const mergePdfScope = nock ( process . env . GOTENBERG_URL_EN as string )
132
+ . intercept ( '/forms/pdfengines/merge' , 'POST' , ( body ) => {
133
+ return body != null ;
134
+ } )
135
+ . reply ( 200 , mergedPdf , { 'content-type' : 'application/pdf' } ) ;
136
+
137
+ const req = mockRequest ( {
138
+ headers : {
139
+ AzureAccessToken : '' ,
140
+ } ,
141
+ body : {
142
+ form : JSON . stringify ( {
143
+ title : formTitle ,
144
+ components : [ ] ,
145
+ properties : { mottaksadresseId : 'mottaksadresseId' , path : '12345' , skjemanummer : 'NAV 12.34-56' } ,
146
+ } ) ,
147
+ submissionMethod : 'paper' ,
148
+ language : 'EN' ,
149
+ submission : JSON . stringify ( { data : { } } ) ,
150
+ translations : JSON . stringify ( { } ) ,
151
+ } ,
152
+ } ) ;
153
+
154
+ await documents . coverPageAndApplication ( req , mockResponse ( ) , mockNext ( ) ) ;
155
+
156
+ expect ( recipientsMock . isDone ( ) ) . toBe ( true ) ;
157
+ expect ( generateFileMock . isDone ( ) ) . toBe ( true ) ;
158
+ expect ( skjemabyggingproxyScope . isDone ( ) ) . toBe ( true ) ;
159
+ expect ( mergePdfScope . isDone ( ) ) . toBe ( true ) ;
160
+ } , 10000 ) ;
103
161
} ) ;
0 commit comments