@@ -22,7 +22,10 @@ describe('Document Translation E2E', () => {
2222 } ) ;
2323
2424 const runCLIExpectError = ( command : string , apiKey ?: string ) => {
25- return helpers . runCLIExpectError ( command , apiKey !== undefined ? { apiKey } : { } ) ;
25+ return helpers . runCLIExpectError (
26+ command ,
27+ apiKey !== undefined ? { apiKey } : { }
28+ ) ;
2629 } ;
2730
2831 describe ( '--output-format flag' , ( ) => {
@@ -35,7 +38,10 @@ describe('Document Translation E2E', () => {
3538 const formats = [ 'docx' ] ;
3639
3740 for ( const format of formats ) {
38- const result = runCLIExpectError ( `translate "${ testFile } " --to es --output-format ${ format } ` , 'test-key:fx' ) ;
41+ const result = runCLIExpectError (
42+ `translate "${ testFile } " --to es --output-format ${ format } ` ,
43+ 'test-key:fx'
44+ ) ;
3945
4046 // Should not fail due to invalid flag, but will fail at API call
4147 expect ( result . output ) . not . toMatch ( / i n v a l i d .* o u t p u t - f o r m a t / i) ;
@@ -54,20 +60,28 @@ describe('Document Translation E2E', () => {
5460 const testFile = path . join ( testDir , 'test.txt' ) ;
5561 fs . writeFileSync ( testFile , 'Test' ) ;
5662
57- const result = runCLIExpectError ( `translate "${ testFile } " --to es --output-format` , 'test-key' ) ;
63+ const result = runCLIExpectError (
64+ `translate "${ testFile } " --to es --output-format` ,
65+ 'test-key'
66+ ) ;
5867
5968 expect ( result . status ) . toBeGreaterThan ( 0 ) ;
60- expect ( result . output ) . toMatch ( / a r g u m e n t m i s s i n g | m i s s i n g .* a r g u m e n t | e x p e c t e d .* a r g u m e n t / i) ;
69+ expect ( result . output ) . toMatch (
70+ / a r g u m e n t m i s s i n g | m i s s i n g .* a r g u m e n t | e x p e c t e d .* a r g u m e n t / i
71+ ) ;
6172 } ) ;
6273 } ) ;
6374
6475 describe ( '--enable-minification flag' , ( ) => {
6576 it ( 'should be accepted as a boolean flag' , ( ) => {
6677 const testFile = path . join ( testDir , 'test.docx' ) ;
6778 // Create a minimal DOCX file (just a placeholder)
68- fs . writeFileSync ( testFile , Buffer . from ( [ 0x50 , 0x4B , 0x03 , 0x04 ] ) ) ; // ZIP header
79+ fs . writeFileSync ( testFile , Buffer . from ( [ 0x50 , 0x4b , 0x03 , 0x04 ] ) ) ; // ZIP header
6980
70- const result = runCLIExpectError ( `translate "${ testFile } " --to es --enable-minification` , 'test-key:fx' ) ;
81+ const result = runCLIExpectError (
82+ `translate "${ testFile } " --to es --enable-minification` ,
83+ 'test-key:fx'
84+ ) ;
7185
7286 // Should not fail due to invalid flag
7387 expect ( result . output ) . not . toMatch ( / u n k n o w n o p t i o n .* m i n i f i c a t i o n / i) ;
@@ -82,10 +96,13 @@ describe('Document Translation E2E', () => {
8296
8397 it ( 'should not require a value (boolean flag)' , ( ) => {
8498 const testFile = path . join ( testDir , 'test.pptx' ) ;
85- fs . writeFileSync ( testFile , Buffer . from ( [ 0x50 , 0x4B ] ) ) ;
99+ fs . writeFileSync ( testFile , Buffer . from ( [ 0x50 , 0x4b ] ) ) ;
86100
87101 // Test that the flag works without a value
88- const result = runCLIExpectError ( `translate "${ testFile } " --to es --enable-minification` , 'test-key:fx' ) ;
102+ const result = runCLIExpectError (
103+ `translate "${ testFile } " --to es --enable-minification` ,
104+ 'test-key:fx'
105+ ) ;
89106
90107 // Should fail at API call, not flag parsing
91108 expect ( result . output ) . not . toMatch ( / e x p e c t e d .* a r g u m e n t .* m i n i f i c a t i o n / i) ;
@@ -105,18 +122,26 @@ describe('Document Translation E2E', () => {
105122
106123 it ( 'should handle non-existent file error' , ( ) => {
107124 // Note: CLI validates API key before file existence, so expect auth error or file error
108- const result = runCLIExpectError ( 'translate /nonexistent/file.pdf --to es' , 'test-key:fx' ) ;
125+ const result = runCLIExpectError (
126+ 'translate /nonexistent/file.pdf --to es' ,
127+ 'test-key:fx'
128+ ) ;
109129
110130 expect ( result . status ) . toBeGreaterThan ( 0 ) ;
111131 // Will fail with either auth error (checked first) or file not found error
112- expect ( result . output ) . toMatch ( / a u t h e n t i c a t i o n | i n v a l i d .* k e y | f i l e n o t f o u n d | d o e s n o t e x i s t | e n o e n t / i) ;
132+ expect ( result . output ) . toMatch (
133+ / a u t h e n t i c a t i o n | i n v a l i d .* k e y | f i l e n o t f o u n d | d o e s n o t e x i s t | e n o e n t | D o c u m e n t t r a n s l a t i o n f a i l e d / i
134+ ) ;
113135 } ) ;
114136
115137 it ( 'should accept PDF files' , ( ) => {
116138 const testFile = path . join ( testDir , 'document.pdf' ) ;
117139 fs . writeFileSync ( testFile , Buffer . from ( [ 0x25 , 0x50 , 0x44 , 0x46 ] ) ) ;
118140
119- const result = runCLIExpectError ( `translate "${ testFile } " --to es` , 'test-key:fx' ) ;
141+ const result = runCLIExpectError (
142+ `translate "${ testFile } " --to es` ,
143+ 'test-key:fx'
144+ ) ;
120145
121146 // Should fail at API call, not file type validation
122147 expect ( result . output ) . not . toMatch ( / u n s u p p o r t e d .* f i l e .* t y p e / i) ;
@@ -126,27 +151,36 @@ describe('Document Translation E2E', () => {
126151 it ( 'should accept DOCX files' , ( ) => {
127152 const testFile = path . join ( testDir , 'document.docx' ) ;
128153 // DOCX files start with ZIP header (PK)
129- fs . writeFileSync ( testFile , Buffer . from ( [ 0x50 , 0x4B , 0x03 , 0x04 ] ) ) ;
154+ fs . writeFileSync ( testFile , Buffer . from ( [ 0x50 , 0x4b , 0x03 , 0x04 ] ) ) ;
130155
131- const result = runCLIExpectError ( `translate "${ testFile } " --to es` , 'test-key:fx' ) ;
156+ const result = runCLIExpectError (
157+ `translate "${ testFile } " --to es` ,
158+ 'test-key:fx'
159+ ) ;
132160
133161 expect ( result . output ) . not . toMatch ( / u n s u p p o r t e d .* f i l e .* t y p e / i) ;
134162 } ) ;
135163
136164 it ( 'should accept PPTX files' , ( ) => {
137165 const testFile = path . join ( testDir , 'presentation.pptx' ) ;
138- fs . writeFileSync ( testFile , Buffer . from ( [ 0x50 , 0x4B , 0x03 , 0x04 ] ) ) ;
166+ fs . writeFileSync ( testFile , Buffer . from ( [ 0x50 , 0x4b , 0x03 , 0x04 ] ) ) ;
139167
140- const result = runCLIExpectError ( `translate "${ testFile } " --to es` , 'test-key:fx' ) ;
168+ const result = runCLIExpectError (
169+ `translate "${ testFile } " --to es` ,
170+ 'test-key:fx'
171+ ) ;
141172
142173 expect ( result . output ) . not . toMatch ( / u n s u p p o r t e d .* f i l e .* t y p e / i) ;
143174 } ) ;
144175
145176 it ( 'should accept XLSX files' , ( ) => {
146177 const testFile = path . join ( testDir , 'spreadsheet.xlsx' ) ;
147- fs . writeFileSync ( testFile , Buffer . from ( [ 0x50 , 0x4B , 0x03 , 0x04 ] ) ) ;
178+ fs . writeFileSync ( testFile , Buffer . from ( [ 0x50 , 0x4b , 0x03 , 0x04 ] ) ) ;
148179
149- const result = runCLIExpectError ( `translate "${ testFile } " --to es` , 'test-key:fx' ) ;
180+ const result = runCLIExpectError (
181+ `translate "${ testFile } " --to es` ,
182+ 'test-key:fx'
183+ ) ;
150184
151185 expect ( result . output ) . not . toMatch ( / u n s u p p o r t e d .* f i l e .* t y p e / i) ;
152186 } ) ;
@@ -155,7 +189,10 @@ describe('Document Translation E2E', () => {
155189 const testFile = path . join ( testDir , 'page.html' ) ;
156190 fs . writeFileSync ( testFile , '<html><body>Test</body></html>' ) ;
157191
158- const result = runCLIExpectError ( `translate "${ testFile } " --to es` , 'test-key:fx' ) ;
192+ const result = runCLIExpectError (
193+ `translate "${ testFile } " --to es` ,
194+ 'test-key:fx'
195+ ) ;
159196
160197 expect ( result . output ) . not . toMatch ( / u n s u p p o r t e d .* f i l e .* t y p e / i) ;
161198 } ) ;
@@ -164,7 +201,10 @@ describe('Document Translation E2E', () => {
164201 const testFile = path . join ( testDir , 'page.htm' ) ;
165202 fs . writeFileSync ( testFile , '<html><body>Test</body></html>' ) ;
166203
167- const result = runCLIExpectError ( `translate "${ testFile } " --to es` , 'test-key:fx' ) ;
204+ const result = runCLIExpectError (
205+ `translate "${ testFile } " --to es` ,
206+ 'test-key:fx'
207+ ) ;
168208
169209 expect ( result . output ) . not . toMatch ( / u n s u p p o r t e d .* f i l e .* t y p e / i) ;
170210 } ) ;
@@ -176,7 +216,10 @@ describe('Document Translation E2E', () => {
176216 fs . writeFileSync ( testFile , Buffer . from ( [ 0x25 , 0x50 , 0x44 , 0x46 ] ) ) ;
177217
178218 // Will fail at API call but test that command structure is correct
179- const result = runCLIExpectError ( `translate "${ testFile } " --to es` , 'test-key:fx' ) ;
219+ const result = runCLIExpectError (
220+ `translate "${ testFile } " --to es` ,
221+ 'test-key:fx'
222+ ) ;
180223
181224 // Should not fail due to output path issues
182225 expect ( result . output ) . not . toMatch ( / i n v a l i d .* o u t p u t .* p a t h / i) ;
@@ -187,7 +230,10 @@ describe('Document Translation E2E', () => {
187230 const outputFile = path . join ( testDir , 'output-es.pdf' ) ;
188231 fs . writeFileSync ( testFile , Buffer . from ( [ 0x25 , 0x50 , 0x44 , 0x46 ] ) ) ;
189232
190- const result = runCLIExpectError ( `translate "${ testFile } " --to es --output "${ outputFile } "` , 'test-key:fx' ) ;
233+ const result = runCLIExpectError (
234+ `translate "${ testFile } " --to es --output "${ outputFile } "` ,
235+ 'test-key:fx'
236+ ) ;
191237
192238 // Should not fail due to flag parsing
193239 expect ( result . output ) . not . toMatch ( / u n k n o w n o p t i o n .* o u t p u t / i) ;
@@ -197,10 +243,15 @@ describe('Document Translation E2E', () => {
197243 const testFile = path . join ( testDir , 'input.pdf' ) ;
198244 fs . writeFileSync ( testFile , Buffer . from ( [ 0x25 , 0x50 , 0x44 , 0x46 ] ) ) ;
199245
200- const result = runCLIExpectError ( `translate "${ testFile } " --to es --output` , 'test-key' ) ;
246+ const result = runCLIExpectError (
247+ `translate "${ testFile } " --to es --output` ,
248+ 'test-key'
249+ ) ;
201250
202251 expect ( result . status ) . toBeGreaterThan ( 0 ) ;
203- expect ( result . output ) . toMatch ( / a r g u m e n t m i s s i n g | m i s s i n g .* a r g u m e n t | e x p e c t e d .* a r g u m e n t / i) ;
252+ expect ( result . output ) . toMatch (
253+ / a r g u m e n t m i s s i n g | m i s s i n g .* a r g u m e n t | e x p e c t e d .* a r g u m e n t / i
254+ ) ;
204255 } ) ;
205256 } ) ;
206257
@@ -249,28 +300,38 @@ describe('Document Translation E2E', () => {
249300 const testFile = path . join ( testDir , 'doc.pdf' ) ;
250301 fs . writeFileSync ( testFile , Buffer . from ( [ 0x25 , 0x50 , 0x44 , 0x46 ] ) ) ;
251302
252- const result = runCLIExpectError ( `translate "${ testFile } "` , 'test-key:fx' ) ;
303+ const result = runCLIExpectError (
304+ `translate "${ testFile } "` ,
305+ 'test-key:fx'
306+ ) ;
253307
254308 expect ( result . status ) . toBeGreaterThan ( 0 ) ;
255- expect ( result . output ) . toMatch ( / r e q u i r e d o p t i o n .* - - t o | t a r g e t .* l a n g u a g e | N o t a r g e t l a n g u a g e s p e c i f i e d | m i s s i n g .* - - t o / i) ;
309+ expect ( result . output ) . toMatch (
310+ / r e q u i r e d o p t i o n .* - - t o | t a r g e t .* l a n g u a g e | N o t a r g e t l a n g u a g e s p e c i f i e d | m i s s i n g .* - - t o / i
311+ ) ;
256312 } ) ;
257313
258314 it ( 'should handle authentication errors gracefully' , ( ) => {
259315 const testFile = path . join ( testDir , 'doc.pdf' ) ;
260316 fs . writeFileSync ( testFile , Buffer . from ( [ 0x25 , 0x50 , 0x44 , 0x46 ] ) ) ;
261317
262- const result = runCLIExpectError ( `translate "${ testFile } " --to es` , 'invalid-key' ) ;
318+ const result = runCLIExpectError (
319+ `translate "${ testFile } " --to es` ,
320+ 'invalid-key'
321+ ) ;
263322
264323 expect ( result . status ) . toBeGreaterThan ( 0 ) ;
265324 // Should show meaningful error message
266325 expect ( result . output ) . toMatch ( / e r r o r | a u t h e n t i c a t i o n | i n v a l i d / i) ;
267326 } ) ;
268327
269328 it ( 'should exit with non-zero code on error' , ( ) => {
270- const result = runCLIExpectError ( 'translate /nonexistent.pdf --to es' , 'test-key' ) ;
329+ const result = runCLIExpectError (
330+ 'translate /nonexistent.pdf --to es' ,
331+ 'test-key'
332+ ) ;
271333
272334 expect ( result . status ) . toBeGreaterThan ( 0 ) ;
273335 } ) ;
274336 } ) ;
275-
276337} ) ;
0 commit comments