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:
dhaksdhakshin 2026-06-23 11:57:07 +05:30
parent 524d4e8fb8
commit 509833a689
6 changed files with 54 additions and 5 deletions

View File

@ -6,7 +6,7 @@ export const eventOperations: INodeProperties[] = [
name: 'operation',
type: 'options',
noDataExpression: true,
default: 'get',
default: 'getAll',
options: [
{
name: 'Get Many',

View File

@ -25,7 +25,7 @@ export const companyContactOperations: INodeProperties[] = [
action: 'Remove a company contact',
},
],
default: 'create',
default: 'add',
},
];

View File

@ -19,7 +19,7 @@ export const folderMessageOperations: INodeProperties[] = [
action: 'Get many folder messages',
},
],
default: 'create',
default: 'getAll',
},
];

View File

@ -6,7 +6,7 @@ export const auditOperations: INodeProperties[] = [
name: 'operation',
type: 'options',
noDataExpression: true,
default: 'get',
default: 'generate',
displayOptions: {
show: {
resource: ['audit'],

View File

@ -563,7 +563,7 @@ export class Spotify implements INodeType {
action: 'Search tracks by keyword',
},
],
default: 'track',
default: 'get',
},
{
displayName: 'Track ID',

View 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);
});
});