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
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:
@@ -0,0 +1,112 @@
|
||||
import * as getMany from '../../../../v2/actions/base/getMany.operation';
|
||||
import * as transport from '../../../../v2/transport';
|
||||
import { createMockExecuteFunction } from '../helpers';
|
||||
|
||||
const bases = [
|
||||
{
|
||||
id: 'appXXX',
|
||||
name: 'base 1',
|
||||
permissionLevel: 'create',
|
||||
},
|
||||
{
|
||||
id: 'appYYY',
|
||||
name: 'base 2',
|
||||
permissionLevel: 'edit',
|
||||
},
|
||||
{
|
||||
id: 'appZZZ',
|
||||
name: 'base 3',
|
||||
permissionLevel: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
apiRequest: jest.fn(async function () {
|
||||
return { bases };
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test AirtableV2, base => getMany', () => {
|
||||
it('should return all bases', async () => {
|
||||
const nodeParameters = {
|
||||
resource: 'base',
|
||||
returnAll: true,
|
||||
options: {},
|
||||
};
|
||||
|
||||
const response = await getMany.execute.call(createMockExecuteFunction(nodeParameters));
|
||||
|
||||
expect(transport.apiRequest).toHaveBeenCalledWith('GET', 'meta/bases');
|
||||
|
||||
expect(response).toEqual([
|
||||
{
|
||||
json: {
|
||||
id: 'appXXX',
|
||||
name: 'base 1',
|
||||
permissionLevel: 'create',
|
||||
},
|
||||
pairedItem: [
|
||||
{
|
||||
item: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
json: {
|
||||
id: 'appYYY',
|
||||
name: 'base 2',
|
||||
permissionLevel: 'edit',
|
||||
},
|
||||
pairedItem: [
|
||||
{
|
||||
item: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
json: {
|
||||
id: 'appZZZ',
|
||||
name: 'base 3',
|
||||
permissionLevel: 'create',
|
||||
},
|
||||
pairedItem: [
|
||||
{
|
||||
item: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('should return one base with edit permission', async () => {
|
||||
const nodeParameters = {
|
||||
resource: 'base',
|
||||
returnAll: false,
|
||||
limit: 2,
|
||||
options: { permissionLevel: ['edit'] },
|
||||
};
|
||||
|
||||
const response = await getMany.execute.call(createMockExecuteFunction(nodeParameters));
|
||||
|
||||
expect(transport.apiRequest).toHaveBeenCalledWith('GET', 'meta/bases');
|
||||
|
||||
expect(response).toEqual([
|
||||
{
|
||||
json: {
|
||||
id: 'appYYY',
|
||||
name: 'base 2',
|
||||
permissionLevel: 'edit',
|
||||
},
|
||||
pairedItem: [
|
||||
{
|
||||
item: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
import { mockDeep } from 'jest-mock-extended';
|
||||
import get from 'lodash/get';
|
||||
import type { IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
import * as getSchema from '../../../../v2/actions/base/getSchema.operation';
|
||||
import * as transport from '../../../../v2/transport';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
apiRequest: jest.fn(async function () {
|
||||
return { tables: [] };
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test AirtableV2, base => getSchema', () => {
|
||||
it('should return all bases', async () => {
|
||||
const nodeParameters = {
|
||||
resource: 'base',
|
||||
operation: 'getSchema',
|
||||
base: {
|
||||
value: '={{$json.id}}',
|
||||
},
|
||||
};
|
||||
|
||||
const items = [
|
||||
{
|
||||
json: { id: 'appYobase1' },
|
||||
},
|
||||
{
|
||||
json: { id: 'appYobase2' },
|
||||
},
|
||||
];
|
||||
|
||||
await getSchema.execute.call(
|
||||
mockDeep<IExecuteFunctions>({
|
||||
getInputData: jest.fn(() => items),
|
||||
getNodeParameter: jest.fn((param: string, itemIndex: number) => {
|
||||
if (param === 'base') {
|
||||
return items[itemIndex].json.id;
|
||||
}
|
||||
|
||||
return get(nodeParameters, param);
|
||||
}),
|
||||
}),
|
||||
items,
|
||||
);
|
||||
|
||||
expect(transport.apiRequest).toBeCalledTimes(2);
|
||||
expect(transport.apiRequest).toHaveBeenCalledWith('GET', 'meta/bases/appYobase1/tables');
|
||||
expect(transport.apiRequest).toHaveBeenCalledWith('GET', 'meta/bases/appYobase2/tables');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user