From ccca4c4e90a34fc6f15a21699890a236abe05bf2 Mon Sep 17 00:00:00 2001 From: r00gm Date: Wed, 13 Nov 2024 08:56:08 +0100 Subject: [PATCH] trigger node test --- .../src/components/RunDataSchema.test.ts | 14 +++-- .../src/components/RunDataSchemaItem.vue | 5 +- .../__snapshots__/RunDataSchema.test.ts.snap | 51 +++++++++++++++---- .../src/composables/useDataSchema.ts | 3 +- 4 files changed, 55 insertions(+), 18 deletions(-) diff --git a/packages/editor-ui/src/components/RunDataSchema.test.ts b/packages/editor-ui/src/components/RunDataSchema.test.ts index 8fd93f41b1..b4f99517cd 100644 --- a/packages/editor-ui/src/components/RunDataSchema.test.ts +++ b/packages/editor-ui/src/components/RunDataSchema.test.ts @@ -9,7 +9,7 @@ import { defaultNodeDescriptions, mockNodeTypeDescription, } from '@/__tests__/mocks'; -import { IF_NODE_TYPE, SET_NODE_TYPE } from '@/constants'; +import { IF_NODE_TYPE, SET_NODE_TYPE, MANUAL_TRIGGER_NODE_TYPE } from '@/constants'; import { useNodeTypesStore } from '@/stores/nodeTypes.store'; import { mock } from 'vitest-mock-extended'; import type { IWorkflowDb } from '@/Interface'; @@ -17,8 +17,8 @@ import { NodeConnectionType, type IDataObject } from 'n8n-workflow'; import * as nodeHelpers from '@/composables/useNodeHelpers'; const mockNode1 = createTestNode({ - name: 'Set1', - type: SET_NODE_TYPE, + name: 'Manual Trigger', + type: MANUAL_TRIGGER_NODE_TYPE, typeVersion: 1, disabled: false, }); @@ -68,6 +68,10 @@ async function setupStore() { nodeTypesStore.setNodeTypes([ ...defaultNodeDescriptions, + mockNodeTypeDescription({ + name: MANUAL_TRIGGER_NODE_TYPE, + outputs: [NodeConnectionType.Main], + }), mockNodeTypeDescription({ name: IF_NODE_TYPE, outputs: [NodeConnectionType.Main, NodeConnectionType.Main], @@ -128,7 +132,7 @@ describe('RunDataSchema.vue', () => { connectionType: 'main', search: '', nodes: [ - { name: 'Set1', indicies: [], depth: 1 }, + { name: 'Manual Trigger', indicies: [], depth: 1 }, { name: 'Set2', indicies: [], depth: 2 }, ], }, @@ -164,7 +168,7 @@ describe('RunDataSchema.vue', () => { const { getAllByTestId } = renderComponent(); const headers = getAllByTestId('run-data-schema-header'); expect(headers.length).toBe(2); - expect(headers[0]).toHaveTextContent('Set1'); + expect(headers[0]).toHaveTextContent('Manual Trigger'); expect(headers[0]).toHaveTextContent('2 items'); expect(headers[1]).toHaveTextContent('Set2'); diff --git a/packages/editor-ui/src/components/RunDataSchemaItem.vue b/packages/editor-ui/src/components/RunDataSchemaItem.vue index ceb918be24..0cf7686bcd 100644 --- a/packages/editor-ui/src/components/RunDataSchemaItem.vue +++ b/packages/editor-ui/src/components/RunDataSchemaItem.vue @@ -10,10 +10,9 @@ type Props = { expression?: string; value?: string; id: string; - icon?: string; + icon: string; collapsable?: boolean; nodeType?: string; - type: 'item'; highlight?: boolean; draggable?: boolean; collapsed?: boolean; @@ -45,7 +44,7 @@ const emit = defineEmits<{ class="pill" :class="{ 'pill--highlight': highlight }" > - + diff --git a/packages/editor-ui/src/components/__snapshots__/RunDataSchema.test.ts.snap b/packages/editor-ui/src/components/__snapshots__/RunDataSchema.test.ts.snap index 539a9c7c3a..4381b71363 100644 --- a/packages/editor-ui/src/components/__snapshots__/RunDataSchema.test.ts.snap +++ b/packages/editor-ui/src/components/__snapshots__/RunDataSchema.test.ts.snap @@ -175,6 +175,7 @@ exports[`RunDataSchema.vue > renders schema in output pane 1`] = ` data-test-id="run-data-schema-item" data-v-46dade00="" data-v-ce2825e7="" + type="item" >
renders schema in output pane 1`] = ` data-test-id="run-data-schema-item" data-v-46dade00="" data-v-ce2825e7="" + type="item" >
renders schema in output pane 1`] = ` data-test-id="run-data-schema-item" data-v-46dade00="" data-v-ce2825e7="" + type="item" >
renders schema in output pane 1`] = ` data-test-id="run-data-schema-item" data-v-46dade00="" data-v-ce2825e7="" + type="item" >
renders schema in output pane 1`] = ` data-test-id="run-data-schema-item" data-v-46dade00="" data-v-ce2825e7="" + type="item" >
renders schema with spaces and dots 1`] = ` data-test-id="run-data-schema-header" data-v-46dade00="" data-v-c0d66716="" - id="Set1" + id="Manual Trigger" type="header" >
renders schema with spaces and dots 1`] = ` />
renders schema with spaces and dots 1`] = ` class="title" data-v-c0d66716="" > - Set1 + Manual Trigger
- +
renders schema with spaces and dots 1`] = ` data-test-id="run-data-schema-item" data-v-46dade00="" data-v-ce2825e7="" + type="item" >
renders schema with spaces and dots 1`] = ` data-depth="1" data-name="hello world" data-nest-level="1" - data-node-type="n8n-nodes-base.set" + data-node-type="n8n-nodes-base.manualTrigger" data-path="['hello world']" data-target="mappable" data-v-ce2825e7="" @@ -763,6 +791,7 @@ exports[`RunDataSchema.vue > renders schema with spaces and dots 1`] = ` data-test-id="run-data-schema-item" data-v-46dade00="" data-v-ce2825e7="" + type="item" >
renders schema with spaces and dots 1`] = ` data-depth="1" data-name="hello world[0]" data-nest-level="2" - data-node-type="n8n-nodes-base.set" + data-node-type="n8n-nodes-base.manualTrigger" data-path="['hello world'][0]" data-target="mappable" data-v-ce2825e7="" @@ -858,6 +887,7 @@ exports[`RunDataSchema.vue > renders schema with spaces and dots 1`] = ` data-test-id="run-data-schema-item" data-v-46dade00="" data-v-ce2825e7="" + type="item" >
renders schema with spaces and dots 1`] = ` data-depth="1" data-name="test" data-nest-level="3" - data-node-type="n8n-nodes-base.set" + data-node-type="n8n-nodes-base.manualTrigger" data-path="['hello world'][0].test" data-target="mappable" data-v-ce2825e7="" @@ -953,6 +983,7 @@ exports[`RunDataSchema.vue > renders schema with spaces and dots 1`] = ` data-test-id="run-data-schema-item" data-v-46dade00="" data-v-ce2825e7="" + type="item" >
renders schema with spaces and dots 1`] = ` data-depth="1" data-name="more to think about" data-nest-level="4" - data-node-type="n8n-nodes-base.set" + data-node-type="n8n-nodes-base.manualTrigger" data-path="['hello world'][0].test['more to think about']" data-target="mappable" data-v-ce2825e7="" @@ -1027,6 +1058,7 @@ exports[`RunDataSchema.vue > renders schema with spaces and dots 1`] = ` data-test-id="run-data-schema-item" data-v-46dade00="" data-v-ce2825e7="" + type="item" >
renders schema with spaces and dots 1`] = ` data-depth="1" data-name="test.how" data-nest-level="3" - data-node-type="n8n-nodes-base.set" + data-node-type="n8n-nodes-base.manualTrigger" data-path="['hello world'][0]['test.how']" data-target="mappable" data-v-ce2825e7="" @@ -1169,6 +1201,7 @@ exports[`RunDataSchema.vue > renders schema with spaces and dots 1`] = ` data-test-id="run-data-schema-item" data-v-46dade00="" data-v-ce2825e7="" + type="item" >
{ if (isDataEmpty(item.schema)) { acc.push({ id: `empty-${index}`, + icon: '', value: useI18n().baseText('dataMapping.schemaView.emptyData'), type: 'item', });