-
Notifications
You must be signed in to change notification settings - Fork 45
/
explorer.cy.js
192 lines (166 loc) · 8.12 KB
/
explorer.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*******************************************************************************
* Copyright (c) 2021, 2023 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
*******************************************************************************/
function createRepresentationFromTreeItem(treeItemLabel, representationDescriptionName, representationName) {
cy.getByTestId(treeItemLabel + '-more').click();
cy.getByTestId('treeitem-contextmenu').findByTestId('new-representation').click();
cy.getByTestId('name').clear();
cy.getByTestId('name').type(representationName);
cy.getByTestId('representationDescription').click();
cy.getByTestId(representationDescriptionName).click();
cy.getByTestId('create-representation').click();
}
describe('/projects/:projectId/edit - Explorer', () => {
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((res) => {
cy.visit(`/projects/${projectId}/edit`);
});
});
});
it('contains the documents', () => {
cy.getByTestId('explorerTree').contains('robot');
});
it('can expand a tree item', () => {
cy.getByTestId('robot').dblclick();
cy.getByTestId('explorerTree').contains('Robot');
cy.getByTestId('Robot').dblclick();
cy.getByTestId('explorerTree').contains('Central_Unit');
cy.getByTestId('explorerTree').contains('CaptureSubSystem');
cy.getByTestId('explorerTree').contains('Wifi');
});
it('can collapse a tree item', () => {
cy.getByTestId('robot').dblclick();
cy.getByTestId('Robot').dblclick();
cy.getByTestId('robot').dblclick();
cy.getByTestId('Robot').should('not.exist');
});
it('can select an object', () => {
cy.getByTestId('robot').dblclick();
cy.getByTestId('Robot').dblclick();
cy.getByTestId('Wifi').click();
cy.getByTestId('selected').contains('Wifi');
});
it('can select a document', () => {
cy.getByTestId('robot').click();
cy.getByTestId('selected').contains('robot');
});
it('can rename a selected document with simple click (direct edit)', () => {
cy.getByTestId('robot').click();
cy.getByTestId('selected').contains('robot');
cy.getByTestId('robot').click();
cy.getByTestId('robot').type('renamed-robot{enter}');
cy.getByTestId('renamed-robot').should('exist');
});
it('can rename a selected document by start typing (direct edit)', () => {
cy.getByTestId('robot').click();
cy.getByTestId('selected').contains('robot');
cy.getByTestId('robot').type('renamed-robot{enter}');
cy.getByTestId('renamed-robot').should('exist');
});
it('can cancel a direct edit with Escape', () => {
cy.getByTestId('robot').click();
cy.getByTestId('selected').contains('robot');
cy.getByTestId('robot').click();
cy.getByTestId('robot').type('renamed-robot{esc}');
cy.getByTestId('name-edit').should('not.exist');
cy.getByTestId('robot').should('exist');
});
it('can apply a direct edit with focus lost', () => {
cy.getByTestId('robot').dblclick();
cy.getByTestId('Robot').should('exist');
cy.getByTestId('robot').click();
cy.getByTestId('robot').type('renamed-robot');
cy.getByTestId('Robot').click();
cy.getByTestId('renamed-robot').should('exist');
});
it('reveals a newly created diagram', () => {
// 1. Expand the root 'Robot' but do not reveal its children (yet)
cy.getByTestId('robot').dblclick();
cy.getByTestId('Robot').should('exist');
cy.getByTestId('Central_Unit').should('not.exist');
cy.getByTestId('CaptureSubSystem').should('not.exist');
cy.getByTestId('Topography').should('not.exist');
// 2. Create 'Topography' diagram on it
createRepresentationFromTreeItem('Robot', 'Topography with auto layout', 'Topography');
// 3. CHECK that the 'Robot' is now expanded, and the 'Topography' diagram inside is visible and selected
cy.getByTestId('Central_Unit').should('exist');
cy.getByTestId('CaptureSubSystem').should('exist');
cy.getByTestId('Topography').should('exist');
cy.getByTestId('selected').findByTestId('Topography').should('exist');
});
it('reveals the semantic element selected on a diagram', () => {
// 1. Expand the root 'Robot' but do not reveal its children (yet)
cy.getByTestId('robot').dblclick();
cy.getByTestId('Robot').should('exist');
cy.getByTestId('Central_Unit').should('not.exist');
cy.getByTestId('CaptureSubSystem').should('not.exist');
cy.getByTestId('Topography').should('not.exist');
// 2. Create 'Topography' diagram on it
createRepresentationFromTreeItem('Robot', 'Topography with auto layout', 'Topography');
// 3. On the diagram, click on the 'DSP' node
cy.getByTestId('DSP').should('not.exist');
cy.getByTestId('Image - DSP').click();
// 4. CHECK that the 'DSP' node is now visible and selected in the explorer
cy.getByTestId('DSP').should('exist');
cy.getByTestId('selected').findByTestId('DSP').should('exist');
});
it('reveals an existing diagram opened using the onboard area', () => {
// 1. Expand and select root 'Robot' but do not reveal its children (yet)
cy.getByTestId('robot').dblclick();
cy.getByTestId('Robot').click();
// 2. Create 'Topography' diagram on it
createRepresentationFromTreeItem('Robot', 'Topography with auto layout', 'Topography');
// 3. Close the new representation and hide it in the explorer
cy.getByTestId('close-representation-tab-Topography').click();
cy.getByTestId('robot').click();
cy.getByTestId('robot').dblclick();
cy.getByTestId('Topography').should('not.exist');
// 4. Re-open the representation from the onboard area
cy.getByTestId('onboard-open-Topography').click();
// 5. CHECK that is is visible and selected again
cy.getByTestId('Topography').should('exist');
cy.getByTestId('selected').findByTestId('Topography').should('exist');
});
it('documents are alphabetically ordered (case insensitive order)', () => {
// Create Flow Model
cy.getByTestId('empty_flow').click();
// Check documents order
cy.getByTestId('tree-root-elements').children().first().contains('Flow').should('exist');
cy.getByTestId('tree-root-elements').children().last().contains('robot').should('exist');
cy.getByTestId('tree-root-elements').children().first().contains('robot').should('not.exist');
cy.getByTestId('tree-root-elements').children().last().contains('Flow').should('not.exist');
// Rename Flow Model to sFlow
cy.getByTestId('Flow').click();
cy.getByTestId('Flow-more').click();
cy.getByTestId('treeitem-contextmenu').findByTestId('rename-tree-item').click();
cy.getByTestId('name-edit').type('sFlow{enter}');
// Check documents order
cy.getByTestId('tree-root-elements').children().first().contains('robot').should('exist');
cy.getByTestId('tree-root-elements').children().last().contains('sFlow').should('exist');
cy.getByTestId('tree-root-elements').children().first().contains('sFlow').should('not.exist');
cy.getByTestId('tree-root-elements').children().last().contains('robot').should('not.exist');
// Rename sFlow Model to ROBOT
cy.getByTestId('sFlow').click();
cy.getByTestId('sFlow-more').click();
cy.getByTestId('treeitem-contextmenu').findByTestId('rename-tree-item').click();
cy.getByTestId('name-edit').type('ROBOT{enter}');
// Check documents order
cy.getByTestId('tree-root-elements').children().first().contains('robot').should('exist');
cy.getByTestId('tree-root-elements').children().last().contains('ROBOT').should('exist');
cy.getByTestId('tree-root-elements').children().first().contains('ROBOT').should('not.exist');
cy.getByTestId('tree-root-elements').children().last().contains('robot').should('not.exist');
});
});