mirror of
https://github.com/n8n-io/n8n.git
synced 2026-08-29 01:39:24 +08:00
fix: Use MS Excel as default Sheets export format (#36406)
Co-authored-by: n8n-cat-bot[bot] <n8n-cat-bot[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -91,4 +91,42 @@ describe('test GoogleDriveV2: file download', () => {
|
||||
{ encoding: 'arraybuffer', json: false, returnFullResponse: true, useStream: true },
|
||||
);
|
||||
});
|
||||
|
||||
it('should export Google Sheets with a supported format by default', async () => {
|
||||
const nodeParameters = {
|
||||
operation: 'download',
|
||||
fileId: {
|
||||
__rl: true,
|
||||
value: 'fileIDxxxxxx',
|
||||
mode: 'list',
|
||||
},
|
||||
options: {},
|
||||
};
|
||||
|
||||
(transport.googleApiRequest as Mock)
|
||||
.mockResolvedValueOnce({ mimeType: 'application/vnd.google-apps.spreadsheet', name: 'test' })
|
||||
.mockResolvedValueOnce({
|
||||
headers: {
|
||||
'content-type': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
},
|
||||
body: Buffer.from(''),
|
||||
});
|
||||
|
||||
const fakeExecuteFunction = createMockExecuteFunction(nodeParameters, driveNode);
|
||||
await download.execute.call(fakeExecuteFunction, 0, { json: {} });
|
||||
|
||||
expect(transport.googleApiRequest).toHaveBeenCalledTimes(2);
|
||||
expect(transport.googleApiRequest).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
'GET',
|
||||
'/drive/v3/files/fileIDxxxxxx/export',
|
||||
{},
|
||||
{
|
||||
mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
supportsAllDrives: true,
|
||||
},
|
||||
undefined,
|
||||
{ encoding: 'arraybuffer', json: false, returnFullResponse: true, useStream: true },
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -232,7 +232,7 @@ export async function execute(
|
||||
mime = this.getNodeParameter(
|
||||
`${parameterKey}.sheetsToFormat`,
|
||||
i,
|
||||
'application/x-vnd.oasis.opendocument.spreadsheet',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
) as string;
|
||||
} else {
|
||||
mime = this.getNodeParameter(`${parameterKey}.drawingsToFormat`, i, 'image/jpeg') as string;
|
||||
|
||||
Reference in New Issue
Block a user