Skip to content
Snippets Groups Projects
Commit d9082565 authored by Loic Huder's avatar Loic Huder
Browse files

Fix Cypress tests

parent c3560256
No related branches found
No related tags found
1 merge request!394Refactor TopAppBarLabel into Breadcrumbs
Pipeline #137318 failed
......@@ -23,7 +23,7 @@ it('should switch to monitor page', () => {
it('should restore an opened workflow when switching pages', () => {
cy.loadGraph('tutorial_Graph');
cy.findByRole('heading', { name: 'tutorial_Graph' }).should('be.visible');
cy.hasBreadcrumbs(['tutorial_Graph']);
cy.get('.react-flow__node').should('have.length', 16);
cy.findByRole('link', { name: 'Monitor' }).click();
......@@ -34,6 +34,7 @@ it('should restore an opened workflow when switching pages', () => {
cy.findByRole('link', { name: 'Edit' }).click()
);
cy.waitForStableDOM();
cy.findByRole('heading', { name: 'tutorial_Graph' }).should('be.visible');
cy.hasBreadcrumbs(['tutorial_Graph']);
cy.get('.react-flow__node').should('have.length', 16);
});
......@@ -19,7 +19,7 @@ it('displays the canvas', () => {
it('opens the tutorial_Graph on the canvas', () => {
cy.loadGraph('tutorial_Graph');
cy.get('h1').should('include.text', 'tutorial_Graph');
cy.hasBreadcrumbs(['tutorial_Graph']);
cy.get('.react-flow__node').should('have.length', 16);
cy.get('.react-flow__edge').should('have.length', 12);
});
......@@ -56,19 +56,22 @@ it('saves an empty workflow on the server and deletes it', () => {
cy.loadGraph(id);
cy.get(`[data-cy="${id}"]`).contains(id);
cy.get(`[data-cy="tutorial_Graph"]`).should('not.exist');
cy.get('[aria-controls="editSidebar-dropdown-menu"]').click();
cy.hasBreadcrumbs([id]);
cy.findByLabelText('breadcrumb').within(() => {
cy.contains('tutorial_Graph').should('not.exist');
});
cy.contains(`Delete Workflow`).click();
cy.findByRole('button', { name: 'Open edit actions menu' }).click();
cy.findByRole('menuitem', { name: 'Delete Workflow' }).click();
cy.contains(`Delete workflow with id: "${id}"?`);
cy.findByRole('dialog').should(
'include.text',
`Delete workflow with id: "${id}"?`
);
cy.findByRole('button', { name: 'Yes' }).click();
cy.get(`[data-cy="${id}"]`).should('not.exist');
cy.contains(id).should('not.exist');
cy.get('p').should(
'include.text',
'Drag and drop tasks here to start building your workflow,or use Quick Open to open an existing workflow.'
......@@ -76,38 +79,25 @@ it('saves an empty workflow on the server and deletes it', () => {
});
it('cannot delete or clone a workflow with an empty canvas', () => {
cy.get('[aria-controls="editSidebar-dropdown-menu"]').click();
cy.get('#editSidebar-dropdown-menu').within(() => {
cy.contains('[role="sidebarMenuItem"]', 'Clone Workflow').should(
'have.class',
'Mui-disabled'
);
});
cy.get('#editSidebar-dropdown-menu').within(() => {
cy.contains('[role="sidebarMenuItem"]', 'Delete Workflow').should(
'have.class',
'Mui-disabled'
);
});
cy.findByRole('button', { name: 'Open edit actions menu' }).click();
cy.findByRole('menuitem', { name: 'Clone Workflow' }).should(
'not.be.enabled'
);
cy.findByRole('menuitem', { name: 'Delete Workflow' }).should(
'not.be.enabled'
);
});
it('opens the clone Graph form with new workflow name', () => {
it('opens a "New workflow" dialog when asking to clone the workflow', () => {
cy.loadGraph('tutorial_Graph');
cy.get('[aria-controls="editSidebar-dropdown-menu"]').click();
cy.get('#editSidebar-dropdown-menu').within(() => {
cy.contains('[role="sidebarMenuItem"]', 'Clone Workflow').click();
});
cy.findByRole('button', { name: 'Open edit actions menu' }).click();
cy.findByRole('menuitem', { name: 'Clone Workflow' }).click();
cy.waitForStableDOM();
cy.contains('Give the new workflow identifier')
.parent()
.should('have.class', 'MuiDialogTitle-root')
.siblings()
.first()
.as('dialogContent')
.should('have.class', 'MuiDialogContent-root');
cy.findByRole('dialog').within(() => {
cy.findAllByRole('heading', {
name: 'Give the new workflow identifier',
}).should('be.visible');
});
});
......@@ -15,7 +15,7 @@ it('loads workflow from disk', () => {
);
cy.waitForStableDOM();
cy.findByRole('heading', { name: 'workflow2' }).should('be.visible');
cy.hasBreadcrumbs(['workflow2']);
cy.get('.react-flow__node').should('have.length', 4);
cy.get('.react-flow__edge').should('have.length', 3);
});
......@@ -33,7 +33,7 @@ it('leaves the original JSON untouched when saving on the server', () => {
);
cy.waitForStableDOM();
cy.findByRole('heading', { name: 'workflow2' }).should('be.visible');
cy.hasBreadcrumbs(['workflow2']);
cy.findByRole('button', { name: 'Save workflow to server' }).click();
cy.findByRole('textbox', {
name: 'Identifier',
......
......@@ -3,7 +3,7 @@ beforeEach(() => {
});
it('navigates to a subgraph, a subsubgraph and back', () => {
cy.findByRole('heading', { name: 'tutorial_Graph' }).should('be.visible');
cy.hasBreadcrumbs(['tutorial_Graph']);
cy.get('.react-flow__node').should('have.length', 16);
cy.get('.react-flow__edge').should('have.length', 12);
......@@ -13,12 +13,7 @@ it('navigates to a subgraph, a subsubgraph and back', () => {
}).dblclick();
cy.waitForStableDOM();
cy.findByRole('heading', { name: 'breadcrumb' }).within(() => {
cy.findByRole('link', { name: 'tutorial_Graph' }).should('be.visible');
cy.findByRole('link', { name: 'Editing-Graph-Node-Link' }).should(
'be.visible'
);
});
cy.hasBreadcrumbs(['tutorial_Graph', 'Editing-Graph-Node-Link']);
cy.get('.react-flow__node').should('have.length', 21);
cy.get('.react-flow__edge').should('have.length', 17);
......@@ -28,13 +23,11 @@ it('navigates to a subgraph, a subsubgraph and back', () => {
}).dblclick();
cy.waitForStableDOM();
cy.findByRole('heading', { name: 'breadcrumb' }).within(() => {
cy.findByRole('link', { name: 'tutorial_Graph' }).should('be.visible');
cy.findByRole('link', { name: 'Editing-Graph-Node-Link' }).should(
'be.visible'
);
cy.findByRole('link', { name: 'Styling-Nodes-Links' }).should('be.visible');
});
cy.hasBreadcrumbs([
'tutorial_Graph',
'Editing-Graph-Node-Link',
'Styling-Nodes-Links',
]);
cy.get('.react-flow__node').should('have.length', 3);
cy.get('.react-flow__edge').should('have.length', 2);
......@@ -42,13 +35,13 @@ it('navigates to a subgraph, a subsubgraph and back', () => {
cy.findByRole('link', { name: 'tutorial_Graph' }).click();
cy.waitForStableDOM();
cy.findByRole('heading', { name: 'tutorial_Graph' }).should('be.visible');
cy.hasBreadcrumbs(['tutorial_Graph']);
cy.get('.react-flow__node').should('have.length', 16);
cy.get('.react-flow__edge').should('have.length', 12);
});
it('loads a different workflow even if inside a subgraph', () => {
cy.findByRole('heading', { name: 'tutorial_Graph' }).should('be.visible');
cy.hasBreadcrumbs(['tutorial_Graph']);
// Navigate to Editing-Graph-Node-Link subgraph
cy.findByRole('button', {
......@@ -56,16 +49,13 @@ it('loads a different workflow even if inside a subgraph', () => {
}).dblclick();
cy.waitForStableDOM();
cy.findByRole('heading', { name: 'breadcrumb' }).within(() => {
cy.findByRole('link', { name: 'tutorial_Graph' }).should('be.visible');
cy.findByRole('link', { name: 'Editing-Graph-Node-Link' }).should(
'be.visible'
);
});
cy.hasBreadcrumbs(['tutorial_Graph', 'Editing-Graph-Node-Link']);
// Load an unrelated workflow
cy.loadGraph('WhatIsEwoks');
cy.findByRole('heading', { name: 'WhatIsEwoks' }).should('be.visible');
cy.findByLabelText('tutorial_Graph').should('not.exist');
cy.hasBreadcrumbs(['WhatIsEwoks']);
cy.findByRole('heading', { name: 'breadcrumb' }).within(() => {
cy.contains('tutorial_Graph').should('not.exist');
});
});
......@@ -45,4 +45,16 @@ Cypress.Commands.add('dragNodeInCanvas', (task_identifier: string) => {
});
});
Cypress.Commands.add('hasBreadcrumbs', (crumbs: string[]) => {
const linkCrumbs = crumbs.slice(0, crumbs.length - 1);
const lastCrumb = crumbs[crumbs.length - 1];
cy.findByLabelText('breadcrumb').within(() => {
linkCrumbs.forEach((name) =>
cy.findByRole('link', { name }).should('be.visible')
);
cy.contains(lastCrumb).should('be.visible');
});
});
addWaitForStableDomCommand({ pollInterval: 300, timeout: 1000 });
......@@ -10,6 +10,7 @@ declare global {
loadGraph(name: string): void;
loadAppWithoutGraph(): void;
dragNodeInCanvas(task_identifier: string): void;
hasBreadcrumbs(crumbs: string[]): void;
}
}
}
......
......@@ -65,7 +65,7 @@ export default function WorkflowSidebarMenu() {
<MenuItem
onClick={() => setOpenSaveDialog(true)}
role="sidebarMenuItem"
role="menuitem"
disabled={
!rootWorkflowId || rootWorkflowId !== displayedWorkflowInfo.id
}
......@@ -78,7 +78,7 @@ export default function WorkflowSidebarMenu() {
</MenuItem>
<MenuItem
onClick={() => setOpenAgreeDialog(true)}
role="sidebarMenuItem"
role="menuitem"
disabled={
!rootWorkflowId || rootWorkflowId !== displayedWorkflowInfo.id
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment