-
Notifications
You must be signed in to change notification settings - Fork 45
/
diagram.reactflow.cy.js
105 lines (86 loc) · 4.32 KB
/
diagram.reactflow.cy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*******************************************************************************
* Copyright (c) 2023, 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
describe('/projects/:projectId/edit - Diagram', () => {
beforeEach(() => {
cy.deleteAllProjects();
cy.createProject('Cypress Project').then((res) => {
const projectId = res.body.data.createProject.project.id;
const robot_flow_id = 'c26b6086-b444-3ee6-b8cd-9a4fde5956a7';
cy.createDocument(projectId, robot_flow_id, 'robot').then(() => {
cy.visit(`/projects/${projectId}/edit`);
});
});
});
it('shows a Topography diagram when clicked in the explorer', () => {
cy.getByTestId('robot').dblclick();
cy.getByTestId('Robot').dblclick();
cy.getByTestId('Robot-more').click();
cy.getByTestId('treeitem-contextmenu').findByTestId('new-representation').click();
cy.getByTestId('name').clear();
cy.getByTestId('name').type('Topography1__REACT_FLOW');
cy.getByTestId('representationDescription').click();
cy.getByTestId('Topography with auto layout').click();
cy.getByTestId('create-representation').click();
cy.getByTestId('rf__wrapper').should('exist');
cy.get('.react-flow__edgelabel-renderer').children().should('have.length', 7);
cy.get('.react-flow__nodes').children().should('have.length', 18);
cy.get('.react-flow__node-freeFormNode').should('have.length', 12);
cy.get('.react-flow__node-listNode').should('have.length', 2);
cy.get('.react-flow__node-iconLabelNode').should('have.length', 4);
});
it('can share the representation', () => {
cy.getByTestId('share').should('not.exist');
cy.getByTestId('robot').dblclick();
cy.getByTestId('Robot').dblclick();
cy.getByTestId('Robot-more').click();
cy.getByTestId('treeitem-contextmenu').findByTestId('new-representation').click();
cy.getByTestId('name').clear();
cy.getByTestId('name').type('Topography1__REACT_FLOW');
cy.getByTestId('representationDescription').click();
cy.getByTestId('Topography with auto layout').click();
cy.getByTestId('create-representation').click();
cy.getByTestId('share').should('be.enabled');
cy.getByTestId('rf__wrapper').should('exist');
cy.getByTestId('share').click();
cy.url().then(($url) => {
cy.window().then((win) => {
win.navigator.clipboard.readText().then((text) => {
expect(text).to.eq($url);
});
});
});
});
it('can switch between representations', () => {
cy.getByTestId('robot').dblclick();
cy.getByTestId('Robot').dblclick();
cy.getByTestId('Robot-more').click();
cy.getByTestId('treeitem-contextmenu').findByTestId('new-representation').click();
cy.getByTestId('name').clear();
cy.getByTestId('name').type('Topography1__REACT_FLOW');
cy.getByTestId('create-representation').click();
cy.getByTestId('Robot-more').click();
cy.getByTestId('treeitem-contextmenu').findByTestId('new-representation').click();
cy.getByTestId('name').clear();
cy.getByTestId('name').type('Topography2__REACT_FLOW');
cy.getByTestId('create-representation').click();
cy.getByTestId('Topography1__REACT_FLOW').click();
cy.getByTestId('representation-tab-Topography1__REACT_FLOW').should('have.attr', 'data-testselected', 'true');
cy.getByTestId('representation-tab-Topography2__REACT_FLOW').should('have.attr', 'data-testselected', 'false');
cy.getByTestId('Topography2__REACT_FLOW').click();
cy.getByTestId('representation-tab-Topography1__REACT_FLOW').should('have.attr', 'data-testselected', 'false');
cy.getByTestId('representation-tab-Topography2__REACT_FLOW').should('have.attr', 'data-testselected', 'true');
cy.getByTestId('representation-tab-Topography1__REACT_FLOW').click();
cy.getByTestId('representation-tab-Topography1__REACT_FLOW').should('have.attr', 'data-testselected', 'true');
cy.getByTestId('representation-tab-Topography2__REACT_FLOW').should('have.attr', 'data-testselected', 'false');
});
});