mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(editor): Fix options parameters that have extra displayName field (#13928)
This commit is contained in:
@@ -143,6 +143,52 @@ describe('ParameterInput.vue', () => {
|
||||
expect(emitted('update')).toContainEqual([expect.objectContaining({ value: 'append' })]);
|
||||
});
|
||||
|
||||
test('should render an options parameter even if it has invalid fields (like displayName)', async () => {
|
||||
// Test case based on the Schedule node
|
||||
// type=options parameters shouldn't have a displayName field, but some do
|
||||
const { container, baseElement, emitted } = renderComponent(ParameterInput, {
|
||||
pinia: createTestingPinia(),
|
||||
props: {
|
||||
path: 'operation',
|
||||
parameter: {
|
||||
displayName: 'Trigger at Hour',
|
||||
name: 'triggerAtHour',
|
||||
type: 'options',
|
||||
default: 0,
|
||||
options: [
|
||||
{
|
||||
name: 'Midnight',
|
||||
displayName: 'Midnight',
|
||||
value: 0,
|
||||
},
|
||||
{
|
||||
name: '1am',
|
||||
displayName: '1am',
|
||||
value: 1,
|
||||
},
|
||||
],
|
||||
description: 'The hour of the day to trigger',
|
||||
},
|
||||
modelValue: 0,
|
||||
},
|
||||
});
|
||||
const select = container.querySelector('input') as HTMLInputElement;
|
||||
const selectTrigger = container.querySelector('.select-trigger') as HTMLElement;
|
||||
|
||||
await waitFor(() => expect(select).toHaveValue('Midnight'));
|
||||
|
||||
await userEvent.click(selectTrigger);
|
||||
|
||||
const options = baseElement.querySelectorAll('.list-option');
|
||||
expect(options.length).toEqual(2);
|
||||
expect(options[0].querySelector('.option-headline')).toHaveTextContent('Midnight');
|
||||
expect(options[1].querySelector('.option-headline')).toHaveTextContent('1am');
|
||||
|
||||
await userEvent.click(options[1]);
|
||||
|
||||
expect(emitted('update')).toContainEqual([expect.objectContaining({ value: 1 })]);
|
||||
});
|
||||
|
||||
test('should render a string parameter', async () => {
|
||||
const { container, emitted } = renderComponent(ParameterInput, {
|
||||
pinia: createTestingPinia(),
|
||||
|
||||
@@ -23,7 +23,7 @@ import type {
|
||||
IParameterLabel,
|
||||
NodeParameterValueType,
|
||||
} from 'n8n-workflow';
|
||||
import { CREDENTIAL_EMPTY_VALUE, isINodePropertyOptions, NodeHelpers } from 'n8n-workflow';
|
||||
import { CREDENTIAL_EMPTY_VALUE, NodeHelpers } from 'n8n-workflow';
|
||||
|
||||
import CodeNodeEditor from '@/components/CodeNodeEditor/CodeNodeEditor.vue';
|
||||
import CredentialsSelect from '@/components/CredentialsSelect.vue';
|
||||
@@ -574,7 +574,7 @@ const shouldCaptureForPosthog = computed(() => {
|
||||
function isValidParameterOption(
|
||||
option: INodePropertyOptions | INodeProperties | INodePropertyCollection,
|
||||
): option is INodePropertyOptions {
|
||||
return isINodePropertyOptions(option) && isPresent(option.value) && isPresent(option.name);
|
||||
return 'value' in option && isPresent(option.value) && isPresent(option.name);
|
||||
}
|
||||
|
||||
function isRemoteParameterOption(option: INodePropertyOptions) {
|
||||
|
||||
Reference in New Issue
Block a user