graphdb-workbench-tests 2.3.1 → 2.4.0-TR1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/fixtures/graphdb-import/resource-test-data.ttl +99 -0
  2. package/fixtures/graphql-editor/default-query-response.json +517 -0
  3. package/fixtures/locale-en.json +18 -5
  4. package/fixtures/namespaces/ontotext-generated-namespace.json +22 -0
  5. package/fixtures/queries/empty-query-response.json +11 -0
  6. package/integration/explore/graphs.overview.spec.js +4 -2
  7. package/integration/explore/similariti-index-create.spec.js +315 -0
  8. package/integration/explore/similarity-index.spec.js +88 -0
  9. package/integration/explore/similarity.spec.js +156 -47
  10. package/integration/explore/visual-graph/graphs-config.spec.js +452 -0
  11. package/integration/explore/{visual.graph.spec.js → visual-graph/visual.graph.spec.js} +145 -348
  12. package/integration/home/language-change.spec.js +3 -3
  13. package/integration/import/import.user.data.spec.js +4 -4
  14. package/integration/resource/resource.spec.js +354 -0
  15. package/integration/setup/jdbc-create.spec.js +316 -0
  16. package/integration/setup/jdbc.spec.js +99 -178
  17. package/integration/setup/my-settings.spec.js +9 -41
  18. package/integration/setup/sparql-template-create.js +141 -0
  19. package/integration/setup/sparql-templates.spec.js +82 -146
  20. package/integration/sparql-editor/actions/execute-query.spec.js +44 -0
  21. package/integration/sparql-editor/actions/expand-results-over-sameas.spec.js +136 -0
  22. package/integration/sparql-editor/actions/include-inferred-statements.spec.js +100 -0
  23. package/integration/sparql-editor/actions/save-query.spec.js +70 -0
  24. package/integration/sparql-editor/actions/show-saved-queries.spec.js +61 -0
  25. package/integration/sparql-editor/internationalization.spec.js +41 -0
  26. package/integration/sparql-editor/saved-query/abort-query.spec.js +60 -0
  27. package/integration/sparql-editor/saved-query/delete-query.spec.js +56 -0
  28. package/integration/sparql-editor/saved-query/edit-query.spec.js +68 -0
  29. package/integration/sparql-editor/saved-query/share-query.spec.js +78 -0
  30. package/integration/sparql-editor/sparql-editor.spec.js +20 -0
  31. package/integration/sparql-editor/yasgui-tabs.spec.js +107 -0
  32. package/integration/sparql-editor/yasr/download-as.spec.js +62 -0
  33. package/integration/sparql-editor/yasr/pagination.spec.js +234 -0
  34. package/integration/sparql-editor/yasr/table-plugin.spec.js +191 -0
  35. package/integration/sparql-editor/yasr/toolbar/visual-button.spec.js +56 -0
  36. package/integration-flaky/setup/sparql-template-create.js +139 -0
  37. package/integration-flaky/sparql-editor/actions/execute-update-query.spec.js +89 -0
  38. package/integration-flaky/sparql-editor/actions/share-query.spec.js +84 -0
  39. package/integration-flaky/sparql-editor/lucene-connector.spec.js +62 -0
  40. package/package.json +3 -2
  41. package/steps/application-steps.js +23 -0
  42. package/steps/error-steps.js +9 -0
  43. package/steps/explore/graphs-overview-steps.js +24 -0
  44. package/steps/explore/similarity-index-create-steps.js +113 -0
  45. package/steps/explore/similarity-indexes-steps.js +18 -0
  46. package/steps/import-steps.js +8 -1
  47. package/steps/language-selector-steps.js +22 -0
  48. package/steps/loader-steps.js +10 -0
  49. package/steps/lucene-connector-steps.js +43 -0
  50. package/steps/main-menu-steps.js +39 -0
  51. package/steps/modal-dialog-steps.js +113 -0
  52. package/steps/repository-selector-steps.js +26 -0
  53. package/steps/resource/resource-edit-steps.js +111 -0
  54. package/steps/resource/resource-steps.js +145 -0
  55. package/steps/setup/jdbc-create-steps.js +97 -0
  56. package/steps/setup/jdbc-steps.js +42 -0
  57. package/steps/setup/sparql-create-update-steps.js +55 -0
  58. package/steps/setup/sparql-templates-steps.js +34 -0
  59. package/steps/sparql-editor-steps.js +20 -0
  60. package/steps/visual-graph-steps.js +340 -3
  61. package/steps/yasgui/confirmation-dialog-steps.js +13 -0
  62. package/steps/yasgui/pagination-steps.js +47 -0
  63. package/steps/yasgui/plugin/error-plugin-steps.js +10 -0
  64. package/steps/yasgui/save-query-dialog.js +61 -0
  65. package/steps/yasgui/saved-queries-dialog.js +29 -0
  66. package/steps/yasgui/saved-query.js +25 -0
  67. package/steps/yasgui/share-saved-query-dialog.js +25 -0
  68. package/steps/yasgui/table-plugin-steps.js +29 -0
  69. package/steps/yasgui/yasgui-steps.js +191 -0
  70. package/steps/yasgui/yasqe-steps.js +187 -0
  71. package/steps/yasgui/yasr-steps.js +105 -0
  72. package/stubs/namespace-stubs.js +10 -0
  73. package/stubs/security-stubs.js +69 -0
  74. package/stubs/yasgui/connectors-stubs.js +12 -0
  75. package/stubs/yasgui/query-stubs.js +258 -0
  76. package/support/index.js +2 -0
  77. package/support/repository-commands.js +6 -1
  78. package/support/sparql-commands.js +1 -1
  79. package/support/visual-graph-commands.js +25 -0
  80. package/integration/sparql/main.menu.spec.js +0 -196
  81. package/integration/sparql/sparql-error-handling.spec.js +0 -74
  82. package/integration/sparql/sparql-language-change.spec.js +0 -58
  83. package/integration/sparql/sparql-result-formating.spec.js +0 -84
  84. package/integration/sparql/sparql.menu.spec.js +0 -1244
  85. package/integration-flaky/setup/sparql-templates.spec.js +0 -125
  86. package/integration-flaky/sparql/sparql-language-change.spec.js +0 -45
  87. package/integration-flaky/sparql/sparql.menu.spec.js +0 -75
  88. package/steps/sparql-steps.js +0 -227
