mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-01 09:17:08 +02:00
fix(HighLevel Node): Encode contact lookup query parameters (#31365)
Some checks are pending
CI: Master (Build, Test, Lint) / Build for Github Cache (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (22.22.3) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (24.15.0) (push) Waiting to run
CI: Master (Build, Test, Lint) / Lint (push) Waiting to run
CI: Master (Build, Test, Lint) / Performance (push) Waiting to run
CI: Master (Build, Test, Lint) / Notify Slack on failure (push) Blocked by required conditions
Some checks are pending
CI: Master (Build, Test, Lint) / Build for Github Cache (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (22.22.3) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (24.15.0) (push) Waiting to run
CI: Master (Build, Test, Lint) / Lint (push) Waiting to run
CI: Master (Build, Test, Lint) / Performance (push) Waiting to run
CI: Master (Build, Test, Lint) / Notify Slack on failure (push) Blocked by required conditions
Co-authored-by: Dawid Myslak <dawid.myslak@gmail.com>
This commit is contained in:
parent
c4fc0447c0
commit
8635dcde23
|
|
@ -100,7 +100,7 @@ export const contactOperations: INodeProperties[] = [
|
|||
routing: {
|
||||
request: {
|
||||
method: 'GET',
|
||||
url: '=/contacts/lookup?email={{$parameter.email}}&phone={{$parameter.phone}}',
|
||||
url: '/contacts/lookup',
|
||||
},
|
||||
output: {
|
||||
postReceive: [
|
||||
|
|
@ -830,6 +830,12 @@ const lookupProperties: INodeProperties[] = [
|
|||
},
|
||||
},
|
||||
default: '',
|
||||
routing: {
|
||||
send: {
|
||||
type: 'query',
|
||||
property: 'email',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Phone',
|
||||
|
|
@ -844,6 +850,12 @@ const lookupProperties: INodeProperties[] = [
|
|||
},
|
||||
},
|
||||
default: '',
|
||||
routing: {
|
||||
send: {
|
||||
type: 'query',
|
||||
property: 'phone',
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
import type { INodeProperties, INodePropertyOptions } from 'n8n-workflow';
|
||||
|
||||
import { contactFields, contactOperations } from '../description/ContactDescription';
|
||||
|
||||
// Reach into the actual routing config so the test breaks if the lookup
|
||||
// operation stops sending its inputs as discrete query parameters.
|
||||
const lookupOperation = (contactOperations[0].options as INodePropertyOptions[]).find(
|
||||
(option) => option.value === 'lookup',
|
||||
);
|
||||
|
||||
const findLookupField = (name: string): INodeProperties => {
|
||||
const field = contactFields.find(
|
||||
(candidate) =>
|
||||
candidate.name === name &&
|
||||
((candidate.displayOptions?.show?.operation as string[] | undefined) ?? []).includes(
|
||||
'lookup',
|
||||
),
|
||||
);
|
||||
|
||||
if (!field) {
|
||||
throw new Error(`Expected to find lookup field "${name}"`);
|
||||
}
|
||||
|
||||
return field;
|
||||
};
|
||||
|
||||
describe('HighLevel V1 - Contact Lookup query parameters', () => {
|
||||
it('builds the request from a static path, not by interpolating user input into the URL', () => {
|
||||
expect(lookupOperation?.routing?.request?.url).toBe('/contacts/lookup');
|
||||
});
|
||||
|
||||
it('sends email and phone as discrete query parameters', () => {
|
||||
expect(findLookupField('email').routing?.send).toEqual({ type: 'query', property: 'email' });
|
||||
expect(findLookupField('phone').routing?.send).toEqual({ type: 'query', property: 'phone' });
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user