graphdb-workbench-tests 4.0.0-TR23 → 4.0.0-TR24

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.
@@ -21,6 +21,20 @@ const CONSTRUCT_TARGET_LABEL = 'Metric';
21
21
  // The graph-navigator settings endpoint requires this repository.
22
22
  const SYSTEM_REPOSITORY_ID = 'SystemRepository';
23
23
 
24
+ /**
25
+ * Switches the repository on the SPARQL view and returns to the Graph Navigator view via the navigation bar.
26
+ *
27
+ * @param {string} repositoryId The repository to switch to.
28
+ */
29
+ function switchRepositoryOnAnotherViewAndReturn(repositoryId) {
30
+ MainMenuSteps.clickOnSparqlMenu();
31
+ GraphNavigatorSteps.getComponent().should('not.exist');
32
+ YasqeSteps.getEditor().should('be.visible');
33
+ RepositorySelectorSteps.selectRepository(repositoryId);
34
+ RepositorySelectorSteps.getSelectedRepository().should('contain', repositoryId);
35
+ MainMenuSteps.clickOnGraphNavigator();
36
+ }
37
+
24
38
  describe('Graph Navigator', () => {
25
39
  let repositoryId;
26
40
 
@@ -124,7 +138,7 @@ describe('Graph Navigator', () => {
124
138
  GraphNavigatorSteps.getElement(SEED_RESOURCE_LABEL).should('exist');
125
139
  });
126
140
 
127
- it('should keep the diagram on refresh but clear it when navigating away and back', () => {
141
+ it('should keep the diagram on refresh and when navigating away and back', () => {
128
142
  // Given the Graph Navigator view is opened with a start resource that gets seeded on the canvas.
129
143
  GraphNavigatorSteps.visit(SEED_RESOURCE_ENCODED);
130
144
  GraphNavigatorSteps.getElements().should('have.length', 1);
@@ -150,9 +164,18 @@ describe('Graph Navigator', () => {
150
164
  // And I return to the Graph Navigator view via the navigation bar.
151
165
  MainMenuSteps.clickOnGraphNavigator();
152
166
 
153
- // Then I expect the canvas to be cleared, because leaving the view drops the persisted diagram state.
167
+ // Then I expect the diagram to be restored, because it is persisted for the repository it was drawn in.
154
168
  GraphNavigatorSteps.getWorkspace().should('exist');
155
- GraphNavigatorSteps.getElements().should('not.exist');
169
+ GraphNavigatorSteps.getElements().should('have.length', 1);
170
+ GraphNavigatorSteps.getElement(SEED_RESOURCE_LABEL).should('exist');
171
+
172
+ // When I refresh the page, which now has no start resource to seed the canvas with.
173
+ cy.reload();
174
+
175
+ // Then I expect the diagram to be restored from the persisted state.
176
+ GraphNavigatorSteps.getWorkspace().should('exist');
177
+ GraphNavigatorSteps.getElements().should('have.length', 1);
178
+ GraphNavigatorSteps.getElement(SEED_RESOURCE_LABEL).should('exist');
156
179
  });
157
180
 
158
181
  describe('Settings', () => {
@@ -380,9 +403,10 @@ describe('Graph Navigator', () => {
380
403
  // When I switch to another repository.
381
404
  RepositorySelectorSteps.selectRepository(secondRepositoryId);
382
405
 
383
- // Then I expect a confirmation that warns the diagram will be cleared.
406
+ // Then I expect a confirmation that warns the diagram will be cleared, and that it can be exported first.
384
407
  GraphNavigatorSteps.getConfirmDialog().should('be.visible')
385
- .and('contain', 'The diagram will be cleared.');
408
+ .and('contain', 'The diagram will be cleared.')
409
+ .and('contain', 'Export to JSON');
386
410
 
387
411
  // When I cancel.
388
412
  GraphNavigatorSteps.cancelDialog();
@@ -411,6 +435,55 @@ describe('Graph Navigator', () => {
411
435
  GraphNavigatorSteps.verifyOnlyRepositoryParam(secondRepositoryId);
412
436
  });
413
437
 
438
+ it('should ask what to do with the diagram when the repository is switched on another view', () => {
439
+ // Given the Graph Navigator view is opened with a start resource that gets seeded on the canvas.
440
+ GraphNavigatorSteps.visit(SEED_RESOURCE_ENCODED);
441
+ GraphNavigatorSteps.getElements().should('have.length', 1);
442
+
443
+ // When I switch to another repository on another view and return to the Graph Navigator view.
444
+ switchRepositoryOnAnotherViewAndReturn(secondRepositoryId);
445
+
446
+ // Then I expect to be asked about the diagram, which was drawn in the first repository.
447
+ GraphNavigatorSteps.getConfirmDialog().should('be.visible')
448
+ .and('contain', 'Diagram of another repository')
449
+ .and('contain', repositoryId);
450
+ // And I expect the diagram not to be shown until I answer.
451
+ GraphNavigatorSteps.getComponent().should('not.exist');
452
+
453
+ // When I close the dialog with Escape.
454
+ GraphNavigatorSteps.typeEscapeKey();
455
+
456
+ // Then I expect the diagram to be kept and shown with the data of the selected repository.
457
+ GraphNavigatorSteps.getWorkspace().should('exist');
458
+ GraphNavigatorSteps.getElements().should('have.length', 1);
459
+
460
+ // When I switch back to the first repository on another view and return.
461
+ switchRepositoryOnAnotherViewAndReturn(repositoryId);
462
+
463
+ // Then I expect to be asked again, because the kept diagram now belongs to the second repository.
464
+ GraphNavigatorSteps.getConfirmDialog().should('be.visible').and('contain', secondRepositoryId);
465
+
466
+ // When I keep the diagram.
467
+ GraphNavigatorSteps.keepDiagramOfAnotherRepository();
468
+
469
+ // Then I expect it to be shown with the data of the selected repository.
470
+ GraphNavigatorSteps.getWorkspace().should('exist');
471
+ GraphNavigatorSteps.getElements().should('have.length', 1);
472
+
473
+ // When I switch to the second repository on another view and return.
474
+ switchRepositoryOnAnotherViewAndReturn(secondRepositoryId);
475
+
476
+ // Then I expect to be asked again, because the kept diagram now belongs to the first repository.
477
+ GraphNavigatorSteps.getConfirmDialog().should('be.visible').and('contain', repositoryId);
478
+
479
+ // When I discard the diagram.
480
+ GraphNavigatorSteps.discardDiagramOfAnotherRepository();
481
+
482
+ // Then I expect the canvas to be empty.
483
+ GraphNavigatorSteps.getWorkspace().should('exist');
484
+ GraphNavigatorSteps.getElements().should('not.exist');
485
+ });
486
+
414
487
  it('should warn that autocomplete is off once per repository selection', () => {
415
488
  // Given the settings use autocomplete, but autocomplete is off.
416
489
  GraphNavigatorStubs.stubSettingsWithAutocomplete();
@@ -0,0 +1,50 @@
1
+ import {RestApiDocumentationSteps} from "../../../steps/rest-api-documentation-steps";
2
+
3
+ describe('REST API Documentation theme', () => {
4
+ const THEME_PERSISTENCE_KEY = 'ls.workbench-settings';
5
+
6
+ // Queued with cy.then, so the change happens in command order and not when the test body runs.
7
+ const emulateMediaFeatures = (features) => cy.then(() => Cypress.automation('remote:debugger:protocol', {
8
+ command: 'Emulation.setEmulatedMedia',
9
+ params: {features}
10
+ }));
11
+ const emulateOsColorScheme = (colorScheme) => emulateMediaFeatures([{name: 'prefers-color-scheme', value: colorScheme}]);
12
+
13
+ afterEach(() => {
14
+ emulateMediaFeatures([]);
15
+ });
16
+
17
+ it('should use the Swagger UI light theme when the workbench is in light mode', () => {
18
+ // Given, the light theme is persisted in local storage
19
+ cy.setLocalStorage(THEME_PERSISTENCE_KEY, JSON.stringify({"theme": "default-theme", "mode": "light"}));
20
+ // When, I visit the REST API Documentation page
21
+ RestApiDocumentationSteps.visit();
22
+ // Then, Swagger UI uses its light theme
23
+ RestApiDocumentationSteps.verifySwaggerLightTheme();
24
+ });
25
+
26
+ it('should use the Swagger UI dark theme when the workbench is in dark mode', () => {
27
+ // Given, the dark theme is persisted in local storage
28
+ cy.setLocalStorage(THEME_PERSISTENCE_KEY, JSON.stringify({"theme": "default-theme", "mode": "dark"}));
29
+ // When, I visit the REST API Documentation page
30
+ RestApiDocumentationSteps.visit();
31
+ // Then, Swagger UI uses its dark theme
32
+ RestApiDocumentationSteps.verifySwaggerDarkTheme();
33
+ });
34
+
35
+ it('should switch the Swagger UI theme when the OS color scheme changes and the workbench follows the OS', () => {
36
+ // Given, no theme is persisted, so the workbench follows the OS, and the OS is in light mode
37
+ emulateOsColorScheme('light');
38
+ // And, I have opened the REST API Documentation page
39
+ RestApiDocumentationSteps.visit();
40
+ RestApiDocumentationSteps.verifySwaggerLightTheme();
41
+ // When, the OS switches to dark mode
42
+ emulateOsColorScheme('dark');
43
+ // Then, Swagger UI switches to its dark theme
44
+ RestApiDocumentationSteps.verifySwaggerDarkTheme();
45
+ // When, the OS switches back to light mode
46
+ emulateOsColorScheme('light');
47
+ // Then, Swagger UI switches back to its light theme
48
+ RestApiDocumentationSteps.verifySwaggerLightTheme();
49
+ });
50
+ });
@@ -49,22 +49,22 @@ describe('Import user data', () => {
49
49
  ImportUserDataSteps.getUploadTextSnippetButton().should('be.visible');
50
50
  });
51
51
 
52
- it('Should show the file size limit warning', () => {
52
+ it('Should show the file size limit info', () => {
53
53
  // Given I have visited the import page
54
54
  ImportUserDataSteps.visit();
55
55
  // When the page is loaded
56
- // Then I should see the file size limit warning
57
- ImportUserDataSteps.getFileSizeLimitWarning().should('be.visible');
58
- // When I click the server files tab through the link in the warning
59
- ImportUserDataSteps.openServerFilesTabFromWarning();
56
+ // Then I should see the file size limit info
57
+ ImportUserDataSteps.getFileSizeLimitInfo().should('be.visible');
58
+ // When I click the server files tab through the link in the info
59
+ ImportUserDataSteps.openServerFilesTabFromInfo();
60
60
  // Then I should see the server files tab
61
61
  ImportUserDataSteps.getActiveTab().should('have.text', 'Server files');
62
62
  cy.url().should('include', '/import').and('include', '#server');
63
63
  ImportUserDataSteps.getServerFilesTab().should('be.visible');
64
- // When I click on the API link in the warning
64
+ // When I click on the API link in the info
65
65
  ImportUserDataSteps.openUserDataTab();
66
66
  ImportUserDataSteps.getUserDataTab().should('be.visible');
67
- ImportUserDataSteps.openAPIViewFromWarning();
67
+ ImportUserDataSteps.openAPIViewFromInfo();
68
68
  // Then I should see the API view
69
69
  cy.url().should('include', '/webapi');
70
70
  });
@@ -80,7 +80,7 @@ describe('Import user data', () => {
80
80
  // Then the help should disappear
81
81
  ImportUserDataSteps.getHelpMessage().should('not.exist');
82
82
  // When I visit the import page again the help should appear again in the empty state
83
- ImportUserDataSteps.openAPIViewFromWarning();
83
+ ImportUserDataSteps.openAPIViewFromInfo();
84
84
  cy.url().should('include', '/webapi');
85
85
  ImportUserDataSteps.visit();
86
86
  ImportUserDataSteps.getHelpMessage().should('be.visible');
@@ -44,7 +44,7 @@ describe('Initial state of the import view with a selected repository', () => {
44
44
  ImportSteps.getUploadRdfFilesButton().should('be.visible');
45
45
  ImportSteps.getUploadFromUrlButton().should('be.visible');
46
46
  ImportSteps.getUploadTextSnippetButton().should('be.visible');
47
- ImportUserDataSteps.getFileSizeLimitationWarningMessage().should('be.visible');
47
+ ImportUserDataSteps.getFileSizeLimitationInfoMessage().should('be.visible');
48
48
  ImportUserDataSteps.getHelpMessage().should('not.exist');
49
49
  ImportUserDataSteps.getResourcesTable().should('be.visible');
50
50
  };
@@ -38,7 +38,7 @@ describe('Initial state of the import view with a selected repository and no imp
38
38
  ImportSteps.getUploadRdfFilesButton().should('be.visible');
39
39
  ImportSteps.getUploadFromUrlButton().should('be.visible');
40
40
  ImportSteps.getUploadTextSnippetButton().should('be.visible');
41
- ImportUserDataSteps.getFileSizeLimitationWarningMessage().should('be.visible');
41
+ ImportUserDataSteps.getFileSizeLimitationInfoMessage().should('be.visible');
42
42
  ImportUserDataSteps.getHelpMessage().should('be.visible');
43
43
  ImportUserDataSteps.getResourcesTable().should('be.hidden');
44
44
  };
@@ -176,11 +176,9 @@ describe('Repositories', () => {
176
176
  RepositorySteps.getRepositoryDisableSameAsCheckbox()
177
177
  .should('be.checked');
178
178
 
179
- // RDFS-Plus (Optimized) -> OWL-Horst (Optimized)
180
- RepositorySteps.getRepositoryRulesetMenu()
181
- .should('have.value', '3')
182
- .select('4')
183
- .should('have.value', '4');
179
+ RepositorySteps.verifySelectedRuleset('RDFS-Plus (Optimized)');
180
+ RepositorySteps.selectRuleset('OWL-Horst (Optimized)');
181
+ RepositorySteps.verifySelectedRuleset('OWL-Horst (Optimized)');
184
182
 
185
183
  // Should be automatically enabled when the rule set is changed to one of the OWL rule set
186
184
  RepositorySteps.getRepositoryDisableSameAsCheckbox()
@@ -201,8 +199,7 @@ describe('Repositories', () => {
201
199
  RepositorySteps.getRepositoryCreateForm();
202
200
  RepositorySteps.getRepositoryIdField().should('have.value', repositoryId);
203
201
  RepositorySteps.getRepositoryTitleField().should('have.value', repoTitle);
204
- // OWL-Horst (Optimized) has become 4
205
- RepositorySteps.getRepositoryRulesetMenu().should('have.value', '4');
202
+ RepositorySteps.verifySelectedRuleset('OWL-Horst (Optimized)');
206
203
  RepositorySteps.getRepositoryDisableSameAsCheckbox().should('not.be.checked');
207
204
  RepositorySteps.getRepositoryContextIndexCheckbox().should('be.checked');
208
205
 
@@ -210,6 +207,26 @@ describe('Repositories', () => {
210
207
  // getRepositoryFtsCheckbox().should('be.checked');
211
208
  });
212
209
 
210
+ it('should create repository with an RDF 1.2 ruleset', () => {
211
+ // Given I am on the create repository page
212
+ RepositorySteps.createRepository();
213
+ RepositorySteps.chooseRepositoryType(GDB_REPOSITORY_TYPE);
214
+ RepositorySteps.typeRepositoryId(repositoryId);
215
+
216
+ // When I select an RDF 1.2 ruleset and save the repository
217
+ RepositorySteps.selectRuleset('RDFS-Plus (Optimized, RDF 1.2)');
218
+ RepositorySteps.saveRepository();
219
+
220
+ // Then the edit page shows the ruleset by its name
221
+ RepositorySteps.editRepository(repositoryId);
222
+ RepositorySteps.verifySelectedRuleset('RDFS-Plus (Optimized, RDF 1.2)');
223
+
224
+ // And the repository config contains the ruleset id (the name-to-id mapping is what this change could break)
225
+ cy.getRepositoryConfig(repositoryId)
226
+ .its('params.ruleset.value')
227
+ .should('equal', 'rdfsplus-optimized-rdf12');
228
+ });
229
+
213
230
  it('should create repository with selected ruleset file', () => {
214
231
  interceptRulesetFileUpload();
215
232
  // Given I create a repository
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "graphdb-workbench-tests",
3
- "version": "4.0.0-TR23",
3
+ "version": "4.0.0-TR24",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "graphdb-workbench-tests",
9
- "version": "4.0.0-TR23",
9
+ "version": "4.0.0-TR24",
10
10
  "license": "Apache-2.0",
11
11
  "devDependencies": {
12
12
  "@bahmutov/cypress-code-coverage": "^2.7.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphdb-workbench-tests",
3
- "version": "4.0.0-TR23",
3
+ "version": "4.0.0-TR24",
4
4
  "description": "Cypress tests for GraphDB workbench",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -139,6 +139,20 @@ export class GraphNavigatorSteps extends BaseSteps {
139
139
  GraphNavigatorSteps.getConfirmDialog().find('.cancel-btn').click();
140
140
  }
141
141
 
142
+ /**
143
+ * Answers the question about a saved diagram of another repository: discard it.
144
+ */
145
+ static discardDiagramOfAnotherRepository() {
146
+ GraphNavigatorSteps.confirmDialog();
147
+ }
148
+
149
+ /**
150
+ * Answers the question about a saved diagram of another repository: keep it.
151
+ */
152
+ static keepDiagramOfAnotherRepository() {
153
+ GraphNavigatorSteps.cancelDialog();
154
+ }
155
+
142
156
  static verifyFileDownloaded(fileName) {
143
157
  cy.readFile('cypress/downloads/' + fileName);
144
158
  }
@@ -137,16 +137,16 @@ class ImportSteps {
137
137
  return this.getView().find('.import-from-url-btn');
138
138
  }
139
139
 
140
- static getFileSizeLimitWarning() {
141
- return this.getView().find('.file-size-limit-warning');
140
+ static getFileSizeLimitInfo() {
141
+ return this.getView().find('.file-size-limit-info');
142
142
  }
143
143
 
144
- static openServerFilesTabFromWarning() {
145
- this.getFileSizeLimitWarning().find('.server-files-tab-link').click();
144
+ static openServerFilesTabFromInfo() {
145
+ this.getFileSizeLimitInfo().find('.server-files-tab-link').click();
146
146
  }
147
147
 
148
- static openAPIViewFromWarning() {
149
- this.getFileSizeLimitWarning().find('.api-link').click();
148
+ static openAPIViewFromInfo() {
149
+ this.getFileSizeLimitInfo().find('.api-link').click();
150
150
  }
151
151
 
152
152
  static copyMaxFileSizeLimitProperty() {
@@ -10,8 +10,8 @@ export class ImportUserDataSteps extends ImportSteps {
10
10
  return this.getView().find('.user-data-import-help');
11
11
  }
12
12
 
13
- static getFileSizeLimitationWarningMessage() {
14
- return this.getView().find('.file-size-limit-warning');
13
+ static getFileSizeLimitationInfoMessage() {
14
+ return this.getView().find('.file-size-limit-info');
15
15
  }
16
16
 
17
17
  static openImportTextSnippetDialog() {
@@ -294,6 +294,22 @@ export class RepositorySteps extends BaseSteps {
294
294
  return RepositorySteps.getRepositoryCreateForm().find('#ruleset');
295
295
  }
296
296
 
297
+ /**
298
+ * Selects a ruleset in the repository form by its name in the dropdown.
299
+ * @param {string} rulesetName the ruleset name, e.g. 'OWL-Horst (Optimized)'
300
+ */
301
+ static selectRuleset(rulesetName) {
302
+ return RepositorySteps.getRepositoryRulesetMenu().select(rulesetName);
303
+ }
304
+
305
+ /**
306
+ * Verifies which ruleset is selected in the repository form.
307
+ * @param {string} rulesetName the expected ruleset name, e.g. 'OWL-Horst (Optimized)'
308
+ */
309
+ static verifySelectedRuleset(rulesetName) {
310
+ return RepositorySteps.getRepositoryRulesetMenu().find('option:selected').should('have.text', rulesetName);
311
+ }
312
+
297
313
  static getAdditionalPropertiesTextArea() {
298
314
  return RepositorySteps.getRepositoryCreateForm().find('#additionalProperties');
299
315
  }
@@ -12,4 +12,27 @@ export class RestApiDocumentationSteps extends BaseSteps {
12
12
  static verifyInitialState() {
13
13
  this.getRestApiContent().should('be.visible');
14
14
  }
15
+
16
+ static getSwaggerDocument() {
17
+ return this.getRestApiContent().its('0.contentDocument');
18
+ }
19
+
20
+ static getSwaggerRoot() {
21
+ return this.getSwaggerDocument().its('documentElement');
22
+ }
23
+
24
+ static waitForSwaggerUi() {
25
+ // The iframe starts with an empty document; wait until Swagger UI has rendered the API operations.
26
+ this.getSwaggerDocument().find('.opblock-tag').should('have.length.greaterThan', 0);
27
+ }
28
+
29
+ static verifySwaggerDarkTheme() {
30
+ this.waitForSwaggerUi();
31
+ this.getSwaggerRoot().should('have.class', 'dark-mode');
32
+ }
33
+
34
+ static verifySwaggerLightTheme() {
35
+ this.waitForSwaggerUi();
36
+ this.getSwaggerRoot().should('not.have.class', 'dark-mode');
37
+ }
15
38
  }
@@ -19,7 +19,8 @@ export class GraphNavigatorStubs extends Stubs {
19
19
  cy.intercept('POST', '/repositories/*', (req) => {
20
20
  // The body is form-encoded (`query=...`), so decode it to match the SPARQL text.
21
21
  const body = new URLSearchParams(String(req.body)).get('query') ?? '';
22
- if (body.includes('SELECT ?inst ?class ?label WHERE') && body.includes(text)) {
22
+ // The lookup query may declare a dataset (e.g. `FROM onto:explicit`) between the projection and `WHERE`.
23
+ if (/SELECT \?inst \?class \?label\s+(FROM\s+\S+\s+)*WHERE/.test(body) && body.includes(text)) {
23
24
  req.alias = 'entity-lookup';
24
25
  }
25
26
  });
@@ -19,6 +19,21 @@ Cypress.Commands.add('createRepository', (options = {}) => {
19
19
  });
20
20
  });
21
21
 
22
+ /**
23
+ * Reads a repository config through the REST API.
24
+ * @param {string} id the repository id
25
+ * @return the repository config, e.g. {id, params: {ruleset: {value}}}
26
+ */
27
+ Cypress.Commands.add('getRepositoryConfig', (id) => {
28
+ return cy.request({
29
+ method: 'GET',
30
+ url: REPOSITORIES_URL + '/' + id,
31
+ headers: {
32
+ 'Accept': 'application/json'
33
+ }
34
+ }).its('body');
35
+ });
36
+
22
37
  Cypress.Commands.add('deleteRepository', (id, secured = false) => {
23
38
  // unset the repository before delete to avoid missing repo errors
24
39
  unsetRepository();