-
Notifications
You must be signed in to change notification settings - Fork 605
/
chart-view.ts
460 lines (392 loc) · 15.2 KB
/
chart-view.ts
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
import { When, Then, Given } from 'cypress-cucumber-preprocessor/steps';
import { guidedTour } from '@console/cypress-integration-tests/views/guided-tour';
import { modal } from '@console/cypress-integration-tests/views/modal';
import { nav } from '@console/cypress-integration-tests/views/nav';
import { pageTitle } from '@console/dev-console/integration-tests/support/constants';
import {
devNavigationMenu,
operators,
resources,
switchPerspective,
} from '@console/dev-console/integration-tests/support/constants/global';
import {
createGitWorkload,
createOperatorBacked,
verifyAndInstallOperator,
} from '@console/dev-console/integration-tests/support/pages';
import {
app,
navigateTo,
perspective,
projectNameSpace,
yamlEditor,
} from '@console/dev-console/integration-tests/support/pages/app';
import { chartAreaPO } from '../../page-objects/chart-area-po';
import { topologyPO, typeOfWorkload } from '../../page-objects/topology-po';
import {
addToProjectOptions,
createWorkloadUsingOptions,
verifyMultipleWorkloadInTopologyPage,
} from '../../pages/functions/chart-functions';
import {
createServiceBindingConnect,
topologyActions,
topologyHelper,
topologyPage,
topologySidePane,
} from '../../pages/topology';
When('user navigates to Topology page', () => {
navigateTo(devNavigationMenu.Topology);
});
Then('user sees Topology page with message {string}', (message: string) => {
cy.get(topologyPO.emptyText).contains(message);
});
Given('user is at the Topology page', () => {
navigateTo(devNavigationMenu.Topology);
});
When('user clicks on {string} link in the topology page', (addLink) => {
cy.get(topologyPO.graph.addLink).should('be.visible').should('have.text', addLink);
cy.get(topologyPO.graph.addLink).click();
});
Then('user will be redirected to Add page', () => {
cy.url().should('include', 'add');
app.waitForLoad();
cy.contains(pageTitle.Add).should('be.visible');
});
When('user clicks on {string} link in the empty topology page', (build: string) => {
cy.byTestID(build.toLowerCase().replace(/\s+/g, '-').trim()).should('be.visible').click();
cy.log(`Quick search bar can be seen with ${build} link`);
});
Then('user will be able to see Add to project search bar', () => {
cy.get(topologyPO.graph.quickSearch).should('be.visible');
});
Given('user has created a deployment workload named {string}', (componentName: string) => {
navigateTo(devNavigationMenu.Add);
createGitWorkload(
'https://github.com/sclorg/nodejs-ex.git',
componentName,
'Deployment',
'nodejs-ex-git-app',
);
});
Given('user has created a deployment workload {string}', (componentName: string) => {
navigateTo(devNavigationMenu.Add);
createGitWorkload(
'https://github.com/sclorg/nodejs-ex.git',
componentName,
'Deployment',
'nodejs-ex-git-app',
);
});
Given('user has created a deployment config workload {string}', (componentName: string) => {
navigateTo(devNavigationMenu.Add);
createGitWorkload(
'https://github.com/sclorg/nodejs-ex.git',
componentName,
'Deployment Config',
'nodejs-ex-git-app',
);
});
When('user navigates to Topology page', () => {
navigateTo(devNavigationMenu.Topology);
});
Then(
'user sees {string} and {string} workloads in topology chart area',
(workload1: string, workload2: string) => {
topologyHelper.verifyWorkloadInTopologyPage(workload1);
topologyHelper.verifyWorkloadInTopologyPage(workload2);
},
);
Given(
'user created {string} workload',
(resourceType: string, componentName: string = `${resourceType.toLowerCase()}-ex-git`) => {
navigateTo(devNavigationMenu.Add);
createGitWorkload(
'https://github.com/sclorg/django-ex.git',
componentName,
resourceType,
'django-ex-git-app',
);
},
);
When('user is at Topology page chart view', () => {
navigateTo(devNavigationMenu.Topology);
cy.get(topologyPO.switcher).should('have.attr', 'aria-label', 'List view');
});
When('user clicks the filter by resource on top', () => {
cy.get(topologyPO.filterByResourceDropDown).should('be.visible').click();
});
When('user clicks on {string} option', (resourceType: string) => {
cy.byTestID(resourceType).should('be.visible').click();
});
Then('user can see only the {string} workload', (workload: string) => {
cy.get(typeOfWorkload(workload)).should('be.visible');
});
When('user selects {string} option in filter menu', (searchType: string) => {
cy.get('#toggle-id').click();
cy.get("[role='menu']").find('li').contains(searchType).should('be.visible').click();
});
When('user searches for label {string}', (search: string) => {
cy.get(topologyPO.search).clear().type(search);
cy.get('.co-suggestion-box__suggestions')
.find('button')
.contains(search)
.should('be.visible')
.first()
.click();
});
Then('user can see the workload {string} visible', (workload: string) => {
cy.get(topologyPO.highlightNode).should('be.visible');
cy.get(topologyPO.highlightNode).should('contain', workload);
app.waitForDocumentLoad();
});
When('user clicks on workload {string} to open sidebar', (workloadName: string) => {
topologyPage.componentNode(workloadName).click({ force: true });
});
When(
'user opens the details page for {string} by clicking on the title',
(workloadName: string) => {
topologySidePane.selectResource(
resources.Deployments,
'aut-topology-delete-workload',
`${workloadName}`,
);
},
);
When('user navigate back to Topology page', () => {
navigateTo(devNavigationMenu.Topology);
cy.get(topologyPO.switcher).should('have.attr', 'aria-label', 'List view');
});
Then(
'user will see the the workload {string} selected with sidebar open',
(workloadName: string) => {
// topologySidePane.verify();
// topologySidePane.verifyTitle(workloadName);
cy.log(workloadName, 'sidebar is open'); // to avoid lint issues
},
);
Given('user has installed Service Binding operator', () => {
verifyAndInstallOperator(operators.ServiceBinding);
});
Given('user is at developer perspective', () => {
perspective.switchTo(switchPerspective.Developer);
guidedTour.close();
nav.sidenav.switcher.shouldHaveText(switchPerspective.Developer);
});
When('user right clicks on workload {string}', (appName: string) => {
topologyPage.rightClickOnNode(appName);
});
When('user clicks on {string} option from context menu', (actionItem: string) => {
app.waitForLoad();
topologyActions.selectAction(actionItem);
});
Then('user will see {string} modal', (modalName: string) => {
app.waitForLoad();
cy.get('[aria-label="Modal"]').should('be.visible').should('contain', modalName);
});
Then('user will see alert {string}', (alertName: string) => {
app.waitForDocumentLoad();
cy.get('[aria-label="Default Alert"]').should('be.visible').should('contain', alertName);
modal.cancel();
});
Given('user has installed Crunchy Postgres for Kubernetes operator', () => {
verifyAndInstallOperator(operators.CrunchyPostgresforKubernetes);
});
Given('user navigates to Topology Page', () => {
perspective.switchTo(switchPerspective.Developer);
projectNameSpace.selectOrCreateProject('aut-topology-delete-workload');
navigateTo(devNavigationMenu.Topology);
app.waitForLoad();
topologyPage.verifyTopologyPage();
});
Then('user is able to see Start building your application, Add page links', () => {
cy.get(topologyPO.emptyView.startBuildingYourApplicationLink).should('be.visible');
cy.get(topologyPO.emptyView.addPageLink).should('be.visible');
});
Then('Display options dropdown, Filter by resource and Find by name fields are disabled', () => {
cy.contains('Display options').should('be.disabled');
cy.get(topologyPO.filterByResourceDropDown).should('be.disabled');
cy.get(topologyPO.search).should('be.disabled');
});
Then('switch view is disabled', () => {
cy.get(topologyPO.switcher).should('have.attr', 'aria-disabled', 'true');
});
When('user right clicks on the node {string} to open context menu', (nodeName: string) => {
topologyPage.rightClickOnNode(nodeName);
});
Then(
'user is able to see context menu options like Edit Application Grouping, Edit Pod Count, Pause Rollouts, Add Health Checks, Add Horizontal Pod Autoscaler, Add Storage, Edit Update Strategy, Edit Labels, Edit Annotations, Edit Deployment, Delete Deployment',
() => {
cy.get(chartAreaPO.editApplicationGrouping).should('be.visible');
cy.get(chartAreaPO.editPodCount).should('be.visible');
cy.get(chartAreaPO.pauseRollouts).should('be.visible');
cy.get(chartAreaPO.addHealthChecks).should('be.visible');
cy.get(chartAreaPO.addHorizontalPod).should('be.visible');
cy.get(chartAreaPO.addStorage).should('be.visible');
cy.get(chartAreaPO.editUpdateStrategy).should('be.visible');
cy.get(chartAreaPO.editLabels).should('be.visible');
cy.get(chartAreaPO.editAnnotations).should('be.visible');
cy.get(chartAreaPO.editDeployment).should('be.visible');
cy.get(chartAreaPO.deleteDeployment).should('be.visible');
},
);
When('user right clicks on the empty chart area', () => {
cy.get(chartAreaPO.topologyArea).rightclick(10, 10);
});
When('user hovers on Add to Project', () => {
cy.get(chartAreaPO.addToProject).trigger('mouseover');
});
Then(
'user is able to see options like Samples, Import from Git, Container Image, From Dockerfile, From Devfile, From Catalog, Database, Operator Backed, Helm Charts, Event Source, Channel',
() => {
cy.get(chartAreaPO.samples).should('be.visible');
cy.get(chartAreaPO.importFromGit).should('be.visible');
cy.get(chartAreaPO.containerImage).should('be.visible');
cy.get(chartAreaPO.catalog).should('be.visible');
cy.get(chartAreaPO.database).should('be.visible');
cy.get(chartAreaPO.operatorBacked).should('be.visible');
cy.get(chartAreaPO.helmCharts).should('be.visible');
cy.get(chartAreaPO.eventsource).should('be.visible');
cy.get(chartAreaPO.channel).should('be.visible');
},
);
When('user clicks on Samples', () => {
cy.get(chartAreaPO.samples).click();
});
When('user selects go sample', () => {
cy.get(chartAreaPO.filterItem).type('Go');
cy.get(chartAreaPO.sampleBuilderGo).click();
});
When('user hovers on Add to Project and clicks on {string}', (optionName: string) => {
cy.get(chartAreaPO.topologyArea).rightclick(10, 10);
cy.get(chartAreaPO.addToProject).trigger('mouseover');
addToProjectOptions(optionName);
});
When('user fills the {string} form and clicks Create', (optionName: string) => {
createWorkloadUsingOptions(optionName);
});
When(
'user fills the {string} form with yaml at {string} and clicks Create',
(optionName: string, yamlLocation: string) => {
createWorkloadUsingOptions(optionName, yamlLocation);
},
);
When('user selects Python Builder Image and clicks Create Application', () => {
cy.get(chartAreaPO.filterItem).type('python');
cy.get(chartAreaPO.pythonBuilderImage).click();
cy.get(chartAreaPO.overlayCreate).click({ force: true });
});
When('user selects Postgres Database and clicks on Instantiate Template', () => {
cy.get(chartAreaPO.filterItem).type('postgresql');
cy.get(chartAreaPO.postgresqlTemplate).click();
cy.get(chartAreaPO.overlayCreate).click({ force: true });
});
When('user selects {string} and clicks on Create', (operator: string) => {
cy.get(chartAreaPO.filterItem).type(operator);
cy.get(chartAreaPO.operatorBackedPostgres).click();
cy.get(chartAreaPO.overlayCreate).click({ force: true });
});
When('user selects Nodejs and clicks on Install Helm Charts', () => {
cy.get(chartAreaPO.filterItem).type('nodejs');
cy.get(chartAreaPO.helmNodejs).eq(0).click();
cy.get(chartAreaPO.overlayCreate).click({ force: true });
});
When('user selects Api Server Source and clicks on Create Event Source', () => {
cy.get(chartAreaPO.filterItem).type('ApiServerSource');
cy.get(chartAreaPO.apiEventSource).click();
cy.get(chartAreaPO.overlayCreate).click({ force: true });
});
When('user clicks on Create button', () => {
cy.get(chartAreaPO.contentScrollable).contains('Create').click();
});
Then(
'user is able to see different applications created from Samples, Import from Git, Container Image, From Catalog, Database, Operator Backed, Helm Charts, Event Source, Channel',
() => {
verifyMultipleWorkloadInTopologyPage([
'golang-sample',
'nodejs-ex-git',
'hello-openshift',
'python-app',
'postgres',
'hippo',
'helm-nodejs',
'api-server-source',
'channel',
]);
},
);
Given('user has created namespace {string}', (projectName: string) => {
Cypress.env('NAMESPACE', projectName);
projectNameSpace.selectOrCreateProject(`${projectName}`);
});
Given('user has installed Redis Operator', () => {
verifyAndInstallOperator(operators.RedisOperator);
});
Given('user has installed Red Hat OpenShift distributed tracing platform', () => {
verifyAndInstallOperator(operators.Jaeger);
});
Given(
'user has created a operator backed service of {string} operator named {string}',
(operatorName, name: string) => {
navigateTo(devNavigationMenu.Add);
createOperatorBacked(operatorName, name);
},
);
Given(
'user has created a operator backed service {string} from yaml {string}',
(name: string, location: string) => {
createWorkloadUsingOptions('Operator Backed', location);
topologyHelper.verifyWorkloadInTopologyPage(name);
},
);
Given(
'user has created service binding connnector {string} between {string} and {string}',
(bindingName, node1, node2: string) => {
createServiceBindingConnect(bindingName, node1, node2);
},
);
When('user clicks on service binding connector', () => {
cy.byLegacyTestID('edge-handler').should('be.visible').click();
});
When('user clicks on the service binding name {string} at the sidebar', (bindingName: string) => {
cy.byLegacyTestID(`${bindingName}`).should('be.visible').click();
});
Then('user will see {string} Status on Service binding details page', (status: string) => {
cy.byTestID('resource-status').should('have.text', status);
cy.exec(`oc delete namespace ${Cypress.env('NAMESPACE')}`, { failOnNonZeroExit: false });
});
Then('user will see service binding connection', () => {
cy.byLegacyTestID('edge-handler').should('be.visible');
});
When('user clicks on import YAML button from topology page', () => {
app.waitForLoad();
topologyPage.verifyTopologyPage();
cy.get('[data-test="import-yaml"]').click();
cy.get('.yaml-editor').should('be.visible');
});
When('user enters yaml content from yaml file {string} in the editor', (yamlFile: string) => {
const yamlContent = `support/${yamlFile}`;
yamlEditor.isLoaded();
yamlEditor.clearYAMLEditor();
yamlEditor.setEditorContent(yamlContent);
});
When('user clicks on Create button in import YAML', () => {
yamlEditor.clickSave();
});
When('user sees {string} Title on Service binding details page', (title: string) => {
app.waitForLoad();
cy.get('[data-test-id="resource-title"]').should('have.text', title);
});
Then(
'user will see {string} in Label Selector section on Service binding details page',
(label: string) => {
cy.byTestID('label-list').should('have.text', label);
},
);
Then(
'user will see {string} in Label Selector section on Service binding connnector topology sidebar',
(label: string) => {
topologySidePane.selectTab('Details');
cy.byTestID('label-list').should('have.text', label);
},
);