graphdb-workbench-tests 2.0.0-TR9 → 2.0.0

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.
@@ -1,4 +1,5 @@
1
1
  import ImportSteps from '../../steps/import-steps';
2
+ import SparqlSteps from '../../steps/sparql-steps';
2
3
 
3
4
  const FILE_TO_IMPORT = 'wine.rdf';
4
5
  const RDF_STAR_FILE_TO_IMPORT = 'turtlestar-data.ttls';
@@ -62,73 +63,25 @@ describe('SPARQL screen validation', () => {
62
63
  ' inst:gateService :dropService "".\n' +
63
64
  '}';
64
65
 
65
- function createRepoAndVisit(repoOptions = {}) {
66
- createRepository(repoOptions);
67
- visitSparql(true);
68
- }
69
-
70
- function createRepository(repoOptions = {}) {
71
- repositoryId = 'sparql-' + Date.now();
72
- repoOptions.id = repositoryId;
73
- cy.createRepository(repoOptions);
74
- cy.initializeRepository(repositoryId);
75
- }
76
-
77
- function visitSparql(resetLocalStorage) {
78
- cy.visit('/sparql', {
79
- onBeforeLoad: (win) => {
80
- if (resetLocalStorage) {
81
- // Needed because the workbench app is very persistent with its local storage (it's hooked on before unload event)
82
- // TODO: Add a test that tests this !
83
- if (win.localStorage) {
84
- win.localStorage.clear();
85
- }
86
- if (win.sessionStorage) {
87
- win.sessionStorage.clear();
88
- }
89
- }
90
- win.localStorage.setItem('com.ontotext.graphdb.repository', repositoryId);
91
- }
92
- });
93
- waitUntilSparqlPageIsLoaded();
94
- }
95
-
96
- function waitUntilSparqlPageIsLoaded() {
97
- cy.window();
98
- // Workbench loading screen should not be visible
99
- cy.get('.ot-splash').should('not.be.visible');
100
-
101
- // Run query button should be clickable
102
- getRunQueryButton().should('be.visible').and('not.be.disabled');
103
-
104
- cy.waitUntilQueryIsVisible();
105
-
106
- // Run query button should be clickable
107
- getRunQueryButton().should('be.visible').and('not.be.disabled');
108
-
109
- // Editor should have a visible tab
110
- getTabs().find('.nav-link').should('be.visible');
111
-
112
- // No active loader
113
- getLoader().should('not.exist');
114
- }
115
-
116
66
  afterEach(() => {
117
67
  cy.deleteRepository(repositoryId);
118
68
  });
119
69
 
120
70
  context('SPARQL queries & filtering', () => {
121
- beforeEach(() => createRepoAndVisit());
71
+ beforeEach(() => {
72
+ repositoryId = 'sparql-' + Date.now();
73
+ SparqlSteps.createRepoAndVisit(repositoryId)
74
+ });
122
75
 
123
76
  it('Test execute default query', () => {
124
- getTabs().should('have.length', 1);
77
+ SparqlSteps.getTabs().should('have.length', 1);
125
78
 
126
79
  verifyQueryAreaEquals(DEFAULT_QUERY);
127
80
 
128
81
  // No queries should have been run for this tab
129
82
  getNoQueryRun().should('be.visible');
130
83
 
131
- executeQuery();
84
+ SparqlSteps.executeQuery();
132
85
 
133
86
  verifyResultsPageLength(70);
134
87
  });
@@ -142,7 +95,7 @@ describe('SPARQL screen validation', () => {
142
95
  // Verify pasting also works
143
96
  cy.pasteQuery(DEFAULT_QUERY_MODIFIED);
144
97
 
145
- executeQuery();
98
+ SparqlSteps.executeQuery();
146
99
 
147
100
  getResultPages().should('have.length', 2);
148
101
 
@@ -160,7 +113,7 @@ describe('SPARQL screen validation', () => {
160
113
 
161
114
  verifyQueryAreaEquals(SPARQL_STAR_QUERY);
162
115
 
163
- executeQuery();
116
+ SparqlSteps.executeQuery();
164
117
 
165
118
  getResultPages().should('have.length', 1);
166
119
 
@@ -180,7 +133,7 @@ describe('SPARQL screen validation', () => {
180
133
 
181
134
  verifyQueryAreaEquals(selectQuery);
182
135
 
183
- executeQuery();
136
+ SparqlSteps.executeQuery();
184
137
 
185
138
  getResultPages().should('have.length', 1);
186
139
 
@@ -200,7 +153,7 @@ describe('SPARQL screen validation', () => {
200
153
 
201
154
  verifyQueryAreaEquals(insertQuery);
202
155
 
203
- executeQuery();
156
+ SparqlSteps.executeQuery();
204
157
 
205
158
  getUpdateMessage()
206
159
  .should('be.visible')
@@ -213,13 +166,13 @@ describe('SPARQL screen validation', () => {
213
166
  cy.importServerFile(repositoryId, RDF_STAR_FILE_TO_IMPORT);
214
167
 
215
168
  let selectQuery = "PREFIX bd: <http://bigdata.com/RDF#>\nPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n" +
216
- "select * where {<<bd:bob foaf:mbox <mailto:bob@home>>> ?p ?o .}";
169
+ "select * where {<<bd:bob foaf:mbox <mailto:bob@home>>> ?p ?o .}";
217
170
 
218
171
  typeQuery(selectQuery);
219
172
 
220
173
  verifyQueryAreaEquals(selectQuery);
221
174
 
222
- executeQuery();
175
+ SparqlSteps.executeQuery();
223
176
 
224
177
  getResultPages().should('have.length', 1);
225
178
 
@@ -232,14 +185,14 @@ describe('SPARQL screen validation', () => {
232
185
  cy.importServerFile(repositoryId, RDF_STAR_FILE_TO_IMPORT);
233
186
 
234
187
  let deleteQuery = "PREFIX bd: <http://bigdata.com/RDF#>\nPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n" +
235
- "PREFIX dc: <http://purl.org/dc/terms/>\nPREFIX re: <http://reasoner.example.com/engines#>\n" +
236
- "delete data {<<bd:alice foaf:knows bd:bob>> dc:source re:engine_1.}";
188
+ "PREFIX dc: <http://purl.org/dc/terms/>\nPREFIX re: <http://reasoner.example.com/engines#>\n" +
189
+ "delete data {<<bd:alice foaf:knows bd:bob>> dc:source re:engine_1.}";
237
190
 
238
191
  typeQuery(deleteQuery);
239
192
 
240
193
  verifyQueryAreaEquals(deleteQuery);
241
194
 
242
- executeQuery();
195
+ SparqlSteps.executeQuery();
243
196
 
244
197
  getUpdateMessage()
245
198
  .should('be.visible')
@@ -248,14 +201,14 @@ describe('SPARQL screen validation', () => {
248
201
  getResultPages().should('have.length', 1);
249
202
 
250
203
  let selectQuery = "PREFIX bd: <http://bigdata.com/RDF#>\nPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n" +
251
- "PREFIX dc: <http://purl.org/dc/terms/>\nPREFIX re: <http://reasoner.example.com/engines#>\n" +
252
- "select * where {<<bd:alice foaf:knows bd:bob>> dc:source re:engine_1.}";
204
+ "PREFIX dc: <http://purl.org/dc/terms/>\nPREFIX re: <http://reasoner.example.com/engines#>\n" +
205
+ "select * where {<<bd:alice foaf:knows bd:bob>> dc:source re:engine_1.}";
253
206
 
254
207
  typeQuery(selectQuery);
255
208
 
256
209
  verifyQueryAreaEquals(selectQuery);
257
210
 
258
- executeQuery();
211
+ SparqlSteps.executeQuery();
259
212
 
260
213
  getResultPages().should('have.length', 1);
261
214
 
@@ -274,7 +227,7 @@ describe('SPARQL screen validation', () => {
274
227
 
275
228
  cy.pasteQuery(describeQuery);
276
229
 
277
- executeQuery();
230
+ SparqlSteps.executeQuery();
278
231
 
279
232
  cy.verifyResultsMessage('Showing results');
280
233
  cy.verifyResultsMessage('Query took');
@@ -303,7 +256,7 @@ describe('SPARQL screen validation', () => {
303
256
 
304
257
  verifyQueryAreaEquals(SPARQL_STAR_QUERY);
305
258
 
306
- executeQuery();
259
+ SparqlSteps.executeQuery();
307
260
 
308
261
  getResultPages().should('have.length', 1);
309
262
 
@@ -318,7 +271,7 @@ describe('SPARQL screen validation', () => {
318
271
  it('Test filter query results', () => {
319
272
  cy.importServerFile(repositoryId, FILE_TO_IMPORT);
320
273
 
321
- executeQuery();
274
+ SparqlSteps.executeQuery();
322
275
 
323
276
  // In the search field below the SPARQL editor enter 'White'
324
277
  getResultFilterField()
@@ -342,7 +295,7 @@ describe('SPARQL screen validation', () => {
342
295
  verifyQueryAreaContains('PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>');
343
296
  verifyQueryAreaContains('PREFIX owl: <http://www.w3.org/2002/07/owl#>');
344
297
 
345
- executeQuery();
298
+ SparqlSteps.executeQuery();
346
299
 
347
300
  cy.getResultsMessage();
348
301
  getResultsWrapper()
@@ -354,7 +307,7 @@ describe('SPARQL screen validation', () => {
354
307
 
355
308
  cy.pasteQuery(describeQuery);
356
309
 
357
- executeQuery();
310
+ SparqlSteps.executeQuery();
358
311
 
359
312
  cy.verifyResultsMessage('Showing results')
360
313
  cy.verifyResultsMessage('Query took');
@@ -380,7 +333,7 @@ describe('SPARQL screen validation', () => {
380
333
  let askQuery = 'ASK WHERE { ?s ?p ?o .FILTER (regex(?o, "ontotext.com")) }';
381
334
 
382
335
  cy.pasteQuery(askQuery);
383
- executeQuery();
336
+ SparqlSteps.executeQuery();
384
337
 
385
338
  // Confirm that all tabs (Table, Pivot Table, Google chart) are disabled
386
339
  getTableResponseButton().should('not.be.visible');
@@ -396,7 +349,7 @@ describe('SPARQL screen validation', () => {
396
349
  cy.pasteQuery(constructQuery);
397
350
  });
398
351
 
399
- executeQuery();
352
+ SparqlSteps.executeQuery();
400
353
 
401
354
  cy.getResultsMessage();
402
355
  getResultsWrapper()
@@ -416,7 +369,7 @@ describe('SPARQL screen validation', () => {
416
369
  let insertQuery = 'INSERT DATA { <urn:a> <http://a/b> <urn:b> . <urn:b> <http://a/b> <urn:c> . }';
417
370
 
418
371
  cy.pasteQuery(insertQuery);
419
- executeQuery();
372
+ SparqlSteps.executeQuery();
420
373
 
421
374
  getUpdateMessage().should('be.visible');
422
375
  getResultsWrapper().should('not.be.visible');
@@ -427,7 +380,7 @@ describe('SPARQL screen validation', () => {
427
380
  .should('be.visible');
428
381
 
429
382
  cy.pasteQuery(DEFAULT_QUERY);
430
- executeQuery();
383
+ SparqlSteps.executeQuery();
431
384
 
432
385
  // Confirm that all statements are available (70 from ruleset, 2 explicit and 2 inferred)
433
386
  getResultsWrapper().should('be.visible');
@@ -436,13 +389,13 @@ describe('SPARQL screen validation', () => {
436
389
 
437
390
  // Uncheck ‘Include inferred’
438
391
  cy.waitUntil(() =>
439
- getInferenceButton()
392
+ getInferenceButton().find('.icon-inferred-on')
440
393
  .then(infBtn => infBtn && cy.wrap(infBtn).click()))
441
394
  .then(() =>
442
395
  cy.get('.icon-inferred-off').should('be.visible'));
443
396
 
444
397
  // Confirm that only inferred statements (only 2) are available
445
- executeQuery();
398
+ SparqlSteps.executeQuery();
446
399
  verifyResultsPageLength(2);
447
400
  });
448
401
 
@@ -471,7 +424,7 @@ describe('SPARQL screen validation', () => {
471
424
  });
472
425
 
473
426
  context('SPARQL queries with OWL-Horst Optimized', () => {
474
- beforeEach(() => createRepoAndVisit({
427
+ beforeEach(() => SparqlSteps.createRepoAndVisit(repositoryId, {
475
428
  params: {
476
429
  ruleset: {
477
430
  value: 'owl-horst-optimized'
@@ -490,7 +443,7 @@ describe('SPARQL screen validation', () => {
490
443
  '}';
491
444
 
492
445
  cy.pasteQuery(defaultQueryWithoutLimit);
493
- executeQuery();
446
+ SparqlSteps.executeQuery();
494
447
 
495
448
  cy.verifyResultsMessage('1,000 of 7,065');
496
449
  getResultsWrapper()
@@ -498,11 +451,12 @@ describe('SPARQL screen validation', () => {
498
451
  verifyResultsPageLength(1000);
499
452
 
500
453
  // Disable the inference from the ">>" icon on the right of the SPARQL editor.
501
- getInferenceButton()
502
- .click()
503
- .find('.icon-inferred-off')
504
- .should('be.visible');
505
- executeQuery();
454
+ cy.waitUntil(() =>
455
+ getInferenceButton().find('.icon-inferred-on')
456
+ .then(infBtn => infBtn && cy.wrap(infBtn).click()))
457
+ .then(() =>
458
+ cy.get('.icon-inferred-off').should('be.visible'));
459
+ SparqlSteps.executeQuery();
506
460
 
507
461
  // Verify that there are 1,839 results
508
462
  cy.verifyResultsMessage('1,000 of 1,839');
@@ -523,7 +477,7 @@ describe('SPARQL screen validation', () => {
523
477
  '}';
524
478
 
525
479
  cy.pasteQuery(updateToExecute);
526
- executeQuery();
480
+ SparqlSteps.executeQuery();
527
481
  getUpdateMessage()
528
482
  .should('be.visible')
529
483
  .and('contain', 'Added 1 statements');
@@ -534,7 +488,7 @@ describe('SPARQL screen validation', () => {
534
488
  .should('be.visible');
535
489
 
536
490
  cy.pasteQuery(selectQuery);
537
- executeQuery();
491
+ SparqlSteps.executeQuery();
538
492
  verifyResultsPageLength(2);
539
493
 
540
494
  getSameAsButton()
@@ -542,19 +496,19 @@ describe('SPARQL screen validation', () => {
542
496
  .find('.icon-sameas-off')
543
497
  .should('be.visible');
544
498
 
545
- executeQuery();
499
+ SparqlSteps.executeQuery();
546
500
  verifyResultsPageLength(1);
547
501
  });
548
502
  });
549
503
 
550
504
  context('SPARQL view & download', () => {
551
- beforeEach(() => createRepoAndVisit());
505
+ beforeEach(() => SparqlSteps.createRepoAndVisit(repositoryId));
552
506
 
553
507
  it('Test open a new tab', () => {
554
508
  getNewTabButton().click();
555
509
 
556
510
  // Verify that as result of clicking addNewTab button we've opened one more tab
557
- getTabs().should('have.length', 2);
511
+ SparqlSteps.getTabs().should('have.length', 2);
558
512
 
559
513
  getLastTab()
560
514
  .should('have.class', 'active')
@@ -574,7 +528,7 @@ describe('SPARQL screen validation', () => {
574
528
  renameTab(1, firstTabName);
575
529
 
576
530
  // Still one after renaming
577
- getTabs().should('have.length', 1);
531
+ SparqlSteps.getTabs().should('have.length', 1);
578
532
 
579
533
  addTab();
580
534
 
@@ -583,7 +537,7 @@ describe('SPARQL screen validation', () => {
583
537
  // TODO: Add spec/steps for cancelling rename
584
538
 
585
539
  // Still two after renaming
586
- getTabs().should('have.length', 2);
540
+ SparqlSteps.getTabs().should('have.length', 2);
587
541
  verifyTabName(1, firstTabName);
588
542
  verifyTabName(2, secondTabName);
589
543
 
@@ -591,10 +545,10 @@ describe('SPARQL screen validation', () => {
591
545
  ImportSteps.visitUserImport();
592
546
 
593
547
  cy.visit("/sparql");
594
- waitUntilSparqlPageIsLoaded();
548
+ SparqlSteps.waitUntilSparqlPageIsLoaded();
595
549
 
596
550
  // Still two after navigation
597
- getTabs().should('have.length', 2);
551
+ SparqlSteps.getTabs().should('have.length', 2);
598
552
  verifyTabName(1, firstTabName);
599
553
  verifyTabName(2, secondTabName);
600
554
  });
@@ -617,7 +571,7 @@ describe('SPARQL screen validation', () => {
617
571
  confirmModal();
618
572
  getModal().should('not.exist');
619
573
 
620
- getTabs().should('have.length', 2);
574
+ SparqlSteps.getTabs().should('have.length', 2);
621
575
 
622
576
  verifyTabName(1, 'Tab 1');
623
577
  verifyTabName(2, 'Tab 3');
@@ -639,12 +593,12 @@ describe('SPARQL screen validation', () => {
639
593
  confirmModal();
640
594
  getModal().should('not.exist');
641
595
 
642
- getTabs().should('have.length', 1);
596
+ SparqlSteps.getTabs().should('have.length', 1);
643
597
  verifyTabName(1, 'Tab 3');
644
598
  });
645
599
 
646
600
  it('Test download query results in Supported formats', () => {
647
- executeQuery();
601
+ SparqlSteps.executeQuery();
648
602
 
649
603
  // Wait until results are visible before verifying the download menu
650
604
  getResultsWrapper().should('be.visible');
@@ -663,7 +617,7 @@ describe('SPARQL screen validation', () => {
663
617
  });
664
618
 
665
619
  it('Test switch result format tabs', () => {
666
- executeQuery();
620
+ SparqlSteps.executeQuery();
667
621
 
668
622
  openRawResponse();
669
623
  getResultsWrapper()
@@ -721,7 +675,7 @@ describe('SPARQL screen validation', () => {
721
675
  cy.get(YASR_SELECTOR).should('have.class', 'vertical');
722
676
 
723
677
  // Run the default query on vertical mode
724
- executeQuery();
678
+ SparqlSteps.executeQuery();
725
679
  // Verify that all results are properly scaled/displayed
726
680
  verifyResultsPageLength(70);
727
681
 
@@ -734,7 +688,7 @@ describe('SPARQL screen validation', () => {
734
688
  });
735
689
 
736
690
  context('Saved queries & links', () => {
737
- beforeEach(() => createRepoAndVisit());
691
+ beforeEach(() => SparqlSteps.createRepoAndVisit(repositoryId));
738
692
 
739
693
  const QUERY_FOR_SAVING = 'select (count (*) as ?cnt)\n' +
740
694
  'where {\n' +
@@ -770,8 +724,8 @@ describe('SPARQL screen validation', () => {
770
724
  getSavedQueryForm().should('not.exist');
771
725
 
772
726
  // Verify that the query is saved
773
- openSavedQueriesPopup();
774
- getPopover()
727
+ SparqlSteps.openSavedQueriesPopup();
728
+ SparqlSteps.getPopover()
775
729
  .should('be.visible')
776
730
  .and('contain', savedQueryName);
777
731
 
@@ -795,8 +749,8 @@ describe('SPARQL screen validation', () => {
795
749
 
796
750
  // Verify that the query is edited.
797
751
  // Select the query from the saved queries again
798
- openSavedQueriesPopup();
799
- getPopover()
752
+ SparqlSteps.openSavedQueriesPopup();
753
+ SparqlSteps.getPopover()
800
754
  .should('be.visible')
801
755
  .and('contain', savedQueryName);
802
756
 
@@ -811,8 +765,8 @@ describe('SPARQL screen validation', () => {
811
765
  submitSavedQuery();
812
766
 
813
767
  // Click on the saved queries icon
814
- openSavedQueriesPopup();
815
- getPopover()
768
+ SparqlSteps.openSavedQueriesPopup();
769
+ SparqlSteps.getPopover()
816
770
  .should('be.visible')
817
771
  .and('contain', savedQueryName);
818
772
 
@@ -825,8 +779,8 @@ describe('SPARQL screen validation', () => {
825
779
  cy.get('.popover').should('not.exist');
826
780
 
827
781
  // Verify that the query is deleted
828
- openSavedQueriesPopup();
829
- getPopover()
782
+ SparqlSteps.openSavedQueriesPopup();
783
+ SparqlSteps.getPopover()
830
784
  .should('be.visible')
831
785
  .and('not.contain', savedQueryName);
832
786
  });
@@ -879,42 +833,42 @@ describe('SPARQL screen validation', () => {
879
833
  // Execute all default saved queries
880
834
 
881
835
  // Execute the default sample Add Statements
882
- selectSavedQuery('Add statements');
883
- getTabs().should('have.length', 2);
836
+ SparqlSteps.selectSavedQuery('Add statements');
837
+ SparqlSteps.getTabs().should('have.length', 2);
884
838
  getActiveTabLink().should('have.text', 'Add statements');
885
- getQueryArea().should('contain', 'INSERT DATA');
886
- executeQuery();
839
+ SparqlSteps.getQueryArea().should('contain', 'INSERT DATA');
840
+ SparqlSteps.executeQuery();
887
841
  // Verify query information: “Added 2 statements”
888
842
  getUpdateMessage()
889
843
  .should('contain', 'Added 2 statements.')
890
844
  .and('contain', 'Update took');
891
845
 
892
846
  // Execute the default sample Remove statements
893
- selectSavedQuery('Remove statements');
894
- getTabs().should('have.length', 3);
847
+ SparqlSteps.selectSavedQuery('Remove statements');
848
+ SparqlSteps.getTabs().should('have.length', 3);
895
849
  getActiveTabLink().should('have.text', 'Remove statements');
896
- getQueryArea().should('contain', 'DELETE DATA');
897
- executeQuery();
850
+ SparqlSteps.getQueryArea().should('contain', 'DELETE DATA');
851
+ SparqlSteps.executeQuery();
898
852
  getUpdateMessage()
899
853
  .should('contain', 'Removed 2 statements.')
900
854
  .and('contain', 'Update took');
901
855
 
902
856
  // Execute the default sample Clear Graph
903
- selectSavedQuery('Clear graph');
904
- getTabs().should('have.length', 4);
857
+ SparqlSteps.selectSavedQuery('Clear graph');
858
+ SparqlSteps.getTabs().should('have.length', 4);
905
859
  getActiveTabLink().should('have.text', 'Clear graph');
906
- getQueryArea().should('contain', 'CLEAR GRAPH');
907
- executeQuery();
860
+ SparqlSteps.getQueryArea().should('contain', 'CLEAR GRAPH');
861
+ SparqlSteps.executeQuery();
908
862
  getUpdateMessage()
909
863
  .should('contain', 'The number of statements did not change.')
910
864
  .and('contain', 'Update took');
911
865
 
912
866
  // Execute the default SPARQL Select template
913
- selectSavedQuery('SPARQL Select template');
914
- getTabs().should('have.length', 5);
867
+ SparqlSteps.selectSavedQuery('SPARQL Select template');
868
+ SparqlSteps.getTabs().should('have.length', 5);
915
869
  getActiveTabLink().should('have.text', 'SPARQL Select template');
916
- getQueryArea().should('contain', 'SELECT');
917
- executeQuery();
870
+ SparqlSteps.getQueryArea().should('contain', 'SELECT');
871
+ SparqlSteps.executeQuery();
918
872
  getUpdateMessage().should('not.be.visible');
919
873
  cy.verifyResultsMessage('Showing results from 1 to 74 of 74');
920
874
  cy.verifyResultsMessage('Query took');
@@ -924,8 +878,8 @@ describe('SPARQL screen validation', () => {
924
878
 
925
879
  it('Test saved query link', () => {
926
880
  const queryName = 'Add statements';
927
- openSavedQueriesPopup();
928
- getPopover().should('be.visible');
881
+ SparqlSteps.openSavedQueriesPopup();
882
+ SparqlSteps.getPopover().should('be.visible');
929
883
 
930
884
  executeSavedQueryCommand(queryName, OPEN_SAVED_QUERY_COMMAND);
931
885
 
@@ -938,13 +892,13 @@ describe('SPARQL screen validation', () => {
938
892
 
939
893
  // Visit performs full page load
940
894
  cy.visit(expectedUrl);
941
- waitUntilSparqlPageIsLoaded();
895
+ SparqlSteps.waitUntilSparqlPageIsLoaded();
942
896
 
943
- getTabs().should('have.length', 2);
897
+ SparqlSteps.getTabs().should('have.length', 2);
944
898
  getActiveTabLink().should('have.text', queryName);
945
899
 
946
900
  // Wait until editor is initialized with the query and then assert the whole query
947
- getQueryArea().should('contain', 'INSERT DATA');
901
+ SparqlSteps.getQueryArea().should('contain', 'INSERT DATA');
948
902
  cy.fixture('queries/add-statement.txt').then((query) => {
949
903
  // Convert new line symbols to \n regardless of OS. Query in SPARQL editor uses \n for new line.
950
904
  const EOLregex = /(\r\n|\r|\n)/g;
@@ -974,11 +928,11 @@ describe('SPARQL screen validation', () => {
974
928
 
975
929
  // Visit performs full page load
976
930
  cy.visit(expectedUrl);
977
- waitUntilSparqlPageIsLoaded();
978
- getTabs().should('have.length', 1);
931
+ SparqlSteps.waitUntilSparqlPageIsLoaded();
932
+ SparqlSteps.getTabs().should('have.length', 1);
979
933
 
980
934
  // Wait until editor is initialized with the query and then assert the whole query
981
- getQueryArea().should('contain', 'SELECT');
935
+ SparqlSteps.getQueryArea().should('contain', 'SELECT');
982
936
  verifyQueryAreaEquals(query);
983
937
  });
984
938
  });
@@ -989,12 +943,12 @@ describe('SPARQL screen validation', () => {
989
943
  const wineUri = '<http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#CorbansDryWhiteRiesling>';
990
944
 
991
945
  it('should suggest resources in the "SPARQL" editor when autocomplete is enabled', () => {
992
- createRepository();
946
+ SparqlSteps.createRepository(repositoryId);
993
947
 
994
948
  cy.importServerFile(repositoryId, FILE_TO_IMPORT);
995
949
 
996
950
  cy.enableAutocomplete(repositoryId);
997
- visitSparql(true);
951
+ SparqlSteps.visitSparql(true, repositoryId);
998
952
 
999
953
  const expectedQuery = queryBegin + wineUri + queryEnd;
1000
954
 
@@ -1015,7 +969,7 @@ describe('SPARQL screen validation', () => {
1015
969
 
1016
970
  verifyQueryAreaEquals(expectedQuery);
1017
971
 
1018
- executeQuery();
972
+ SparqlSteps.executeQuery();
1019
973
 
1020
974
  getResultsWrapper().should('be.visible');
1021
975
 
@@ -1023,7 +977,7 @@ describe('SPARQL screen validation', () => {
1023
977
  });
1024
978
 
1025
979
  it('should not suggests resources in the "SPARQL" editor if the autocomplete is NOT enabled', () => {
1026
- createRepoAndVisit();
980
+ SparqlSteps.createRepoAndVisit(repositoryId);
1027
981
 
1028
982
  clearQuery();
1029
983
 
@@ -1044,26 +998,6 @@ describe('SPARQL screen validation', () => {
1044
998
  const YASR_SELECTOR = '#yasr';
1045
999
  const YASR_INNER_SELECTOR = '#yasr-inner';
1046
1000
 
1047
- function executeQuery() {
1048
- getRunQueryButton().click();
1049
- getLoader().should('not.exist');
1050
- }
1051
-
1052
- function getLoader() {
1053
- return cy.get('.ot-loader-new-content');
1054
- }
1055
-
1056
- function getPopover() {
1057
- return cy.get('.popover')
1058
- .should('not.have.class', 'ng-animate')
1059
- .and('not.have.class', 'in-add')
1060
- .and('not.have.class', 'in-add-active');
1061
- }
1062
-
1063
- function getRunQueryButton() {
1064
- return cy.get('#wb-sparql-runQuery');
1065
- }
1066
-
1067
1001
  function getTableResultRows() {
1068
1002
  return getResultsWrapper().find('.resultsTable tbody tr');
1069
1003
  }
@@ -1096,10 +1030,6 @@ describe('SPARQL screen validation', () => {
1096
1030
  .click();
1097
1031
  }
1098
1032
 
1099
- function getTabs() {
1100
- return cy.get(TABS_SELECTOR);
1101
- }
1102
-
1103
1033
  function getActiveTabLink() {
1104
1034
  return cy.get(TABS_SELECTOR + '.active .nav-link');
1105
1035
  }
@@ -1113,13 +1043,13 @@ describe('SPARQL screen validation', () => {
1113
1043
  }
1114
1044
 
1115
1045
  function getLastTab() {
1116
- return getTabs().last();
1046
+ return SparqlSteps.getTabs().last();
1117
1047
  }
1118
1048
 
1119
1049
  function renameTab(position, newName) {
1120
- getTabs().eq(position - 1).then(tab => {
1050
+ SparqlSteps.getTabs().eq(position - 1).then(tab => {
1121
1051
  cy.wrap(tab)
1122
- // First click is to focus it in case it's not the active tab
1052
+ // First click is to focus it in case it's not the active tab
1123
1053
  .click()
1124
1054
  .find('.nav-link')
1125
1055
  .dblclick();
@@ -1135,14 +1065,14 @@ describe('SPARQL screen validation', () => {
1135
1065
  }
1136
1066
 
1137
1067
  function verifyTabName(position, name) {
1138
- getTabs().eq(position - 1)
1068
+ SparqlSteps.getTabs().eq(position - 1)
1139
1069
  .should('be.visible')
1140
1070
  .find('.nav-link')
1141
1071
  .should('have.text', name);
1142
1072
  }
1143
1073
 
1144
1074
  function getTabCloseBtn(position) {
1145
- return getTabs().eq(position - 1).find('.delete-sparql-tab-btn');
1075
+ return SparqlSteps.getTabs().eq(position - 1).find('.delete-sparql-tab-btn');
1146
1076
  }
1147
1077
 
1148
1078
  function closeTab(position) {
@@ -1152,24 +1082,20 @@ describe('SPARQL screen validation', () => {
1152
1082
  function verifyQueryAreaContains(query) {
1153
1083
  // Using the CodeMirror instance because getting the value from the DOM is very cumbersome
1154
1084
  cy.waitUntil(() =>
1155
- getQueryArea()
1085
+ SparqlSteps.getQueryArea()
1156
1086
  .then(codeMirrorEl => codeMirrorEl && codeMirrorEl[0].CodeMirror.getValue().includes(query)));
1157
1087
  }
1158
1088
 
1159
1089
  function verifyQueryAreaEquals(query) {
1160
1090
  // Using the CodeMirror instance because getting the value from the DOM is very cumbersome
1161
- getQueryArea().should(codeMirrorEl => {
1091
+ SparqlSteps.getQueryArea().should(codeMirrorEl => {
1162
1092
  const cm = codeMirrorEl[0].CodeMirror;
1163
1093
  expect(cm.getValue().trim()).to.equal(query.trim());
1164
1094
  });
1165
1095
  }
1166
1096
 
1167
- function getQueryArea() {
1168
- return cy.get('#queryEditor .CodeMirror');
1169
- }
1170
-
1171
1097
  function getQueryTextArea() {
1172
- return getQueryArea().find('textarea');
1098
+ return SparqlSteps.getQueryArea().find('textarea');
1173
1099
  }
1174
1100
 
1175
1101
  function getNoQueryRun() {
@@ -1191,7 +1117,7 @@ describe('SPARQL screen validation', () => {
1191
1117
 
1192
1118
  function goToPage(page) {
1193
1119
  getResultPages().contains(page).click();
1194
- getLoader().should('not.exist');
1120
+ SparqlSteps.getLoader().should('not.exist');
1195
1121
  }
1196
1122
 
1197
1123
  function getResultFilterField() {
@@ -1290,33 +1216,10 @@ describe('SPARQL screen validation', () => {
1290
1216
  return cy.get('#wb-sparql-sampleValue');
1291
1217
  }
1292
1218
 
1293
- function getSavedQueriesPopupBtn() {
1294
- return cy.get('#wb-sparql-toggleSampleQueries');
1295
- }
1296
-
1297
- function openSavedQueriesPopup() {
1298
- getSavedQueriesPopupBtn().click();
1299
- }
1300
-
1301
- function getSavedQueryFromPopup(savedQueryName) {
1302
- return cy.get('#wb-sparql-queryInSampleQueries')
1303
- .contains(savedQueryName)
1304
- .closest('.saved-query');
1305
- }
1306
-
1307
- function selectSavedQuery(savedQueryName) {
1308
- openSavedQueriesPopup();
1309
- getPopover().should('be.visible');
1310
- getSavedQueryFromPopup(savedQueryName)
1311
- .find('a')
1312
- // the popup is opened and the link with the text is visible but cypress think it's 0x0px width/height
1313
- .click({force: true});
1314
- }
1315
-
1316
1219
  function executeSavedQueryCommand(savedQueryName, commandSelector) {
1317
- getSavedQueryFromPopup(savedQueryName)
1318
- // Current implementation of the saved queries popup always render the action bar next to
1319
- // each query item but it's just hidden with opacity: 0. So IMO it's safe to force it here.
1220
+ SparqlSteps.getSavedQueryFromPopup(savedQueryName)
1221
+ // Current implementation of the saved queries popup always render the action bar next to
1222
+ // each query item but it's just hidden with opacity: 0. So IMO it's safe to force it here.
1320
1223
  .trigger('mouseover', {force: true})
1321
1224
  .find('.actions-bar')
1322
1225
  .find(commandSelector)