| 35 | } |
| 36 | |
| 37 | function multipartPayload(fileName: string, file: Buffer): { payload: Buffer; contentType: string } { |
| 38 | const boundary = '----chatlab-import-source-test' |
| 39 | const header = Buffer.from( |
| 40 | [ |
| 41 | `--${boundary}`, |
| 42 | `Content-Disposition: form-data; name="file"; filename="${fileName}"`, |
| 43 | 'Content-Type: application/zip', |
| 44 | '', |
| 45 | '', |
| 46 | ].join('\r\n') |
| 47 | ) |
| 48 | const footer = Buffer.from(`\r\n--${boundary}--\r\n`) |
| 49 | return { |
| 50 | payload: Buffer.concat([header, file, footer]), |
| 51 | contentType: `multipart/form-data; boundary=${boundary}`, |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | describe('CLI Web archive import source routes', () => { |
| 56 | it('uploads once, reuses the source for imports, and releases idempotently', async () => { |