graphdb-workbench-tests 4.0.0-SPARQL12-TEST-FIX → 4.0.0-TR10

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.
@@ -0,0 +1,145 @@
1
+ import {SparqlEditorSteps} from "../../steps/sparql-editor-steps";
2
+ import {YasguiSteps} from "../../steps/yasgui/yasgui-steps";
3
+ import {YasqeSteps} from "../../steps/yasgui/yasqe-steps";
4
+ import {YasrSteps} from "../../steps/yasgui/yasr-steps";
5
+ import {QueryStubs} from "../../stubs/yasgui/query-stubs";
6
+ import {GraphsOverviewSteps} from "../../steps/explore/graphs-overview-steps";
7
+ import {JsonLdModalSteps} from "../../steps/json-ld-modal-steps";
8
+
9
+ // The workbench requests RDF 1.2 by adding the "version" media type parameter to the Accept header.
10
+ // The parameter must be present on every RDF media range and must precede the weight ("q"),
11
+ // because anything after the weight is not a media type parameter.
12
+ const SELECT_QUERY_ACCEPT = 'application/x-sparqlstar-results+json;version=1.2, application/sparql-results+json;version=1.2;q=0.9, */*;version=1.2;q=0.8';
13
+ const CONSTRUCT_QUERY_ACCEPT = 'application/x-graphdb-table-results+json;version=1.2, application/rdf+json;version=1.2;q=0.9, */*;version=1.2;q=0.8';
14
+ const JSONLD_EXPANDED_ACCEPT = 'application/ld+json;profile=http://www.w3.org/ns/json-ld#expanded;version=1.2';
15
+
16
+ describe('RDF version in the Accept header', () => {
17
+ let repositoryId;
18
+
19
+ afterEach(() => {
20
+ cy.deleteRepository(repositoryId);
21
+ });
22
+
23
+ describe('SPARQL editor', () => {
24
+ beforeEach(() => {
25
+ repositoryId = 'rdf-version-sparql-' + Date.now();
26
+ QueryStubs.stubQueryCountResponse();
27
+ cy.createRepository({id: repositoryId});
28
+ cy.presetRepository(repositoryId);
29
+ QueryStubs.stubDefaultQueryResponse(repositoryId);
30
+
31
+ SparqlEditorSteps.visitSparqlEditorPage();
32
+ YasguiSteps.getYasgui().should('be.visible');
33
+ });
34
+
35
+ it('should request RDF 1.2 when executing a SELECT query', () => {
36
+ // Given I am about to execute the default SELECT query
37
+ cy.intercept('POST', `/repositories/${repositoryId}`).as('query');
38
+
39
+ // When I execute it
40
+ YasqeSteps.executeQuery();
41
+
42
+ // Then every media range of the Accept header should request RDF 1.2
43
+ verifyAcceptHeader('@query', SELECT_QUERY_ACCEPT);
44
+ });
45
+
46
+ it('should request RDF 1.2 when executing a CONSTRUCT query', () => {
47
+ // Given I am about to execute a CONSTRUCT query
48
+ cy.intercept('POST', `/repositories/${repositoryId}`).as('query');
49
+
50
+ // When I execute it
51
+ pasteAndExecuteConstructQuery();
52
+
53
+ // Then every media range of the Accept header should request RDF 1.2
54
+ verifyAcceptHeader('@query', CONSTRUCT_QUERY_ACCEPT);
55
+ });
56
+
57
+ it('should request RDF 1.2 when downloading SELECT results', () => {
58
+ // Given I have executed a SELECT query
59
+ YasqeSteps.executeQuery();
60
+ cy.intercept('POST', `/repositories/${repositoryId}`).as('download');
61
+
62
+ // When I download the results as XML
63
+ YasrSteps.openDownloadAsDropdown();
64
+ YasrSteps.selectDownloadAsOption(1);
65
+
66
+ // Then the download request should ask for RDF 1.2
67
+ verifyAcceptHeader('@download', 'application/sparql-results+xml;version=1.2');
68
+ });
69
+
70
+ it('should request RDF 1.2 when downloading CONSTRUCT results as JSON-LD', () => {
71
+ // Given I have executed a CONSTRUCT query
72
+ pasteAndExecuteConstructQuery();
73
+ cy.intercept('POST', `/repositories/${repositoryId}`).as('download');
74
+
75
+ // When I download the results as JSON-LD with the default settings
76
+ YasrSteps.openDownloadAsDropdown();
77
+ YasrSteps.selectDownloadAsOption(1);
78
+ JsonLdModalSteps.clickExportJSONLD();
79
+
80
+ // Then the version should follow the JSON-LD profile
81
+ verifyAcceptHeader('@download', JSONLD_EXPANDED_ACCEPT);
82
+ });
83
+ });
84
+
85
+ describe('Graphs overview', () => {
86
+ beforeEach(() => {
87
+ repositoryId = 'rdf-version-graphs-' + Date.now();
88
+ cy.createRepository({id: repositoryId});
89
+ cy.presetRepository(repositoryId);
90
+ cy.importRDFTextSnippet(repositoryId, '<urn:s> <urn:p> <urn:o> .');
91
+
92
+ GraphsOverviewSteps.visit();
93
+ GraphsOverviewSteps.getResults().should('have.length.at.least', 1);
94
+ });
95
+
96
+ it('should request RDF 1.2 when exporting the repository', () => {
97
+ // Given the export opens the download URL in a new window
98
+ cy.window().then((win) => {
99
+ cy.stub(win, 'open').returns({closed: true}).as('windowOpen');
100
+ });
101
+
102
+ // When I export the repository as TriG
103
+ GraphsOverviewSteps.exportRepository();
104
+ cy.get('.export-repo-format-TriG').eq(0).click();
105
+
106
+ // Then the Accept parameter of the download URL should request RDF 1.2
107
+ cy.get('@windowOpen').should('have.been.calledOnce')
108
+ .its('firstCall.args.0')
109
+ .should('contain', '&Accept=' + encodeURIComponent('application/x-trig;version=1.2'));
110
+ });
111
+
112
+ it('should request RDF 1.2 when exporting the repository as JSON-LD', () => {
113
+ // Given I am about to export the repository
114
+ cy.intercept({method: 'GET', pathname: `/repositories/${repositoryId}/statements`}).as('export');
115
+
116
+ // When I export it as JSON-LD with the default settings
117
+ GraphsOverviewSteps.exportRepository();
118
+ GraphsOverviewSteps.selectJSONLDOption();
119
+ JsonLdModalSteps.clickExportJSONLD();
120
+
121
+ // Then the version should follow the JSON-LD profile
122
+ verifyAcceptHeader('@export', JSONLD_EXPANDED_ACCEPT);
123
+ });
124
+
125
+ it('should request RDF 1.2 when downloading all graphs', () => {
126
+ // Given I am about to download all graphs
127
+ cy.intercept({method: 'GET', pathname: `/repositories/${repositoryId}/contexts`}).as('downloadGraphs');
128
+
129
+ // When I download them
130
+ GraphsOverviewSteps.clickOnDownloadAllButton();
131
+
132
+ // Then RDF 1.2 should be requested for every media range except JSON
133
+ verifyAcceptHeader('@downloadGraphs', 'application/json, text/plain;version=1.2, */*;version=1.2');
134
+ });
135
+ });
136
+ });
137
+
138
+ function verifyAcceptHeader(alias, expectedAccept) {
139
+ cy.wait(alias).its('request.headers.accept').should('equal', expectedAccept);
140
+ }
141
+
142
+ function pasteAndExecuteConstructQuery() {
143
+ YasqeSteps.pasteQuery('CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }');
144
+ YasqeSteps.executeQuery();
145
+ }
@@ -9,6 +9,7 @@ import {YasguiSteps} from "../../steps/yasgui/yasgui-steps";
9
9
  import {JsonLdModalSteps} from "../../steps/json-ld-modal-steps";
