mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix: Show Pinned data in demo mode (#11490)
This commit is contained in:
parent
5b5bd7291d
commit
ca2a583b5c
|
@ -40,6 +40,14 @@ export function getOutputPanelDataContainer() {
|
|||
return getOutputPanel().getByTestId('ndv-data-container');
|
||||
}
|
||||
|
||||
export function getOutputTableRows() {
|
||||
return getOutputPanelDataContainer().find('table tr');
|
||||
}
|
||||
|
||||
export function getOutputTableRow(row: number) {
|
||||
return getOutputTableRows().eq(row);
|
||||
}
|
||||
|
||||
export function getOutputPanelTable() {
|
||||
return getOutputPanelDataContainer().get('table');
|
||||
}
|
||||
|
|
|
@ -69,6 +69,13 @@ export function getNodeCreatorPlusButton() {
|
|||
return cy.getByTestId('node-creator-plus-button');
|
||||
}
|
||||
|
||||
export function getCanvasNodes() {
|
||||
return cy.ifCanvasVersion(
|
||||
() => cy.getByTestId('canvas-node'),
|
||||
() => cy.getByTestId('canvas-node').not('[data-node-type="n8n-nodes-internal.addNodes"]'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Actions
|
||||
*/
|
||||
|
|
|
@ -1,21 +1,29 @@
|
|||
import workflow from '../fixtures/Manual_wait_set.json';
|
||||
import { getOutputTableRow } from '../composables/ndv';
|
||||
import { getCanvasNodes, openNode } from '../composables/workflow';
|
||||
import SIMPLE_WORKFLOW from '../fixtures/Manual_wait_set.json';
|
||||
import WORKFLOW_WITH_PINNED from '../fixtures/Webhook_set_pinned.json';
|
||||
import { importWorkflow, visitDemoPage } from '../pages/demo';
|
||||
import { errorToast } from '../pages/notifications';
|
||||
import { WorkflowPage } from '../pages/workflow';
|
||||
|
||||
const workflowPage = new WorkflowPage();
|
||||
|
||||
describe('Demo', () => {
|
||||
beforeEach(() => {
|
||||
cy.overrideSettings({ previewMode: true });
|
||||
cy.signout();
|
||||
});
|
||||
|
||||
it('can import template', () => {
|
||||
visitDemoPage();
|
||||
errorToast().should('not.exist');
|
||||
importWorkflow(workflow);
|
||||
workflowPage.getters.canvasNodes().should('have.length', 3);
|
||||
importWorkflow(SIMPLE_WORKFLOW);
|
||||
getCanvasNodes().should('have.length', 3);
|
||||
});
|
||||
|
||||
it('can import workflow with pin data', () => {
|
||||
visitDemoPage();
|
||||
importWorkflow(WORKFLOW_WITH_PINNED);
|
||||
getCanvasNodes().should('have.length', 2);
|
||||
openNode('Webhook');
|
||||
getOutputTableRow(0).should('include.text', 'headers');
|
||||
getOutputTableRow(1).should('include.text', 'dragons');
|
||||
});
|
||||
|
||||
it('can override theme to dark', () => {
|
||||
|
|
|
@ -17,12 +17,8 @@ import type {
|
|||
} from '@/Interface';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
|
||||
import {
|
||||
SEND_AND_WAIT_OPERATION,
|
||||
type ExecutionSummary,
|
||||
type IConnection,
|
||||
type INodeExecutionData,
|
||||
} from 'n8n-workflow';
|
||||
import { SEND_AND_WAIT_OPERATION } from 'n8n-workflow';
|
||||
import type { IPinData, ExecutionSummary, IConnection, INodeExecutionData } from 'n8n-workflow';
|
||||
import { stringSizeInBytes } from '@/utils/typesUtils';
|
||||
import { dataPinningEventBus } from '@/event-bus';
|
||||
import { useUIStore } from '@/stores/ui.store';
|
||||
|
@ -599,6 +595,29 @@ describe('useWorkflowsStore', () => {
|
|||
},
|
||||
);
|
||||
});
|
||||
|
||||
it('sets workflow pin data', () => {
|
||||
workflowsStore.workflow.pinData = undefined;
|
||||
const data: IPinData = {
|
||||
TestNode: [{ json: { test: true } }],
|
||||
TestNode1: [{ json: { test: false } }],
|
||||
};
|
||||
workflowsStore.setWorkflowPinData(data);
|
||||
expect(workflowsStore.workflow.pinData).toEqual(data);
|
||||
});
|
||||
|
||||
it('sets workflow pin data, adding json keys', () => {
|
||||
workflowsStore.workflow.pinData = undefined;
|
||||
const data = {
|
||||
TestNode: [{ test: true }],
|
||||
TestNode1: [{ test: false }],
|
||||
};
|
||||
workflowsStore.setWorkflowPinData(data as unknown as IPinData);
|
||||
expect(workflowsStore.workflow.pinData).toEqual({
|
||||
TestNode: [{ json: { test: true } }],
|
||||
TestNode1: [{ json: { test: false } }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('finishActiveExecution', () => {
|
||||
|
|
|
@ -735,14 +735,23 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
|||
};
|
||||
}
|
||||
|
||||
function setWorkflowPinData(pinData?: IPinData) {
|
||||
workflow.value = {
|
||||
...workflow.value,
|
||||
pinData: pinData ?? {},
|
||||
};
|
||||
function setWorkflowPinData(data: IPinData = {}) {
|
||||
const validPinData = Object.keys(data).reduce((accu, nodeName) => {
|
||||
accu[nodeName] = data[nodeName].map((item) => {
|
||||
if (!isJsonKeyObject(item)) {
|
||||
return { json: item };
|
||||
}
|
||||
|
||||
return item;
|
||||
});
|
||||
|
||||
return accu;
|
||||
}, {} as IPinData);
|
||||
|
||||
workflow.value.pinData = validPinData;
|
||||
updateCachedWorkflow();
|
||||
|
||||
dataPinningEventBus.emit('pin-data', pinData ?? {});
|
||||
dataPinningEventBus.emit('pin-data', validPinData);
|
||||
}
|
||||
|
||||
function setWorkflowTagIds(tags: string[]) {
|
||||
|
|
Loading…
Reference in a new issue