test: Migrate cypress tests batch 2 to playwright (#19589)

This commit is contained in:
Artem Sorokin
2025-09-16 16:25:22 +02:00
committed by GitHub
parent a4fc24371d
commit a7f4e3e323
9 changed files with 1300 additions and 326 deletions

View File

@@ -1,115 +0,0 @@
import { WorkflowPage, NDV } from '../pages';
const wf = new WorkflowPage();
const ndv = new NDV();
describe('Data transformation expressions', () => {
beforeEach(() => {
wf.actions.visit();
});
it('$json + native string methods', () => {
wf.actions.addInitialNodeToCanvas('Schedule Trigger', { keepNdvOpen: true });
ndv.actions.setPinnedData([{ myStr: 'Monday' }]);
ndv.actions.close();
addEditFields();
const input = '{{$json.myStr.toLowerCase() + " is " + "today".toUpperCase()';
const output = 'monday is TODAY';
ndv.getters.inlineExpressionEditorInput().clear().type(input);
ndv.getters.inlineExpressionEditorOutput().should('have.text', output);
ndv.actions.execute();
ndv.getters.outputDataContainer().should('be.visible');
ndv.getters.outputDataContainer().contains(output);
});
it('$json + n8n string methods', () => {
wf.actions.addInitialNodeToCanvas('Schedule Trigger', { keepNdvOpen: true });
ndv.actions.setPinnedData([{ myStr: 'hello@n8n.io is an email' }]);
ndv.actions.close();
addEditFields();
const input = '{{$json.myStr.extractEmail() + " " + $json.myStr.isEmpty()';
const output = 'hello@n8n.io false';
ndv.getters.inlineExpressionEditorInput().clear().type(input);
ndv.getters.inlineExpressionEditorOutput().should('have.text', output);
ndv.actions.execute();
ndv.getters.outputDataContainer().should('be.visible');
ndv.getters.outputDataContainer().contains(output);
});
it('$json + native numeric methods', () => {
wf.actions.addInitialNodeToCanvas('Schedule Trigger', { keepNdvOpen: true });
ndv.actions.setPinnedData([{ myNum: 9.123 }]);
ndv.actions.close();
addEditFields();
const input = '{{$json.myNum.toPrecision(3)';
const output = '9.12';
ndv.getters.inlineExpressionEditorInput().clear().type(input);
ndv.getters.inlineExpressionEditorOutput().should('have.text', output);
ndv.actions.execute();
ndv.getters.outputDataContainer().should('be.visible');
ndv.getters.outputDataContainer().contains(output);
});
it('$json + n8n numeric methods', () => {
wf.actions.addInitialNodeToCanvas('Schedule Trigger', { keepNdvOpen: true });
ndv.actions.setPinnedData([{ myStr: 'hello@n8n.io is an email' }]);
ndv.actions.close();
addEditFields();
const input = '{{$json.myStr.extractEmail() + " " + $json.myStr.isEmpty()';
const output = 'hello@n8n.io false';
ndv.getters.inlineExpressionEditorInput().clear().type(input);
ndv.getters.inlineExpressionEditorOutput().should('have.text', output);
ndv.actions.execute();
ndv.getters.outputDataContainer().should('be.visible');
ndv.getters.outputDataContainer().contains(output);
});
it('$json + native array access', () => {
wf.actions.addInitialNodeToCanvas('Schedule Trigger', { keepNdvOpen: true });
ndv.actions.setPinnedData([{ myArr: [1, 2, 3] }]);
ndv.actions.close();
addEditFields();
const input = '{{$json.myArr.includes(1) + " " + $json.myArr[2]';
const output = 'true 3';
ndv.getters.inlineExpressionEditorInput().clear().type(input);
ndv.getters.inlineExpressionEditorOutput().should('have.text', output);
ndv.actions.execute();
ndv.getters.outputDataContainer().find('[class*=value_]').should('exist');
ndv.getters.outputDataContainer().find('[class*=value_]').should('contain', output);
});
it('$json + n8n array methods', () => {
wf.actions.addInitialNodeToCanvas('Schedule Trigger', { keepNdvOpen: true });
ndv.actions.setPinnedData([{ myArr: [1, 2, 3] }]);
ndv.actions.close();
addEditFields();
const input = '{{$json.myArr.first() + " " + $json.myArr.last()';
const output = '1 3';
ndv.getters.inlineExpressionEditorInput().clear().type(input);
ndv.getters.inlineExpressionEditorOutput().should('have.text', output);
ndv.actions.execute();
ndv.getters.outputDataContainer().find('[class*=value_]').should('exist');
ndv.getters.outputDataContainer().find('[class*=value_]').should('contain', output);
});
});
// ----------------------------------
// utils
// ----------------------------------
const addEditFields = () => {
wf.actions.addNodeToCanvas('Edit Fields', true, true);
ndv.getters.assignmentCollectionAdd('assignments').click();
ndv.getters.assignmentValue('assignments').contains('Expression').invoke('show').click();
};

View File

@@ -1,111 +0,0 @@
import { WorkflowPage as WorkflowPageClass, NDV } from '../pages';
const workflowPage = new WorkflowPageClass();
const ndv = new NDV();
describe('Node IO Filter', () => {
beforeEach(() => {
workflowPage.actions.visit();
cy.createFixtureWorkflow('Node_IO_filter.json');
workflowPage.actions.saveWorkflowOnButtonClick();
workflowPage.actions.executeWorkflow();
});
it('should filter pinned data', () => {
workflowPage.getters.canvasNodes().first().dblclick();
ndv.actions.close();
workflowPage.getters.canvasNodes().first().dblclick();
ndv.getters.outputDataContainer().should('be.visible');
ndv.getters.outputPanel().findChildByTestId('ndv-search').should('exist');
cy.document().trigger('keyup', { key: '/' });
const searchInput = ndv.getters.searchInput();
searchInput.should('have.focus');
ndv.getters.pagination().find('li').should('have.length', 3);
ndv.getters.outputDataContainer().find('mark').should('not.exist');
searchInput.type('ar');
ndv.getters.pagination().find('li').should('have.length', 2);
ndv.getters.outputDataContainer().find('mark').its('length').should('be.gt', 0);
searchInput.type('i');
ndv.getters.pagination().should('not.exist');
ndv.getters.outputDataContainer().find('mark').its('length').should('be.gt', 0);
});
it('should filter input/output data separately', () => {
workflowPage.getters.canvasNodes().eq(1).dblclick();
ndv.getters.outputDataContainer().should('be.visible');
ndv.getters.inputDataContainer().should('be.visible');
ndv.actions.switchInputMode('Table');
ndv.getters.outputPanel().findChildByTestId('ndv-search').should('exist');
cy.document().trigger('keyup', { key: '/' });
ndv.getters.outputPanel().findChildByTestId('ndv-search').should('not.have.focus');
let focusedInput = ndv.getters
.inputPanel()
.findChildByTestId('ndv-search')
.should('have.focus');
const getInputPagination = () =>
ndv.getters.inputPanel().findChildByTestId('ndv-data-pagination');
const getInputCounter = () => ndv.getters.inputPanel().findChildByTestId('ndv-items-count');
const getOuputPagination = () =>
ndv.getters.outputPanel().findChildByTestId('ndv-data-pagination');
const getOutputCounter = () => ndv.getters.outputPanel().findChildByTestId('ndv-items-count');
getInputPagination().find('li').should('have.length', 3);
getInputCounter().contains('21 items').should('exist');
getOuputPagination().find('li').should('have.length', 3);
getOutputCounter().contains('21 items').should('exist');
focusedInput.type('ar');
getInputPagination().find('li').should('have.length', 2);
getInputCounter().should('contain', '14 of 21 items');
getOuputPagination().find('li').should('have.length', 3);
getOutputCounter().should('contain', '21 items');
focusedInput.type('i');
getInputPagination().should('not.exist');
getInputCounter().should('contain', '8 of 21 items');
getOuputPagination().find('li').should('have.length', 3);
getOutputCounter().should('contain', '21 items');
focusedInput.clear();
getInputPagination().find('li').should('have.length', 3);
getInputCounter().contains('21 items').should('exist');
getOuputPagination().find('li').should('have.length', 3);
getOutputCounter().contains('21 items').should('exist');
ndv.getters.outputDataContainer().trigger('mouseover');
cy.document().trigger('keyup', { key: '/' });
ndv.getters.inputPanel().findChildByTestId('ndv-search').should('not.have.focus');
focusedInput = ndv.getters.outputPanel().findChildByTestId('ndv-search').should('have.focus');
getInputPagination().find('li').should('have.length', 3);
getInputCounter().contains('21 items').should('exist');
getOuputPagination().find('li').should('have.length', 3);
getOutputCounter().contains('21 items').should('exist');
focusedInput.type('ar');
getInputPagination().find('li').should('have.length', 3);
getInputCounter().contains('21 items').should('exist');
getOuputPagination().find('li').should('have.length', 2);
getOutputCounter().should('contain', '14 of 21 items');
focusedInput.type('i');
getInputPagination().find('li').should('have.length', 3);
getInputCounter().contains('21 items').should('exist');
getOuputPagination().should('not.exist');
getOutputCounter().should('contain', '8 of 21 items');
focusedInput.clear();
getInputPagination().find('li').should('have.length', 3);
getInputCounter().contains('21 items').should('exist');
getOuputPagination().find('li').should('have.length', 3);
getOutputCounter().contains('21 items').should('exist');
});
});

View File

@@ -1,100 +0,0 @@
import {
changeOutputRunSelector,
getOutputPanelItemsCount,
getOutputPanelRelatedExecutionLink,
getOutputRunSelectorInput,
getOutputTableHeaders,
getOutputTableRows,
getOutputTbodyCell,
} from '../composables/ndv';
import {
clickExecuteWorkflowButton,
clickZoomToFit,
getCanvasNodes,
navigateToNewWorkflowPage,
openNode,
pasteWorkflow,
saveWorkflowOnButtonClick,
} from '../composables/workflow';
import SUBWORKFLOW_DEBUGGING_EXAMPLE from '../fixtures/Subworkflow-debugging-execute-workflow.json';
describe('Subworkflow debugging', () => {
beforeEach(() => {
navigateToNewWorkflowPage();
pasteWorkflow(SUBWORKFLOW_DEBUGGING_EXAMPLE);
saveWorkflowOnButtonClick();
getCanvasNodes().should('have.length', 11);
clickZoomToFit();
clickExecuteWorkflowButton();
});
describe('can inspect sub executed workflow', () => {
it('(Run once with all items/ Wait for Sub-workflow completion) (default behavior)', () => {
openNode('Execute Workflow with param');
getOutputPanelItemsCount().should('contain.text', '2 items, 1 sub-execution');
getOutputPanelRelatedExecutionLink().should('contain.text', 'View sub-execution');
getOutputPanelRelatedExecutionLink().should('have.attr', 'href');
// ensure workflow executed and waited on output
getOutputTableHeaders().should('have.length', 2);
getOutputTbodyCell(1, 0).should('have.text', 'world Natalie Moore');
});
it('(Run once for each item/ Wait for Sub-workflow completion)', () => {
openNode('Execute Workflow with param1');
getOutputPanelItemsCount().should('contain.text', '2 items, 2 sub-execution');
getOutputPanelRelatedExecutionLink().should('not.exist');
// ensure workflow executed and waited on output
getOutputTableHeaders().should('have.length', 3);
getOutputTbodyCell(1, 0).find('a').should('have.attr', 'href');
getOutputTbodyCell(1, 1).should('have.text', 'world Natalie Moore');
});
it('(Run once with all items/ Wait for Sub-workflow completion)', () => {
openNode('Execute Workflow with param2');
getOutputPanelItemsCount().should('not.exist');
getOutputPanelRelatedExecutionLink().should('contain.text', 'View sub-execution');
getOutputPanelRelatedExecutionLink().should('have.attr', 'href');
// ensure workflow executed but returned same data as input
getOutputRunSelectorInput().should('have.value', '2 of 2 (3 items, 1 sub-execution)');
getOutputTableHeaders().should('have.length', 6);
getOutputTableHeaders().eq(0).should('have.text', 'uid');
getOutputTableRows().should('have.length', 4);
getOutputTbodyCell(1, 1).should('include.text', 'Jon_Ebert@yahoo.com');
changeOutputRunSelector('1 of 2 (2 items, 1 sub-execution)');
getOutputRunSelectorInput().should('have.value', '1 of 2 (2 items, 1 sub-execution)');
getOutputTableHeaders().should('have.length', 6);
getOutputTableHeaders().eq(0).should('have.text', 'uid');
getOutputTableRows().should('have.length', 3);
getOutputTbodyCell(1, 1).should('include.text', 'Terry.Dach@hotmail.com');
});
it('(Run once for each item/ Wait for Sub-workflow completion)', () => {
openNode('Execute Workflow with param3');
// ensure workflow executed but returned same data as input
getOutputRunSelectorInput().should('have.value', '2 of 2 (3 items, 3 sub-executions)');
getOutputTableHeaders().should('have.length', 7);
getOutputTableHeaders().eq(1).should('have.text', 'uid');
getOutputTableRows().should('have.length', 4);
getOutputTbodyCell(1, 0).find('a').should('have.attr', 'href');
getOutputTbodyCell(1, 2).should('include.text', 'Jon_Ebert@yahoo.com');
changeOutputRunSelector('1 of 2 (2 items, 2 sub-executions)');
getOutputRunSelectorInput().should('have.value', '1 of 2 (2 items, 2 sub-executions)');
getOutputTableHeaders().should('have.length', 7);
getOutputTableHeaders().eq(1).should('have.text', 'uid');
getOutputTableRows().should('have.length', 3);
getOutputTbodyCell(1, 0).find('a').should('have.attr', 'href');
getOutputTbodyCell(1, 2).should('include.text', 'Terry.Dach@hotmail.com');
});
});
});