test: Migrate Cypress test for the log view (#19108)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Suguru Inoue
2025-09-03 14:21:28 +02:00
committed by GitHub
parent 6bd4edf1ec
commit f7479bb2e5
17 changed files with 428 additions and 247 deletions

View File

@@ -1,232 +0,0 @@
import * as executions from '../composables/executions';
import * as logs from '../composables/logs';
import * as chat from '../composables/modals/chat-modal';
import * as ndv from '../composables/ndv';
import * as workflow from '../composables/workflow';
import Workflow_chat from '../fixtures/Workflow_ai_agent.json';
import Workflow_if from '../fixtures/Workflow_if.json';
import Workflow_loop from '../fixtures/Workflow_loop.json';
import Workflow_wait_for_webhook from '../fixtures/Workflow_wait_for_webhook.json';
describe('Logs', () => {
it('should populate logs as manual execution progresses', () => {
workflow.navigateToNewWorkflowPage();
workflow.pasteWorkflow(Workflow_loop);
workflow.clickZoomToFit();
logs.openLogsPanel();
logs.getLogEntries().should('have.length', 0);
workflow.executeWorkflow();
logs.getOverviewStatus().contains('Running').should('exist');
logs.getLogEntries().should('have.length', 4);
logs.getLogEntries().eq(0).should('contain.text', 'When clicking Execute workflow');
logs.getLogEntries().eq(1).should('contain.text', 'Code');
logs.getLogEntries().eq(2).should('contain.text', 'Loop Over Items');
logs.getLogEntries().eq(3).should('contain.text', 'Wait');
logs.getLogEntries().should('have.length', 6);
logs.getLogEntries().eq(4).should('contain.text', 'Loop Over Items');
logs.getLogEntries().eq(5).should('contain.text', 'Wait');
logs.getLogEntries().should('have.length', 8);
logs.getLogEntries().eq(6).should('contain.text', 'Loop Over Items');
logs.getLogEntries().eq(7).should('contain.text', 'Wait');
logs.getLogEntries().should('have.length', 10);
logs.getLogEntries().eq(8).should('contain.text', 'Loop Over Items');
logs.getLogEntries().eq(9).should('contain.text', 'Code1');
logs
.getOverviewStatus()
.contains(/Error in [\d\.]+s/)
.should('exist');
logs.getSelectedLogEntry().should('contain.text', 'Code1'); // Errored node is automatically selected
logs.getNodeErrorMessageHeader().should('contain.text', 'test!!! [line 1]');
workflow.getNodeIssuesByName('Code1').should('exist');
logs.pressClearExecutionButton();
logs.getLogEntries().should('have.length', 0);
workflow.getNodeIssuesByName('Code1').should('not.exist');
});
it('should allow to trigger partial execution', () => {
workflow.navigateToNewWorkflowPage();
workflow.pasteWorkflow(Workflow_if);
workflow.clickZoomToFit();
logs.openLogsPanel();
workflow.executeWorkflowAndWait(false);
logs.getLogEntries().should('have.length', 6);
logs.getLogEntries().eq(0).should('contain.text', 'Schedule Trigger');
logs.getLogEntries().eq(1).should('contain.text', 'Code');
logs.getLogEntries().eq(2).should('contain.text', 'Edit Fields');
logs.getLogEntries().eq(3).should('contain.text', 'If');
logs.getLogEntries().eq(4).should('contain.text', 'Edit Fields');
logs.getLogEntries().eq(5).should('contain.text', 'Edit Fields');
logs.clickTriggerPartialExecutionAtRow(3);
logs.getLogEntries().should('have.length', 3);
logs.getLogEntries().eq(0).should('contain.text', 'Schedule Trigger');
logs.getLogEntries().eq(1).should('contain.text', 'Code');
logs.getLogEntries().eq(2).should('contain.text', 'If');
});
// TODO: make it possible to test workflows with AI model end-to-end
// eslint-disable-next-line n8n-local-rules/no-skipped-tests
it.skip('should show input and output data in the selected display mode', () => {
workflow.navigateToNewWorkflowPage();
workflow.pasteWorkflow(Workflow_chat);
workflow.clickZoomToFit();
logs.openLogsPanel();
chat.sendManualChatMessage('Hi!');
workflow.waitForSuccessBannerToAppear();
chat.getManualChatMessages().eq(0).should('contain.text', 'Hi!');
chat.getManualChatMessages().eq(1).should('contain.text', 'Hello from e2e model!!!');
logs.getLogEntries().eq(2).should('have.text', 'E2E Chat Model');
logs.getLogEntries().eq(2).click();
logs.getOutputPanel().should('contain.text', 'Hello from e2e model!!!');
logs.setOutputDisplayMode('table');
logs.getOutputTbodyCell(1, 0).should('contain.text', 'text:Hello from **e2e** model!!!');
logs.getOutputTbodyCell(1, 1).should('contain.text', 'completionTokens:20');
logs.setOutputDisplayMode('schema');
logs.getOutputPanel().should('contain.text', 'generations[0]');
logs.getOutputPanel().should('contain.text', 'Hello from **e2e** model!!!');
logs.setOutputDisplayMode('json');
logs.getOutputPanel().should('contain.text', '[{"response": {"generations": [');
logs.toggleInputPanel();
logs.getInputPanel().should('contain.text', 'Human: Hi!');
logs.setInputDisplayMode('table');
logs.getInputTbodyCell(1, 0).should('contain.text', '0:Human: Hi!');
logs.setInputDisplayMode('schema');
logs.getInputPanel().should('contain.text', 'messages[0]');
logs.getInputPanel().should('contain.text', 'Human: Hi!');
logs.setInputDisplayMode('json');
logs.getInputPanel().should('contain.text', '[{"messages": ["Human: Hi!"],');
});
it('should show input and output data of correct run index and branch', () => {
workflow.navigateToNewWorkflowPage();
workflow.pasteWorkflow(Workflow_if);
workflow.clickZoomToFit();
logs.openLogsPanel();
workflow.executeWorkflow();
logs.clickLogEntryAtRow(2); // Run #1 of 'Edit Fields' node; input is 'Code' node
logs.toggleInputPanel();
logs.setInputDisplayMode('table');
logs.getInputTableRows().should('have.length', 11);
logs.getInputTbodyCell(1, 0).should('contain.text', '0');
logs.getInputTbodyCell(10, 0).should('contain.text', '9');
logs.clickOpenNdvAtRow(2);
ndv.setInputDisplayMode('Table');
ndv.getInputSelect().should('have.value', 'Code ');
ndv.getInputTableRows().should('have.length', 11);
ndv.getInputTbodyCell(1, 0).should('contain.text', '0');
ndv.getInputTbodyCell(10, 0).should('contain.text', '9');
ndv.getOutputRunSelectorInput().should('have.value', '1 of 3 (10 items)');
ndv.clickGetBackToCanvas();
logs.clickLogEntryAtRow(4); // Run #2 of 'Edit Fields' node; input is false branch of 'If' node
logs.getInputTableRows().should('have.length', 6);
logs.getInputTbodyCell(1, 0).should('contain.text', '5');
logs.getInputTbodyCell(5, 0).should('contain.text', '9');
logs.clickOpenNdvAtRow(4);
ndv.getInputSelect().should('have.value', 'If ');
ndv.getInputTableRows().should('have.length', 6);
ndv.getInputTbodyCell(1, 0).should('contain.text', '5');
ndv.getInputTbodyCell(5, 0).should('contain.text', '9');
ndv.getOutputRunSelectorInput().should('have.value', '2 of 3 (5 items)');
ndv.clickGetBackToCanvas();
logs.clickLogEntryAtRow(5); // Run #3 of 'Edit Fields' node; input is true branch of 'If' node
logs.getInputTableRows().should('have.length', 6);
logs.getInputTbodyCell(1, 0).should('contain.text', '0');
logs.getInputTbodyCell(5, 0).should('contain.text', '4');
logs.clickOpenNdvAtRow(5);
ndv.getInputSelect().should('have.value', 'If ');
ndv.getInputTableRows().should('have.length', 6);
ndv.getInputTbodyCell(1, 0).should('contain.text', '0');
ndv.getInputTbodyCell(5, 0).should('contain.text', '4');
ndv.getOutputRunSelectorInput().should('have.value', '3 of 3 (5 items)');
});
it('should keep populated logs unchanged when workflow get edits after the execution', () => {
workflow.navigateToNewWorkflowPage();
workflow.pasteWorkflow(Workflow_if);
workflow.clickZoomToFit();
logs.openLogsPanel();
workflow.executeWorkflowAndWait(false);
logs.getLogEntries().should('have.length', 6);
workflow.disableNode('Edit Fields');
logs.getLogEntries().should('have.length', 6);
workflow.deleteNode('If');
logs.getLogEntries().should('have.length', 6);
});
// TODO: make it possible to test workflows with AI model end-to-end
// eslint-disable-next-line n8n-local-rules/no-skipped-tests
it.skip('should show logs for a past execution', () => {
workflow.navigateToNewWorkflowPage();
workflow.pasteWorkflow(Workflow_chat);
workflow.clickZoomToFit();
logs.openLogsPanel();
chat.sendManualChatMessage('Hi!');
workflow.waitForSuccessBannerToAppear();
workflow.openExecutions();
executions.toggleAutoRefresh(); // Stop unnecessary background requests
executions.getManualChatMessages().eq(0).should('contain.text', 'Hi!');
executions.getManualChatMessages().eq(1).should('contain.text', 'Hello from e2e model!!!');
executions
.getLogsOverviewStatus()
.contains(/Success in [\d\.]+m?s/)
.should('exist');
executions.getLogEntries().should('have.length', 3);
executions.getLogEntries().eq(0).should('contain.text', 'When chat message received');
executions.getLogEntries().eq(1).should('contain.text', 'AI Agent');
executions.getLogEntries().eq(2).should('contain.text', 'E2E Chat Model');
});
it('should show logs for a workflow with a node that waits for webhook', () => {
workflow.navigateToNewWorkflowPage();
workflow.pasteWorkflow(Workflow_wait_for_webhook);
workflow.getCanvas().click('topLeft'); // click canvas to deselect nodes
workflow.clickZoomToFit();
logs.openLogsPanel();
workflow.executeWorkflow();
workflow.getNodesWithSpinner().should('contain.text', 'Wait');
workflow.getWaitingNodes().should('contain.text', 'Wait');
logs.getLogEntries().should('have.length', 2);
logs.getLogEntries().eq(1).should('contain.text', 'Wait node');
logs.getLogEntries().eq(1).should('contain.text', 'Waiting');
workflow.openNode('Wait node');
ndv
.getOutputPanelDataContainer()
.find('a')
.should('have.attr', 'href')
.then((url) => {
cy.request(url as unknown as string).then((response) => {
expect(response.status).to.eq(200);
});
});
ndv.getBackToCanvasButton().click();
workflow.getNodesWithSpinner().should('not.exist');
workflow.getWaitingNodes().should('not.exist');
logs
.getOverviewStatus()
.contains(/Success in [\d\.]+m?s/)
.should('exist');
logs.getLogEntries().eq(1).click(); // click selected row to deselect
logs.getLogEntries().should('have.length', 2);
logs.getLogEntries().eq(1).should('contain.text', 'Wait node');
logs.getLogEntries().eq(1).should('contain.text', 'Success');
});
});

View File

@@ -1,66 +0,0 @@
{
"nodes": [
{
"parameters": {
"options": {}
},
"id": "5eb6b347-b34e-4112-9601-f7aa94f26575",
"name": "When chat message received",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.1,
"position": [0, 0],
"webhookId": "4fb58136-3481-494a-a30f-d9e064dac186"
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.9,
"position": [220, 0],
"id": "32534841-9474-4890-9998-65d6a56bdf0c",
"name": "AI Agent"
},
{
"parameters": {
"response": "Hello from **e2e** model!!!"
},
"type": "@n8n/n8n-nodes-langchain.lmChatE2eTest",
"typeVersion": 1,
"position": [308, 220],
"id": "2f239d5b-95ef-4949-92b6-5a7541e1029f",
"name": "E2E Chat Model"
}
],
"connections": {
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [[]]
},
"E2E Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"instanceId": "14f5bd03485879885c6d92999d35d4d24556536fa2b675f932eb27193691e2b2"
}
}

