-
Notifications
You must be signed in to change notification settings - Fork 45
/
diagram-contextual-palette.cy.js
82 lines (75 loc) · 3.4 KB
/
diagram-contextual-palette.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
/*******************************************************************************
* Copyright (c) 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
*******************************************************************************/
describe('/projects/:projectId/edit - Robot Diagram', () => {
const fadeByElementTestId = (elementTestId) => {
cy.getByTestId(elementTestId).should('have.css', 'opacity', '1');
cy.getByTestId(elementTestId).first().click({ force: true });
cy.wait(200); // wait for the palette to be loaded completely
cy.getByTestId('Fade-elements').should('exist').click({ force: true });
cy.getByTestId(elementTestId).should('have.css', 'opacity', '0.4');
};
const hideByElementTestId = (elementTestId) => {
cy.getByTestId(elementTestId).then((elementBefore) => {
console.log(elementTestId);
const countBefore = elementBefore.length ?? 0;
console.log(countBefore);
cy.getByTestId(elementTestId).first().click({ force: true });
cy.wait(200); // wait for the palette to be loaded completely
cy.getByTestId('Hide-elements').should('exist').click({ force: true });
cy.getByTestId(elementTestId).then((elementAfter) => {
console.log(elementAfter.length ?? 0);
cy.expect((elementAfter.length ?? 0) + 1).to.equal(countBefore);
});
});
};
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, 'flow').then(() => {
cy.visit(`/projects/${projectId}/edit`);
});
});
cy.getByTestId('flow').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('Topography__REACT_FLOW');
cy.getByTestId('representationDescription').click();
cy.getByTestId('Topography with auto layout').click();
cy.getByTestId('create-representation').click();
cy.getByTestId('Topography__REACT_FLOW').click();
});
it('test Hide/Fade action is not available on diagram background', () => {
cy.getByTestId('Label - CaptureSubSystem').click('topLeft');
cy.getByTestId('Hide-elements').should('exist');
cy.getByTestId('Fade-elements').should('exist');
cy.getByTestId('rf__wrapper').click();
cy.getByTestId('Hide-elements').should('not.exist');
cy.getByTestId('Fade-elements').should('not.exist');
});
it('can fade any type of nodes', () => {
fadeByElementTestId('IconLabel - Temperature: 25');
fadeByElementTestId('Image - Motion_Engine');
fadeByElementTestId('Rectangle - Central_Unit');
fadeByElementTestId('List - Description');
});
it.only('can hide any type of nodes', () => {
hideByElementTestId('IconLabel - Temperature: 25');
hideByElementTestId('Image - Motion_Engine');
hideByElementTestId('List - Description');
hideByElementTestId('Rectangle - Central_Unit');
});
});