10
10
  import {GraphConfigStubs} from '../../stubs/graph-config-stubs.js';
11
11
  import {VisualGraphSplitButtonSteps} from '../../steps/visual-graph-split-button-steps.js';
12
+ import {GraphNavigatorSteps} from '../../steps/graph-navigator-steps.js';
12
13
 
13
14
  const FILE_TO_IMPORT = 'resource-test-data.ttl';
14
15
  const SUBJECT_RESOURCE_ENCODED = 'http:%2F%2Fexample.com%2Fontology%23CustomerLoyalty';
@@ -19,12 +20,12 @@ const OBJECT_RESOURCE = 'http:%2F%2Fexample.com%2Fontology%23Metric';
19
20
  const IMPLICIT_EXPLICIT_RESOURCE = 'http:%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23type';
20
21
  // A triple term in the SPARQL 1.2 syntax. The resource view expects it wrapped in <<( )>>.
21
22
  const TRIPLE_RESOURCE_DECODED = '<<(<http://example.com/resource/person/W6J1827> <http://example.com/ontology#hasAddress> <http://example.com/resource/person/W6J1827/address>)>>';
22
- const TRIPLE_RESOURCE = encodeURIComponent(TRIPLE_RESOURCE_DECODED);
23
+ const TRIPLE_RESOURCE_ENCODED = encodeURIComponent(TRIPLE_RESOURCE_DECODED);
23
24
  const TRIPLE_RESOURCE_LOCAL_NAMES = '<<(<W6J1827> <hasAddress> <address>)>>';
