mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-16 21:19:43 +02:00
fix: Correct operation defaults to valid options in several nodes
Five 'options' operation selectors declared a default that isn't one of their own option values, so the operation loaded with no valid selection: - Spotify (Track): 'track' -> 'get' - Bitwarden (Event): 'get' -> 'getAll' - Mautic (Company Contact): 'create' -> 'add' - Microsoft Outlook v1 (Folder Message): 'create' -> 'getAll' - n8n (Audit): 'get' -> 'generate' Add a unit test asserting each fixed selector's default is a valid option value. Closes #32347
This commit is contained in:
parent
524d4e8fb8
commit
509833a689
|
|
@ -6,7 +6,7 @@ export const eventOperations: INodeProperties[] = [
|
|||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
default: 'get',
|
||||
default: 'getAll',
|
||||
options: [
|
||||
{
|
||||
name: 'Get Many',
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export const companyContactOperations: INodeProperties[] = [
|
|||
action: 'Remove a company contact',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
default: 'add',
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export const folderMessageOperations: INodeProperties[] = [
|
|||
action: 'Get many folder messages',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
default: 'getAll',
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export const auditOperations: INodeProperties[] = [
|
|||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
default: 'get',
|
||||
default: 'generate',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['audit'],
|
||||
|
|
|
|||
|
|
@ -563,7 +563,7 @@ export class Spotify implements INodeType {
|
|||
action: 'Search tracks by keyword',
|
||||
},
|
||||
],
|
||||
default: 'track',
|
||||
default: 'get',
|
||||
},
|
||||
{
|
||||
displayName: 'Track ID',
|
||||
|
|
|
|||
49
packages/nodes-base/test/nodes/operationDefaults.test.ts
Normal file
49
packages/nodes-base/test/nodes/operationDefaults.test.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { eventOperations } from '../../nodes/Bitwarden/descriptions/EventDescription';
|
||||
import { companyContactOperations } from '../../nodes/Mautic/CompanyContactDescription';
|
||||
import { folderMessageOperations } from '../../nodes/Microsoft/Outlook/v1/FolderMessageDecription';
|
||||
import { auditOperations } from '../../nodes/N8n/AuditDescription';
|
||||
import { Spotify } from '../../nodes/Spotify/Spotify.node';
|
||||
|
||||
/**
|
||||
* Asserts that for every `type: 'options'` parameter that declares a static
|
||||
* list of options and a non-empty string default, the default is one of the
|
||||
* option values. Parameters with dynamically loaded options (no static
|
||||
* `options` array) are skipped.
|
||||
*/
|
||||
function expectOptionDefaultsToBeValid(properties: INodeProperties[]) {
|
||||
for (const property of properties) {
|
||||
if (property.type !== 'options') continue;
|
||||
if (!Array.isArray(property.options) || property.options.length === 0) continue;
|
||||
if (typeof property.default !== 'string' || property.default === '') continue;
|
||||
|
||||
const validValues = property.options
|
||||
.map((option) => ('value' in option ? option.value : undefined))
|
||||
.filter((value): value is string | number => value !== undefined);
|
||||
|
||||
expect(validValues).toContain(property.default);
|
||||
}
|
||||
}
|
||||
|
||||
describe('operation parameter defaults', () => {
|
||||
it('Bitwarden Event operation default is a valid option', () => {
|
||||
expectOptionDefaultsToBeValid(eventOperations);
|
||||
});
|
||||
|
||||
it('Mautic Company Contact operation default is a valid option', () => {
|
||||
expectOptionDefaultsToBeValid(companyContactOperations);
|
||||
});
|
||||
|
||||
it('Microsoft Outlook v1 Folder Message operation default is a valid option', () => {
|
||||
expectOptionDefaultsToBeValid(folderMessageOperations);
|
||||
});
|
||||
|
||||
it('n8n Audit operation default is a valid option', () => {
|
||||
expectOptionDefaultsToBeValid(auditOperations);
|
||||
});
|
||||
|
||||
it('Spotify operation defaults are valid options', () => {
|
||||
expectOptionDefaultsToBeValid(new Spotify().description.properties);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user