first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled

This commit is contained in:
2026-03-17 16:22:57 +03:30
commit 3d5eaf9445
15349 changed files with 2847338 additions and 0 deletions
@@ -0,0 +1,108 @@
import type { IHttpRequestMethods } from 'n8n-workflow';
import * as search from '../../../../v2/actions/fileFolder/search.operation';
import * as transport from '../../../../v2/transport';
import { createMockExecuteFunction, driveNode } from '../helpers';
jest.mock('../../../../v2/transport', () => {
const originalModule = jest.requireActual('../../../../v2/transport');
return {
...originalModule,
googleApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
if (method === 'GET') {
return {};
}
}),
googleApiRequestAllItems: jest.fn(async function (method: IHttpRequestMethods) {
if (method === 'GET') {
return {};
}
}),
};
});
describe('test GoogleDriveV2: fileFolder search', () => {
it('returnAll = false', async () => {
const nodeParameters = {
searchMethod: 'name',
resource: 'fileFolder',
queryString: 'test',
returnAll: false,
limit: 2,
filter: {
whatToSearch: 'files',
fileTypes: ['application/vnd.google-apps.document'],
},
options: {
fields: ['id', 'name', 'starred', 'version'],
},
};
const fakeExecuteFunction = createMockExecuteFunction(nodeParameters, driveNode);
await search.execute.call(fakeExecuteFunction, 0);
expect(transport.googleApiRequest).toBeCalledTimes(1);
expect(transport.googleApiRequest).toBeCalledWith('GET', '/drive/v3/files', undefined, {
corpora: 'allDrives',
fields: 'nextPageToken, files(id, name, starred, version)',
includeItemsFromAllDrives: true,
pageSize: 2,
q: "name contains 'test' and mimeType != 'application/vnd.google-apps.folder' and trashed = false and (mimeType = 'application/vnd.google-apps.document')",
spaces: 'appDataFolder, drive',
supportsAllDrives: true,
});
});
it('returnAll = true', async () => {
const nodeParameters = {
resource: 'fileFolder',
searchMethod: 'query',
queryString: 'test',
returnAll: true,
filter: {
driveId: {
__rl: true,
value: 'driveID000000123',
mode: 'list',
cachedResultName: 'sharedDrive',
cachedResultUrl: 'https://drive.google.com/drive/folders/driveID000000123',
},
folderId: {
__rl: true,
value: 'folderID000000123',
mode: 'list',
cachedResultName: 'testFolder 3',
cachedResultUrl: 'https://drive.google.com/drive/folders/folderID000000123',
},
whatToSearch: 'all',
fileTypes: ['*'],
includeTrashed: true,
},
options: {
fields: ['permissions', 'mimeType'],
},
};
const fakeExecuteFunction = createMockExecuteFunction(nodeParameters, driveNode);
await search.execute.call(fakeExecuteFunction, 0);
expect(transport.googleApiRequestAllItems).toBeCalledTimes(1);
expect(transport.googleApiRequestAllItems).toBeCalledWith(
'GET',
'files',
'/drive/v3/files',
{},
{
corpora: 'drive',
driveId: 'driveID000000123',
fields: 'nextPageToken, files(permissions, mimeType)',
includeItemsFromAllDrives: true,
q: "test and 'folderID000000123' in parents",
spaces: 'appDataFolder, drive',
supportsAllDrives: true,
},
);
});
});