24
25
  // A triple term whose object is a literal. It is deliberately not part of the test data, because it is
25
26
  // used only to verify that shortening the IRIs of a triple term leaves its literals untouched.
26
27
  const LITERAL_TRIPLE_RESOURCE_DECODED = '<<(<http://example.com/resource/person/W6J1827> <http://example.com/ontology#firstName> "Burgunda")>>';
27
- const LITERAL_TRIPLE_RESOURCE = encodeURIComponent(LITERAL_TRIPLE_RESOURCE_DECODED);
28
+ const LITERAL_TRIPLE_RESOURCE_ENCODED = encodeURIComponent(LITERAL_TRIPLE_RESOURCE_DECODED);
28
29
  const LITERAL_TRIPLE_RESOURCE_LOCAL_NAMES = '<<(<W6J1827> <firstName> "Burgunda")>>';
29
30
  // The number of statements the resource view lists for the triple term - the four statements which
30
31
  // annotate it in the test data plus the "rdf:reifies" statement which binds its reifier to it.
@@ -104,6 +105,18 @@ describe('Resource view', () => {
104
105
  VisualGraphSteps.verifyUrl();
105
106
  });
106
107
 
108
+ it('should open the Graph Navigator view when click on the "Visualize Graph Navigator" button', () => {
109
+ // When I am on resource view and page loaded a resource.
110
+ ResourceSteps.visit(`uri=${SUBJECT_RESOURCE_ENCODED}`);
111
+
112
+ // When I click on "Visualize Graph Navigator" button.
113
+ ResourceSteps.clickOnVisualizeGraphNavigatorButton();
114
+
115
+ // Then I expect to be redirected to the Graph Navigator view with the resource as the start uri.
116
+ GraphNavigatorSteps.verifyUrl();
117
+ GraphNavigatorSteps.verifyStartResourceUri(SUBJECT_RESOURCE);
118
+ });
119
+
107
120
  it('should open graphs-visualizations view when select a graph configuration', () => {
108
121
  // When I am on resource view and page loaded a resource.
109
122
  ResourceSteps.visit(`uri=${SUBJECT_RESOURCE_ENCODED}&role=subject`);
@@ -149,7 +162,7 @@ describe('Resource view', () => {
149
162
  YasrSteps.getResults().should('have.length', EXPLICIT_TYPE_STATEMENTS_COUNT);
150
163
  });
151
164
 
152
- context('Same as', () => {
165
+ describe('Same as', () => {
153
166
 
154
167
  it('should display sameAs button when is enabled by user settings', () => {
155
168
  // When I am on resource view and page loaded a resource that has triplets in explicit and implicit context,
@@ -219,7 +232,7 @@ describe('Resource view', () => {
219
232
  });
220
233
  });
221
234
 
222
- context('Role tabs', () => {
235
+ describe('Role tabs', () => {
223
236
 
224
237
  it('should list the triples of a resource used as subject', () => {
225
238
  // When I am on resource view,
@@ -411,10 +424,10 @@ describe('Resource view', () => {
411
424
  });
412
425
  });
413
426
 
414
- context('Triple resource', () => {
427
+ describe('Triple resource', () => {
415
428
  it('should show triple resource shortened in the header and in full as a target', () => {
416
429
  // When I visit resource view with triple resource.
417
- ResourceSteps.visit(`triple=${TRIPLE_RESOURCE}&role=subject`);
430
+ ResourceSteps.visit(`triple=${TRIPLE_RESOURCE_ENCODED}&role=subject`);
418
431
 
419
432
  // Then I expect the header link to show the triple term with shortened IRIs,
420
433
  ResourceSteps.verifyTrimmedText(ResourceSteps.getTripleResourceLink(), TRIPLE_RESOURCE_LOCAL_NAMES);
@@ -434,7 +447,7 @@ describe('Resource view', () => {
434
447
 
435
448
  it('should shorten only the IRIs of a triple term and leave its literals unchanged', () => {
436
449
  // When I visit resource view with a triple term whose object is a literal.
437
- ResourceSteps.visit(`triple=${LITERAL_TRIPLE_RESOURCE}&role=subject`);
450
+ ResourceSteps.visit(`triple=${LITERAL_TRIPLE_RESOURCE_ENCODED}&role=subject`);
438
451
 
439
452
  // Then I expect the header link to show the IRIs shortened and the literal as it is,
440
453
  ResourceSteps.verifyTrimmedText(ResourceSteps.getTripleResourceLink(), LITERAL_TRIPLE_RESOURCE_LOCAL_NAMES);
@@ -444,7 +457,7 @@ describe('Resource view', () => {
444
457
 
445
458
  it('should point both the header and the target link to the triple term lookup query', () => {
446
459
  // When I visit resource view with triple resource.
447
- ResourceSteps.visit(`triple=${TRIPLE_RESOURCE}&role=subject`);
460
+ ResourceSteps.visit(`triple=${TRIPLE_RESOURCE_ENCODED}&role=subject`);
448
461
 
449
462
  // Then I expect both links to point to the sparql editor with the triple term lookup query.
450
463
  ResourceSteps.getTripleResourceLink().should('have.attr', 'href', TRIPLE_TERM_LOOKUP_HREF);
@@ -453,7 +466,7 @@ describe('Resource view', () => {
453
466
 
454
467
  it('should activate the "triple term" role tab and disable all other role tabs', () => {
455
468
  // When I visit resource view with triple resource.
456
- ResourceSteps.visit(`triple=${TRIPLE_RESOURCE}&role=subject`);
469
+ ResourceSteps.visit(`triple=${TRIPLE_RESOURCE_ENCODED}&role=subject`);
457
470
 
458
471
  // Then I expect the "triple term" tab to be the active one, regardless of the role url parameter,
459
472
  ResourceSteps.verifyActiveRoleTab(TRIPLE_TERM_ROLE_LABEL);
@@ -474,7 +487,7 @@ describe('Resource view', () => {
474
487
 
475
488
  it('should activate the "triple term" role tab when the role url parameter is missing', () => {
476
489
  // When I visit resource view with a triple resource and without a role parameter.
477
- ResourceSteps.visit(`triple=${TRIPLE_RESOURCE}`);
490
+ ResourceSteps.visit(`triple=${TRIPLE_RESOURCE_ENCODED}`);
478
491
 
479
492
  // Then I expect the "triple term" tab to be the active one,
480
493
  ResourceSteps.verifyActiveRoleTab(TRIPLE_TERM_ROLE_LABEL);
@@ -490,7 +503,7 @@ describe('Resource view', () => {
490
503
  ].forEach(({label, click}) => {
491
504
  it(`should open the sparql editor with a triple term lookup query when the ${label} link is clicked`, () => {
492
505
  // When I visit resource view with triple resource.
493
- ResourceSteps.visit(`triple=${TRIPLE_RESOURCE}&role=subject`);
506
+ ResourceSteps.visit(`triple=${TRIPLE_RESOURCE_ENCODED}&role=subject`);
494
507
 
495
508
  // When I click on the link.
496
509
  click();
@@ -505,7 +518,7 @@ describe('Resource view', () => {
505
518
  });
506
519
  });
507
520
 
508
- context('Download as', () => {
521
+ describe('Download as', () => {
509
522
  it('should download as JSON-LD and then restore defaults', () => {
510
523
  // Given I am in the Resource view
511
524
  ResourceSteps.visit(`uri=${SUBJECT_RESOURCE_ENCODED}&role=subject`);
@@ -3,6 +3,7 @@ import {YasqeSteps} from '../../../steps/yasgui/yasqe-steps';
3
3
  import {SecurityStubs} from '../../../stubs/security-stubs';
4
4
  import {VisualGraphSteps} from '../../../steps/visual-graph-steps';
5
5
  import {ToasterSteps} from '../../../steps/toaster-steps';
6
+ import {SettingsSteps} from '../../../steps/setup/settings-steps';
6
7
 
7
8
  describe('My Settings', () => {
8
9
 
@@ -32,16 +33,12 @@ describe('My Settings', () => {
32
33
  //turn off inference, sameAs and count total results
33
34
  clickLabelBtn('#sameas-on')
34
35
  .then(() => {
35
- cy.get('#sameas-on')
36
- .find('.switch:checkbox')
37
- .should('not.be.visible');
36
+ SettingsSteps.getSameAsToggle().should('not.be.checked');
38
37
  });
39
38
 
40
39
  clickLabelBtn('#inference-on')
41
40
  .then(() => {
42
- cy.get('#inference-on')
43
- .find('.switch:checkbox')
44
- .should('not.be.visible');
41
+ SettingsSteps.getInferenceToggle().should('not.be.checked');
45
42
  });
46
43
 
47
44
  cy.get('#defaultCount:checkbox').uncheck();
@@ -95,9 +92,7 @@ describe('My Settings', () => {
95
92
  visitSettingsView();
96
93
 
97
94
  clickLabelBtn('#schema-on').then(() => {
98
- cy.get('#schema-on')
99
- .find('.switch:checkbox')
100
- .should('not.be.visible');
95
+ SettingsSteps.getSchemaToggle().should('not.be.checked');
101
96
  });
102
97
 
103
98
  getSaveButton()
@@ -152,14 +147,29 @@ describe('My Settings', () => {
152
147
  it('sameAs button should be disabled if inference is turned off', () => {
153
148
  clickLabelBtn('#inference-on')
154
149
  .then(() => {
155
- cy.get('#inference-on')
156
- .find('.switch:checkbox')
157
- .should('not.be.visible');
150
+ SettingsSteps.getInferenceToggle().should('not.be.checked');
158
151
  });
159
152
 
160
- cy.get('#sameas-on')
161
- .find('.switch:checkbox')
162
- .should('not.be.visible');
153
+ SettingsSteps.getSameAsToggle()
154
+ .should('be.disabled')
155
+ .and('not.be.checked');
156
+ });
157
+
158
+ it('should give the settings form controls accessible names', () => {
159
+ SettingsSteps.getUsernameLabel().should('contain', 'Username');
160
+
161
+ SettingsSteps.getSameAsToggleLabel().should('contain', 'Expand results over owl:SameAs');
162
+ SettingsSteps.getInferenceToggleLabel().should('contain', 'Enable inference');
163
+ SettingsSteps.getSchemaToggleLabel().should('contain', 'Show schema');
164
+
165
+ SettingsSteps.getAnyRepositoryReadCheckbox()
166
+ .should('have.attr', 'aria-label', 'Read access to Global (any data repository)');
167
+ SettingsSteps.getAnyRepositoryWriteCheckbox()
168
+ .should('have.attr', 'aria-label', 'Write access to Global (any data repository)');
169
+ SettingsSteps.getAnyRepositoryMaintainCheckbox()
170
+ .should('have.attr', 'aria-label', 'Maintain access to Global (any data repository)');
171
+ SettingsSteps.getAnyRepositoryGraphqlCheckbox()
172
+ .should('have.attr', 'aria-label', 'Restrict Global (any data repository) to GraphQL');
163
173
  });
164
174
 
165
175
  function getSaveButton() {
@@ -19,7 +19,6 @@ describe('User and Access', () => {
19
19
  repositoryId2 = 'user-access-repo2-' + Date.now();
20
20
  cy.createRepository({id: repositoryId1});
21
21
  cy.createRepository({id: repositoryId2});
22
- cy.presetRepository(repositoryId1);
23
22
  UserAndAccessSteps.visit();
24
23
  // Users table should be visible
25
24
  UserAndAccessSteps.getUsersTable().should('be.visible');