@@ -0,0 +1,452 @@
1
+ import {ApplicationSteps} from "../../../steps/application-steps";
2
+ import {YasqeSteps} from "../../../steps/yasgui/yasqe-steps";
3
+ import {YasrSteps} from "../../../steps/yasgui/yasr-steps";
4
+ import {ModalDialogSteps} from "../../../steps/modal-dialog-steps";
5
+ import {VisualGraphSteps} from "../../../steps/visual-graph-steps";
6
+
7
+ const FILE_TO_IMPORT = 'wine.rdf';
8
+ const QUERY_START = `# CONSTRUCT or DESCRIBE query. The results will be rendered visually as a graph of triples.\nCONSTRUCT WHERE {\n\t?s ?p ?o\n} LIMIT 10`;
9
+ const QUERY_EXPAND_NODE = `# Note that ?node is the node you clicked and must be used in the query\nPREFIX rank: <http://www.ontotext.com/owlim/RDFRank#>\nPREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\nCONSTRUCT {\n # The triples that will be added to the visual graph\n ?node ?edge ?newNodeLTR .\n ?newNodeRTL ?edge ?node .\n} WHERE {\n {\n # Left to right relations (starting IRI is the subject)\n ?node ?edge ?newNodeLTR .\n\n # Select only IRIs\n FILTER(isIRI(?newNodeLTR) || rdf:isTriple(?newNodeLTR))\n } UNION {\n # Right to left relations (starting IRI is the object)\n ?newNodeRTL ?edge ?node .\n\n # Select only IRIs\n FILTER(isIRI(?newNodeRTL) || rdf:isTriple(?newNodeRTL))\n }\n FILTER(isIRI(?node) || rdf:isTriple(?node))\n} ORDER BY ?edge`;
10
+
11
+ describe('Graphs config', () => {
12
+
13
+ let repositoryId = 'graphRepo' + Date.now();
14
+ let graphConfigName = 'graph-config';
15
+
16
+ before(() => {
17
+ cy.clearLocalStorage('ls.graphs-viz');
18
+ repositoryId = 'repo' + Date.now();
19
+ cy.createRepository({id: repositoryId});
20
+ cy.importServerFile(repositoryId, FILE_TO_IMPORT);
21
+ });
22
+
23
+ after(() => {
24
+ cy.clearLocalStorage('ls.graphs-viz');
25
+ cy.setDefaultUserData();
26
+ cy.deleteRepository(repositoryId);
27
+ });
28
+
29
+ beforeEach(() => {
30
+ cy.presetRepository(repositoryId);
31
+ });
32
+
33
+ afterEach(() => {
34
+ cy.deleteGraphConfig(graphConfigName);
35
+ });
36
+
37
+ it('Should be able to switch between wizard tabs using the previous-next buttons', () => {
38
+ // Given I have started a create config wizard
39
+ startCreateConfigWizard();
40
+ // Then I expect to see the first wizard tab
41
+ VisualGraphSteps.getConfigWizardTab(1).should('be.visible')
42
+ .and('have.class', 'active');
43
+ // And I should not see the previous page button
44
+ VisualGraphSteps.getPreviousPageButton().should('not.be.visible');
45
+ // When I click on next buttons
46
+ // Then I expect wizard tabs to be switched
47
+ VisualGraphSteps.goToNextPage();
48
+ VisualGraphSteps.getConfigWizardTab(2).should('be.visible')
49
+ .and('have.class', 'active');
50
+ VisualGraphSteps.goToNextPage();
51
+ VisualGraphSteps.getConfigWizardTab(3).should('be.visible')
52
+ .and('have.class', 'active');
53
+ VisualGraphSteps.goToNextPage();
54
+ VisualGraphSteps.getConfigWizardTab(4).should('be.visible')
55
+ .and('have.class', 'active');
56
+ VisualGraphSteps.goToNextPage();
57
+ VisualGraphSteps.getConfigWizardTab(5).should('be.visible')
58
+ .and('have.class', 'active');
59
+ // When I am on the last wizard tab
60
+ // Then I should not see the next page button
61
+ VisualGraphSteps.getNextPageButton().should('not.be.visible');
62
+ });
63
+
64
+ it('Should see the first tab in create graph config wizard', () => {
65
+ // Given I have started a create config wizard
66
+ startCreateConfigWizard();
67
+ // And I should see the create config wizard tabs
68
+ // And the first tab should be active
69
+ VisualGraphSteps.getConfigWizardTab(1).should('be.visible')
70
+ .and('contain', 'Starting point')
71
+ .and('have.class', 'active');
72
+
73
+ // In the Starting point tab
74
+
75
+ // And I should see the start mode selectors
76
+ VisualGraphSteps.getStartModes().should('have.length', 3);
77
+ // And the search mode should be selected
78
+ VisualGraphSteps.getStartModeSelector('search').should('be.checked');
79
+ VisualGraphSteps.getStartMode('search').should('contain', 'Start with a search box');
80
+
81
+ // When I select the node mode
82
+ VisualGraphSteps.selectStartMode('node');
83
+ // Then I expect selector to become active
84
+ VisualGraphSteps.getStartModeSelector('node').should('be.checked');
85
+ VisualGraphSteps.getStartMode('node').should('contain', 'Start with a fixed node');
86
+ // And I should see the start node selector field
87
+ VisualGraphSteps.getStartNodeSelectorField().should('be.visible').and('be.empty');
88
+
89
+ // When I select the query mode
90
+ VisualGraphSteps.selectStartMode('query');
91
+ // Then I expect selector to become active
92
+ VisualGraphSteps.getStartModeSelector('query').should('be.checked');
93
+ VisualGraphSteps.getStartMode('query').should('contain', 'Start with graph query results');
94
+ // And I should see a query editor
95
+ checkEditorWithQuery(' ');
96
+ // And I should see predefined sample queries
97
+ VisualGraphSteps.getPredefinedQuerySamples().should('have.length', 1);
98
+ // And I should not see user sample queries
99
+ VisualGraphSteps.getUserQuerySamples().should('have.length.gte', 0);
100
+ // And I should see the show preview button when query mode is query
101
+ VisualGraphSteps.getPreviewQueryResultsButton().should('be.visible');
102
+ });
103
+
104
+ it('Should see the second tab in create graph config wizard', () => {
105
+ // Given I have started a create config wizard
106
+ startCreateConfigWizard();
107
+
108
+ // When I open the graph expansion tab
109
+ VisualGraphSteps.openConfigWizardTab(2);
110
+ VisualGraphSteps.getConfigWizardTab(2).should('contain', 'Graph expansion')
111
+ .and('have.class', 'active');
112
+ // Then I should see an info box
113
+ VisualGraphSteps.getHelpInfoBox().should('be.visible');
114
+ // And I should see the query editor
115
+ checkEditorWithQuery(' ');
116
+ // And I should see predefined sample queries
117
+ VisualGraphSteps.getPredefinedQuerySamples().should('have.length', 2);
118
+ // And I should not see user sample queries
119
+ VisualGraphSteps.getUserQuerySamples().should('have.length', 0);
120
+ // And I should see the show preview button
121
+ VisualGraphSteps.getPreviewQueryResultsButton().should('be.visible');
122
+ });
123
+
124
+ it('Should see the third tab in create graph config wizard', () => {
125
+ // Given I have started a create config wizard
126
+ startCreateConfigWizard();
127
+
128
+ // When I open the graph node basics tab
129
+ VisualGraphSteps.openConfigWizardTab(3);
130
+ VisualGraphSteps.getConfigWizardTab(3).should('contain', 'Node basics')
131
+ .and('have.class', 'active');
132
+ // Then I should see an info box
133
+ VisualGraphSteps.getHelpInfoBox().should('be.visible');
134
+ // And I should see the query editor
135
+ checkEditorWithQuery(' ');
136
+ // And I should see predefined sample queries
137
+ VisualGraphSteps.getPredefinedQuerySamples().should('have.length', 2);
138
+ // And I should not see user sample queries
139
+ VisualGraphSteps.getUserQuerySamples().should('have.length', 0);
140
+ // And I should see the show preview button
141
+ VisualGraphSteps.getPreviewQueryResultsButton().should('be.visible');
142
+ });
143
+
144
+ it('Should see the fourth tab in create graph config wizard', () => {
145
+ // Given I have started a create config wizard
146
+ startCreateConfigWizard();
147
+
148
+ // When I open the graph edge basics tab
149
+ VisualGraphSteps.openConfigWizardTab(4);
150
+ VisualGraphSteps.getConfigWizardTab(4).should('contain', 'Edge basics')
151
+ .and('have.class', 'active');
152
+ // Then I should see an info box
153
+ VisualGraphSteps.getHelpInfoBox().should('be.visible');
154
+ // And I should see the query editor
155
+ checkEditorWithQuery(' ');
156
+ // And I should see predefined sample queries
157
+ VisualGraphSteps.getPredefinedQuerySamples().should('have.length', 2);
158
+ // And I should not see user sample queries
159
+ VisualGraphSteps.getUserQuerySamples().should('have.length', 0);
160
+ // And I should see the show preview button
161
+ VisualGraphSteps.getPreviewQueryResultsButton().should('be.visible');
162
+ });
163
+
164
+ it('Should see the fifth tab in create graph config wizard', () => {
165
+ // Given I have started a create config wizard
166
+ startCreateConfigWizard();
167
+
168
+ // When I open the graph edge basics tab
169
+ VisualGraphSteps.openConfigWizardTab(5);
170
+ VisualGraphSteps.getConfigWizardTab(5).should('contain', 'Node extra')
171
+ .and('have.class', 'active');
172
+ // Then I should see an info box
173
+ VisualGraphSteps.getHelpInfoBox().should('be.visible');
174
+ // And I should see the query editor
175
+ checkEditorWithQuery(' ');
176
+ // And I should see predefined sample queries
177
+ VisualGraphSteps.getPredefinedQuerySamples().should('have.length', 2);
178
+ // And I should not see user sample queries
179
+ VisualGraphSteps.getUserQuerySamples().should('have.length', 0);
180
+ // And I should see the show preview button
181
+ VisualGraphSteps.getPreviewQueryResultsButton().should('be.visible');
182
+ });
183
+
184
+ it('Should be able to cancel config creation', () => {
185
+ // Given I have started a create config wizard
186
+ startCreateConfigWizard();
187
+ // When I click on cancel
188
+ VisualGraphSteps.cancelSaveConfig();
189
+ // Then I expect to be redirected to configs list view
190
+ cy.url().should('eq', Cypress.config('baseUrl') + '/graphs-visualizations');
191
+ });
192
+
193
+ it('Should not allow config creation without a name', () => {
194
+ // Given I have started a create config wizard
195
+ startCreateConfigWizard();
196
+ // When I click on save
197
+ VisualGraphSteps.saveConfig();
198
+ // Then I expect a warning notification
199
+ ApplicationSteps.getWarningNotification().should('be.visible');
200
+ // And I should stay on the same page
201
+ cy.url().should('include', '/graphs-visualizations/config/save');
202
+ });
203
+
204
+ it('Should create graph config with search box', () => {
205
+ // Given I have started a create config wizard
206
+ startCreateConfigWizard();
207
+ // When I fill in the config name
208
+ VisualGraphSteps.typeGraphConfigName(graphConfigName);
209
+ // And I save the graph config
210
+ saveGraphConfig(graphConfigName);
211
+ // When I open the graph config
212
+ VisualGraphSteps.openGraphConfig(graphConfigName);
213
+ // Then I expect the uri search field for the saved graph to be opened
214
+ cy.url().should('contain', Cypress.config('baseUrl') + '/graphs-visualizations?config=');
215
+ VisualGraphSteps.getGraphConfigSearchPanelName().should('contain', graphConfigName);
216
+ });
217
+
218
+ it('Should create graph config with fixed node', () => {
219
+ cy.enableAutocomplete(repositoryId);
220
+ // Given I have started a create config wizard
221
+ startCreateConfigWizard();
222
+ // When I fill in the config name
223
+ VisualGraphSteps.typeGraphConfigName(graphConfigName);
224
+ // And I select the config with fixed node option
225
+ VisualGraphSteps.selectStartMode('node');
226
+ // And I type an uri and select it
227
+ VisualGraphSteps.selectStartNode('USRegion', 0);
228
+ VisualGraphSteps.getSelectedStartNodeUri().should('contain', 'http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#USRegion');
229
+ // And I save the graph config
230
+ saveGraphConfig(graphConfigName);
231
+ // When I open the graph config
232
+ VisualGraphSteps.openGraphConfig(graphConfigName);
233
+ // Then I expect the graph visualization of the saved config to be opened
234
+ cy.url().should('contain', Cypress.config('baseUrl') + '/graphs-visualizations?config=');
235
+ VisualGraphSteps.getGraphVisualizationPane().should('be.visible');
236
+ });
237
+
238
+ it('Should not be able to switch to next wizard tabs when starting point query is not provided ', () => {
239
+ // Given I have started a create config wizard
240
+ startCreateConfigWizard();
241
+ // And I populated in the config name
242
+ VisualGraphSteps.typeGraphConfigName(graphConfigName);
243
+ // And I selected the config with query results option
244
+ VisualGraphSteps.selectStartMode('query');
245
+ // When I try to open the graph expansion tab without providing a starting point query
246
+ VisualGraphSteps.openConfigWizardTab(2);
247
+ // Then I expect to see a warning
248
+ // And the current first tab to remain open
249
+ ApplicationSteps.getWarningNotification().should('be.visible');
250
+ VisualGraphSteps.getConfigWizardTab(1).should('be.visible')
251
+ .and('have.class', 'active');
252
+ });
253
+
254
+ it('Should be able to create graph config with query results', () => {
255
+ // Given I have started a create config wizard
256
+ startCreateConfigWizard();
257
+ // And I populated in the config name
258
+ VisualGraphSteps.typeGraphConfigName(graphConfigName);
259
+ // And I selected the config with query results option
260
+ VisualGraphSteps.selectStartMode('query');
261
+ // And I selected a query
262
+ checkEditorWithQuery(' ');
263
+ VisualGraphSteps.selectPredefinedQuerySample(0);
264
+ YasqeSteps.getQuery(500).should('contain', QUERY_START);
265
+ // When I select preview query results
266
+ VisualGraphSteps.previewQueryResults();
267
+ // Then I expect to see the results table
268
+ YasrSteps.getYasr().should('be.visible');
269
+ // When I select to edit query
270
+ VisualGraphSteps.editQuery();
271
+ // Then I expect to see the query editor with the previously selected query
272
+ checkEditorWithQuery(QUERY_START);
273
+ // And I open the graph expansion tab
274
+ VisualGraphSteps.openConfigWizardTab(2);
275
+ // Then I expect the tab to be opened and become active
276
+ VisualGraphSteps.getConfigWizardTab(2).should('have.class', 'active');
277
+ // And the query editor to be visible and empty
278
+ checkEditorWithQuery(' ');
279
+ // When I select a predefined query from the list
280
+ VisualGraphSteps.selectPredefinedQuerySample(0);
281
+ YasqeSteps.getQuery(500).should('contain', QUERY_EXPAND_NODE);
282
+ // When I select to preview query results
283
+ VisualGraphSteps.previewQueryResults();
284
+ // Then I expect to see the results table
285
+ YasrSteps.getYasr().should('be.visible');
286
+ // When I select to edit the selected query
287
+ VisualGraphSteps.editQuery();
288
+ // Then I expect to see the editor with the selected query
289
+ YasqeSteps.getQuery(500).should('contain', QUERY_EXPAND_NODE);
290
+ // When I click on save
291
+ saveGraphConfig(graphConfigName);
292
+ // Then I expect config to be saved
293
+ // When I open the graph config
294
+ VisualGraphSteps.openGraphConfig(graphConfigName);
295
+ // Then I expect the graph visualization of the saved config to be opened
296
+ cy.url().should('contain', Cypress.config('baseUrl') + '/graphs-visualizations?config=');
297
+ VisualGraphSteps.getGraphVisualizationPane().should('be.visible');
298
+ });
299
+
300
+ it('Should be able to update existing graph config', () => {
301
+ // Given I have created a graph config with start query
302
+ startCreateConfigWizard();
303
+ VisualGraphSteps.typeGraphConfigName(graphConfigName);
304
+ VisualGraphSteps.selectStartMode('query');
305
+ checkEditorWithQuery(' ');
306
+ VisualGraphSteps.selectPredefinedQuerySample(0);
307
+ checkEditorWithQuery(QUERY_START);
308
+ saveGraphConfig(graphConfigName);
309
+ // When I select edit for the new config
310
+ VisualGraphSteps.editConfig(graphConfigName);
311
+ // Then I expect to see the first wizard tab with the selected start query
312
+ checkEditorWithQuery(QUERY_START);
313
+ // When I change the query
314
+ VisualGraphSteps.getRevertQueryButton().should('be.disabled');
315
+ YasqeSteps.writeInEditor('##');
316
+ // Then I expect to be able to revert it
317
+ VisualGraphSteps.getRevertQueryButton().should('be.enabled');
318
+ VisualGraphSteps.revertQuery();
319
+ VisualGraphSteps.getRevertQueryButton().should('be.disabled');
320
+ checkEditorWithQuery(QUERY_START);
321
+ // When I edit the config by adding an expand query
322
+ VisualGraphSteps.goToNextPage();
323
+ VisualGraphSteps.getConfigWizardTab(2).should('be.visible');
324
+ VisualGraphSteps.selectPredefinedQuerySample(0);
325
+ checkEditorWithQuery(QUERY_EXPAND_NODE);
326
+ saveGraphConfig(graphConfigName);
327
+ // Then I expect graph config to be saved with the new data
328
+ VisualGraphSteps.editConfig(graphConfigName);
329
+ checkEditorWithQuery(QUERY_START);
330
+ VisualGraphSteps.goToNextPage();
331
+ VisualGraphSteps.getConfigWizardTab(2).should('be.visible');
332
+ checkEditorWithQuery(QUERY_EXPAND_NODE);
333
+ });
334
+
335
+ it('Should prevent leaving with confirmation when start query is changed', () => {
336
+ // Given I have created a graph config with start query
337
+ startCreateConfigWizard();
338
+ VisualGraphSteps.typeGraphConfigName(graphConfigName);
339
+ VisualGraphSteps.selectStartMode('query');
340
+ checkEditorWithQuery(' ');
341
+ VisualGraphSteps.selectPredefinedQuerySample(0);
342
+ checkEditorWithQuery(QUERY_START);
343
+ saveGraphConfig(graphConfigName);
344
+ // And I open it for edit
345
+ VisualGraphSteps.editConfig(graphConfigName);
346
+ checkEditorWithQuery(QUERY_START);
347
+ // When I click cancel without changing the query
348
+ VisualGraphSteps.cancelSaveConfig();
349
+ // Then I expect to be redirected to configs list without confirmation
350
+ cy.url().should('eq', Cypress.config('baseUrl') + '/graphs-visualizations');
351
+ // And I open it for edit
352
+ VisualGraphSteps.editConfig(graphConfigName);
353
+ checkEditorWithQuery(QUERY_START);
354
+ // And I change the query
355
+ YasqeSteps.writeInEditor('##');
356
+ // When I click cancel after changing the query
357
+ VisualGraphSteps.cancelSaveConfig();
358
+ // Then I expect a confirmation for leaving the page
359
+ ModalDialogSteps.getDialog().should('be.visible');
360
+ // When I reject
361
+ ModalDialogSteps.clickOnCancelButton();
362
+ // Then I expect to remain on the same page
363
+ ModalDialogSteps.getDialog().should('not.exist');
364
+ cy.url().should('contain', '/graphs-visualizations/config/save');
365
+ // When I click cancel after changing the query
366
+ VisualGraphSteps.cancelSaveConfig();
367
+ // Then I expect a confirmation for leaving the page
368
+ ModalDialogSteps.getDialog().should('be.visible');
369
+ // When I confirm
370
+ ModalDialogSteps.clickOnConfirmButton();
371
+ // Then I expect to be redirected to configs list page
372
+ ModalDialogSteps.getDialog().should('not.exist');
373
+ cy.url().should('eq', Cypress.config('baseUrl') + '/graphs-visualizations');
374
+ });
375
+
376
+ it('Should prevent leaving with confirmation when expand query is changed', () => {
377
+ // Given I have created a graph config with start query
378
+ startCreateConfigWizard();
379
+ VisualGraphSteps.typeGraphConfigName(graphConfigName);
380
+ VisualGraphSteps.selectStartMode('query');
381
+ checkEditorWithQuery(' ');
382
+ VisualGraphSteps.selectPredefinedQuerySample(0);
383
+ checkEditorWithQuery(QUERY_START);
384
+ saveGraphConfig(graphConfigName);
385
+ // And I open it for edit
386
+ VisualGraphSteps.editConfig(graphConfigName);
387
+ // And I open the expand query wizard tab
388
+ VisualGraphSteps.openConfigWizardTab(2);
389
+ VisualGraphSteps.getConfigWizardTab(2).should('have.class', 'active');
390
+ // When I click cancel without changing the query
391
+ VisualGraphSteps.cancelSaveConfig();
392
+ // Then I expect a confirmation for leaving the page
393
+ ModalDialogSteps.getDialog().should('be.visible');
394
+ // When I reject
395
+ ModalDialogSteps.clickOnCancelButton();
396
+ // Then I expect to stay on the same page
397
+ ModalDialogSteps.getDialog().should('not.exist');
398
+ // When I select a predefined query
399
+ VisualGraphSteps.selectPredefinedQuerySample(0);
400
+ YasqeSteps.getQuery(500).should('contain', QUERY_EXPAND_NODE);
401
+ // And I try to open another page
402
+ cy.get('.main-menu .brand a').click();
403
+ // Then I expect a confirmation for leaving the page
404
+ ModalDialogSteps.getDialog().should('be.visible');
405
+ });
406
+
407
+ it('Should be able to delete existing graph config', () => {
408
+ // Given I have created a graph config
409
+ startCreateConfigWizard();
410
+ VisualGraphSteps.typeGraphConfigName(graphConfigName);
411
+ saveGraphConfig(graphConfigName);
412
+ // When I select to delete the config
413
+ VisualGraphSteps.deleteConfig(graphConfigName);
414
+ // Then I expect to see confirmation dialog
415
+ ModalDialogSteps.getDialog().should('be.visible');
416
+ // When I cancel delete operation
417
+ ModalDialogSteps.clickOnCancelButton();
418
+ ModalDialogSteps.getDialog().should('not.exist');
419
+ // Then I expect that config will not be deleted
420
+ VisualGraphSteps.getGraphConfig(graphConfigName).should('be.visible');
421
+ // When I delete and confirm the operation
422
+ VisualGraphSteps.deleteConfig(graphConfigName);
423
+ ModalDialogSteps.clickOnConfirmButton();
424
+ // Then I expect the config to be deleted
425
+ VisualGraphSteps.getGraphConfigs().should('not.exist');
426
+ });
427
+ });
428
+
429
+ function checkEditorWithQuery(query) {
430
+ VisualGraphSteps.getQueryEditor().should('be.visible');
431
+ YasqeSteps.getQuery(500).should('contain', query);
432
+ }
433
+
434
+ function saveGraphConfig(graphConfigName) {
435
+ // And I click on save
436
+ VisualGraphSteps.saveConfig();
437
+ // Then I expect a success notification
438
+ ApplicationSteps.getSuccessNotifications().should('be.visible');
439
+ // And I should be redirected to configs list view
440
+ cy.url().should('eq', Cypress.config('baseUrl') + '/graphs-visualizations');
441
+ // And the new config should be present in the list
442
+ VisualGraphSteps.getGraphConfig(graphConfigName).should('be.visible');
443
+ }
444
+
445
+ function startCreateConfigWizard() {
446
+ // Given I have opened the graphs visualizations page
447
+ cy.visit('graphs-visualizations');
448
+ // When I click on create custom graphs config
449
+ VisualGraphSteps.getCreateCustomGraphLink().click();
450
+ // Then I should see the graphs config view
451
+ cy.url().should('include', '/config/save');
452
+ }