|
5 | 5 | getQuickBooksAttachmentTarget, |
6 | 6 | parseQuickBooksAttachableResponse, |
7 | 7 | QUICKBOOKS_FILE_TOOL_RESPONSE_MAX_BYTES, |
| 8 | + sanitizeQuickBooksAttachable, |
8 | 9 | sanitizeQuickBooksFileName, |
9 | 10 | validateQuickBooksAttachmentFileType, |
10 | 11 | } from '@/tools/quickbooks/documents_utils' |
@@ -191,6 +192,45 @@ describe('QuickBooks attachment metadata reads', () => { |
191 | 192 | }) |
192 | 193 | }) |
193 | 194 |
|
| 195 | + it('removes Intuit attachment access URLs from parsed and listed metadata', async () => { |
| 196 | + const attachment = { |
| 197 | + Id: '9', |
| 198 | + FileName: 'receipt.pdf', |
| 199 | + FileAccessUri: 'https://example.invalid/file', |
| 200 | + TempDownloadUri: 'https://example.invalid/temp?token=secret', |
| 201 | + TemporaryDownloadUri: 'https://example.invalid/temporary?token=secret', |
| 202 | + ThumbnailFileAccessUri: 'https://example.invalid/thumbnail', |
| 203 | + ThumbnailTempDownloadUri: 'https://example.invalid/thumbnail-temp?token=secret', |
| 204 | + } |
| 205 | + |
| 206 | + expect(sanitizeQuickBooksAttachable(attachment)).toEqual({ |
| 207 | + Id: '9', |
| 208 | + FileName: 'receipt.pdf', |
| 209 | + }) |
| 210 | + |
| 211 | + await expect( |
| 212 | + parseQuickBooksAttachableResponse(Response.json({ Attachable: attachment })) |
| 213 | + ).resolves.toEqual({ |
| 214 | + attachment: { Id: '9', FileName: 'receipt.pdf' }, |
| 215 | + time: null, |
| 216 | + }) |
| 217 | + |
| 218 | + const params: QuickBooksReadAttachmentsParams = { |
| 219 | + ...auth, |
| 220 | + readMode: 'list', |
| 221 | + targetType: 'invoice', |
| 222 | + targetId: '88', |
| 223 | + } |
| 224 | + await expect( |
| 225 | + quickbooksReadAttachmentsTool.transformResponse!( |
| 226 | + Response.json({ QueryResponse: { Attachable: [attachment] } }), |
| 227 | + params |
| 228 | + ) |
| 229 | + ).resolves.toMatchObject({ |
| 230 | + output: { items: [{ Id: '9', FileName: 'receipt.pdf' }] }, |
| 231 | + }) |
| 232 | + }) |
| 233 | + |
194 | 234 | it('surfaces sanitized faults from successful upload envelopes', async () => { |
195 | 235 | const response = Response.json({ |
196 | 236 | AttachableResponse: [ |
|
0 commit comments