View File

@@ -1,149 +0,0 @@
{
"nodes": [
{
"parameters": {
"rule": {
"interval": [{}]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [0, 0],
"id": "4c4f02e3-f0cc-4e1a-b084-9888dd75ccaf",
"name": "Schedule Trigger"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "553f50d9-5023-433f-8f62-eebc9c9e2269",
"leftValue": "={{ $json.data }}",
"rightValue": 5,
"operator": {
"type": "number",
"operation": "lt"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [660, 80],
"id": "3273dcdb-845c-43cc-8ed0-ffaef7b68b1c",
"name": "If"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "71475f04-571e-4e99-bdf8-adff367533fb",
"name": "data",
"value": "={{ $json.data }}",
"type": "number"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [880, 0],
"id": "0522012f-fe99-41e0-ba19-7e18f22758d9",
"name": "Edit Fields"
},
{
"parameters": {
"jsCode": "return Array.from({length:10}).map((_,i)=>({data:i}))"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [440, 0],
"id": "268c2da4-23c8-46c5-8992-37a92b8e4aad",
"name": "Code"
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [220, 0],
"id": "0e2d1621-607d-4d53-98a3-07afc0d6230d",
"name": "Edit Fields1",
"disabled": true
}
],
"connections": {
"Schedule Trigger": {
"main": [
[
{
"node": "Edit Fields1",
"type": "main",
"index": 0
}
]
]
},
"If": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
],
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
},
{
"node": "Edit Fields",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields1": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"instanceId": "ddb4b2493e5f30d4af3bb43dd3c9acf1f60cbaa91c89e84d2967725474533c77"
}
}

View File

@@ -1,110 +0,0 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, -10],
"id": "cc68bd44-e150-403c-afaf-bd0bac0459dd",
"name": "When clicking Execute workflow"
},
{
"parameters": {
"jsCode": "return [{data:1},{data:2},{data:3}]"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [220, -10],
"id": "461b130c-0efb-4201-8210-d5e794e88ed8",
"name": "Code"
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [440, -10],
"id": "16860d82-1b2c-4882-ad76-43cc2042d695",
"name": "Loop Over Items"
},
{
"parameters": {
"amount": 2
},
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [660, 40],
"id": "9ede6c97-a3c5-4f42-adcc-dfe66fc7a2a8",
"name": "Wait",
"webhookId": "36d32e2d-a9cf-4dc7-b138-70d7966c96d7"
},
{
"parameters": {
"jsCode": "throw Error('test!!!')"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [660, -160],
"id": "05ad4f4d-10fc-4bec-9145-0e5c20f455c4",
"name": "Code1"
}
],
"connections": {
"When clicking Execute workflow": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
],
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Wait": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"instanceId": "74f18f142a6ddf6880a6f8c5b30685f621743a7a66d8d94c8f164937f4dd5515"
}
}

View File

@@ -1,41 +0,0 @@
{
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "42c6e003-10e7-4100-aff8-8865c49f384c",
"name": "When clicking Test workflow"
},
{
"parameters": {
"resume": "webhook",
"options": {}
},
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [220, 0],
"id": "77614c15-c41e-4b8c-95d6-084d48fed328",
"name": "Wait node",
"webhookId": "62aad98c-81b3-4c44-9adb-b33a23d1271d"
}
],
"connections": {
"When clicking Test workflow": {
"main": [
[
{
"node": "Wait node",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"instanceId": "eea4a7b09aa7ee308bc067003a65466862f88be8d9309a2bb16297f6bb2616ec"
}
}