Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/n8n-io/n8n into node-2187-…
Browse files Browse the repository at this point in the history
…form-node-completion-redirect-page-returns-an-error
  • Loading branch information
michael-radency committed Jan 6, 2025
2 parents ca1c631 + d7cc789 commit 21043b2
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 9 deletions.
12 changes: 7 additions & 5 deletions cypress/e2e/14-mapping.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ describe('Data mapping', () => {
});

it('maps expressions from json view', () => {
// ADO-3063 - followup to make this viewport global
cy.viewport('macbook-16');
cy.fixture('Test_workflow_3.json').then((data) => {
cy.get('body').paste(JSON.stringify(data));
});
Expand All @@ -123,17 +125,17 @@ describe('Data mapping', () => {
workflowPage.actions.openNode('Set');
ndv.actions.switchInputMode('JSON');

ndv.getters.inputDataContainer().should('exist');

ndv.getters
.inputDataContainer()
.should('exist')
.find('.json-data')
.should(
'have.text',
'[{"input": [{"count": 0,"with space": "!!","with.dot": "!!","with"quotes": "!!"}]},{"input": [{"count": 1}]}]',
)
.find('span')
.contains('"count"')
.realMouseDown();
);

ndv.getters.inputDataContainer().find('span').contains('"count"').realMouseDown();

ndv.actions.mapToParameter('value');
ndv.getters.inlineExpressionEditorInput().should('have.text', '{{ $json.input[0].count }}');
Expand Down
4 changes: 2 additions & 2 deletions packages/@n8n/nodes-langchain/utils/descriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const inputSchemaField: INodeProperties = {
};

export const promptTypeOptions: INodeProperties = {
displayName: 'Prompt Source (User Message)',
displayName: 'Source for Prompt (User Message)',
name: 'promptType',
type: 'options',
options: [
Expand Down Expand Up @@ -98,7 +98,7 @@ export const textInput: INodeProperties = {
};

export const textFromPreviousNode: INodeProperties = {
displayName: 'Text From Previous Node',
displayName: 'Prompt (User Message)',
name: 'text',
type: 'string',
required: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/nodes-base/nodes/Supabase/Supabase.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ export class Supabase implements INodeType {

if (keys.length !== 0) {
if (matchType === 'allFilters') {
const data = keys.reduce((obj, value) => buildQuery(obj, value), {});
Object.assign(qs, data);
const data = keys.map((key) => buildOrQuery(key));
Object.assign(qs, { and: `(${data.join(',')})` });
}
if (matchType === 'anyFilter') {
const data = keys.map((key) => buildOrQuery(key));
Expand Down
99 changes: 99 additions & 0 deletions packages/nodes-base/nodes/Supabase/tests/Supabase.node.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { mock } from 'jest-mock-extended';
import { get } from 'lodash';
import {
type IDataObject,
type IExecuteFunctions,
type IGetNodeParameterOptions,
type INodeExecutionData,
type IPairedItemData,
NodeOperationError,
} from 'n8n-workflow';

import * as utils from '../GenericFunctions';
import { Supabase } from '../Supabase.node';

describe('Test Supabase Node', () => {
const node = new Supabase();

const input = [{ json: {} }];

const createMockExecuteFunction = (
nodeParameters: IDataObject,
continueOnFail: boolean = false,
) => {
const fakeExecuteFunction = {
getNodeParameter(
parameterName: string,
itemIndex: number,
fallbackValue?: IDataObject | undefined,
options?: IGetNodeParameterOptions | undefined,
) {
const parameter = options?.extractValue ? `${parameterName}.value` : parameterName;

const parameterValue = get(nodeParameters, parameter, fallbackValue);

if ((parameterValue as IDataObject)?.nodeOperationError) {
throw new NodeOperationError(mock(), 'Get Options Error', { itemIndex });
}

return parameterValue;
},
getNode() {
return node;
},
continueOnFail: () => continueOnFail,
getInputData: () => input,
helpers: {
constructExecutionMetaData: (
_inputData: INodeExecutionData[],
_options: { itemData: IPairedItemData | IPairedItemData[] },
) => [],
returnJsonArray: (_jsonData: IDataObject | IDataObject[]) => [],
},
} as unknown as IExecuteFunctions;
return fakeExecuteFunction;
};

it('should allow filtering on the same field multiple times', async () => {
const supabaseApiRequest = jest
.spyOn(utils, 'supabaseApiRequest')
.mockImplementation(async () => {
return [];
});

const fakeExecuteFunction = createMockExecuteFunction({
resource: 'row',
operation: 'getAll',
returnAll: true,
filterType: 'manual',
matchType: 'allFilters',
tableId: 'my_table',
filters: {
conditions: [
{
condition: 'gt',
keyName: 'created_at',
keyValue: '2025-01-02 08:03:43.952051+00',
},
{
condition: 'lt',
keyName: 'created_at',
keyValue: '2025-01-02 08:07:36.102231+00',
},
],
},
});

await node.execute.call(fakeExecuteFunction);

expect(supabaseApiRequest).toHaveBeenCalledWith(
'GET',
'/my_table',
{},
{
and: '(created_at.gt.2025-01-02 08:03:43.952051+00,created_at.lt.2025-01-02 08:07:36.102231+00)',
offset: 0,
},
);
});
});

0 comments on commit 21043b2

Please sign in to comment.