graphdb-workbench-tests 3.5.0-reactodia-resource-construct-TR1 → 3.5.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.
Files changed (46) hide show
  1. package/e2e-legacy/guides/ttyg/configure-agent/configure-agent-guide.spec.js +2 -1
  2. package/e2e-legacy/guides/welcome/welcome-guide.spec.js +1 -1
  3. package/e2e-legacy/home/solr-banner/solr-banner.spec.js +137 -0
  4. package/e2e-legacy/repository/ontop-repository.spec.js +132 -0
  5. package/e2e-legacy/resource/resource.spec.js +4 -17
  6. package/e2e-legacy/setup/aclmanagement/create-rule.spec.js +1 -1
  7. package/e2e-legacy/setup/aclmanagement/delete-rule.spec.js +1 -1
  8. package/e2e-legacy/setup/aclmanagement/edit-rule.spec.js +1 -1
  9. package/e2e-legacy/setup/aclmanagement/render-rules.spec.js +1 -1
  10. package/e2e-legacy/setup/aclmanagement/reorder-rules.spec.js +1 -1
  11. package/e2e-legacy/setup/aclmanagement/revert-rules.spec.js +1 -1
  12. package/e2e-legacy/setup/aclmanagement/scopes.spec.js +2 -2
  13. package/e2e-legacy/setup/aclmanagement/update-rules.spec.js +2 -2
  14. package/e2e-legacy/setup/jdbc/jdbc-create.spec.js +1 -1
  15. package/e2e-legacy/setup/settings/my-settings-initial-state.spec.js +2 -6
  16. package/e2e-legacy/setup/settings/my-settings.spec.js +1 -1
  17. package/e2e-legacy/setup/users-and-access/user-and-access.spec.js +706 -337
  18. package/e2e-legacy/sparql-editor/saved-query/readonly-query.spec.js +1 -1
  19. package/e2e-legacy/ttyg/agent-select-menu.spec.js +7 -1
  20. package/e2e-legacy/ttyg/chat-list.spec.js +1 -1
  21. package/e2e-legacy/ttyg/create-chat.spec.js +1 -1
  22. package/e2e-legacy/ttyg/edit-agent.spec.js +2 -2
  23. package/e2e-legacy/ttyg/ttyg-permission.spec.js +2 -1
  24. package/e2e-security/setup/users-and-access/create-user-permissions.spec.js +15 -15
  25. package/e2e-security/setup/users-and-access/graphql-user.spec.js +3 -3
  26. package/e2e-security/setup/users-and-access/repo-admin-role.spec.js +2 -2
  27. package/eslint.config.js +1 -0
  28. package/fixtures/ontop/university-complete_edited.obda +106 -0
  29. package/npm-shrinkwrap.json +448 -278
  30. package/package.json +5 -6
  31. package/steps/application-steps.js +1 -1
  32. package/steps/deprecation-banner/deprecation-banner-steps.js +13 -0
  33. package/steps/deprecation-steps.js +13 -0
  34. package/steps/main-menu-steps.js +5 -1
  35. package/steps/ontop-repository-steps.js +20 -0
  36. package/steps/repository-steps.js +44 -3
  37. package/steps/resource/resource-steps.js +0 -8
  38. package/steps/setup/settings-steps.js +3 -3
  39. package/steps/setup/user-and-access-steps.js +84 -13
  40. package/steps/ttyg/ttyg-view-steps.js +15 -1
  41. package/stubs/repositories/repositories-stubs.js +4 -0
  42. package/stubs/security-stubs.js +4 -0
  43. package/support/security-command.js +43 -0
  44. package/cypress-guides.config.js +0 -45
  45. package/e2e-legacy/reactodia/reactodia.spec.js +0 -96
  46. package/steps/reactodia-steps.js +0 -42
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphdb-workbench-tests",
3
- "version": "3.5.0-reactodia-resource-construct-TR1",
3
+ "version": "3.5.0",
4
4
  "description": "Cypress tests for GraphDB workbench",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -10,10 +10,9 @@
10
10
  "cy:open-legacy": "cypress open --config-file cypress-legacy.config.js",
11
11
  "cy:open-security": "cypress open --config-file cypress-security.config.js",
12
12
  "cy:open-flaky": "cypress open --config-file cypress-flaky.config.js",
13
- "cy:open-guides": "cypress open --config-file cypress-guides.config.js",
14
- "cy:run-guides": "cypress run --config-file cypress-guides.config.js",
13
+ "cy:guides": "cypress run --config-file cypress-legacy.config.js --spec \"e2e-legacy/guides/**/*.spec.js\" --browser chrome",
15
14
  "cy:run": "npm run cy:run-legacy && cypress run",
16
- "cy:run:partial": "cypress run --config-file cypress-legacy.config.js --spec \"e2e-legacy/**/jdbc-create.spec.js\" --browser chrome",
15
+ "cy:run:partial": "cypress run --config-file cypress-legacy.config.js --spec \"e2e-legacy/ttyg/**/*.spec.js\" --browser chrome",
17
16
  "cy:run-legacy": "cypress run --config-file cypress-legacy.config.js --browser chrome",
18
17
  "cy:run-security": "cypress run --config-file cypress-security.config.js --browser chrome",
19
18
  "cy:run-legacy:coverage": "cypress run --config-file cypress-legacy.config.js --browser chrome",
@@ -41,12 +40,12 @@
41
40
  "@eslint/js": "^9.33.0",
42
41
  "babel-loader": "^10.0.0",
43
42
  "babel-plugin-istanbul": "^7.0.0",
44
- "cypress": "15.9.0",
43
+ "cypress": "^15.19.0",
45
44
  "cypress-failed-log": "^2.10.0",
46
45
  "cypress-file-upload": "^5.0.8",
47
46
  "cypress-localstorage-commands": "^2.2.7",
48
47
  "cypress-multi-reporters": "^2.0.5",
49
- "cypress-real-events": "^1.14.0",
48
+ "cypress-real-events": "^1.15.0",
50
49
  "cypress-terminal-report": "^7.2.0",
51
50
  "cypress-wait-until": "^3.0.2",
52
51
  "del": "^8.0.0",
@@ -28,7 +28,7 @@ export class ApplicationSteps {
28
28
  cy.get('onto-navbar .menu-element').eq(0).click();
29
29
  }
30
30
 
31
- static geLoader() {
31
+ static getLoader() {
32
32
  return cy.get('.ot-loader-new-content');
33
33
  }
34
34
 
@@ -0,0 +1,13 @@
1
+ export class DeprecationSteps {
2
+ static getDeprecationBanner() {
3
+ return cy.get('onto-deprecation-banner');
4
+ }
5
+
6
+ static getCloseButton() {
7
+ return DeprecationSteps.getDeprecationBanner().find('.close-button');
8
+ }
9
+
10
+ static closeBanner() {
11
+ DeprecationSteps.getCloseButton().click();
12
+ }
13
+ }
@@ -0,0 +1,13 @@
1
+ export class DeprecationSteps {
2
+ static getDeprecationBanner() {
3
+ return cy.get('onto-deprecation-banner');
4
+ }
5
+
6
+ static getCloseButton() {
7
+ return DeprecationSteps.getDeprecationBanner().find('.close-button');
8
+ }
9
+
10
+ static closeBanner() {
11
+ DeprecationSteps.getCloseButton().click();
12
+ }
13
+ }
@@ -53,7 +53,11 @@ export class MainMenuSteps {
53
53
 
54
54
  static clickOnMenu(menuName) {
55
55
  // Forced it because some element as "Explore" for example has CSS pointer-events: none
56
- MainMenuSteps.getMenuButton(menuName).click({force: true});
56
+ MainMenuSteps.getMenuButton(menuName).realClick();
57
+ }
58
+
59
+ static getSubmenuFor(menuName) {
60
+ return MainMenuSteps.getMainMenu().contains('.menu-element', menuName).find('.sub-menu');
57
61
  }
58
62
 
59
63
  static clickOnSubmenuTriggerElement(menuName) {
@@ -9,10 +9,22 @@ export class OntopRepositorySteps {
9
9
  return cy.get('div').contains("OBDA or R2RML file *").parent();
10
10
  }
11
11
 
12
+ static getPage() {
13
+ return cy.get('#wb-repository');
14
+ }
15
+
12
16
  static getOBDAUploadButton() {
13
17
  return cy.get('span[for="obdaFile"]').contains("Upload file...");
14
18
  }
15
19
 
20
+ static getOBDAFileFieldEditButton() {
21
+ return OntopRepositorySteps.getOBDAFileField().find('.ot-edit-input');
22
+ }
23
+
24
+ static editOBDAFile() {
25
+ OntopRepositorySteps.getOBDAFileFieldEditButton().click();
26
+ }
27
+
16
28
  static getOntologyFileField() {
17
29
  return cy.get('div').contains("Ontology file");
18
30
  }
@@ -119,9 +131,17 @@ export class OntopRepositorySteps {
119
131
  OntopRepositorySteps.getOBDAUploadButton().click();
120
132
  }
121
133
 
134
+ static getAdditionalJDBCProperties() {
135
+ return OntopRepositorySteps.getPage().find('.additional-jdbc-properties');
136
+ }
137
+
122
138
  static uploadObdaFile(file) {
123
139
  // The label for the input has visibility: hidden, so force must be used
124
140
  // eq() index 0 for location of OBDA field input
125
141
  cy.get('input[type=file]').eq(0).selectFile(file, {force: true});
126
142
  }
143
+
144
+ static getOntopSaveButton() {
145
+ return cy.get('#addEditOntopRepository');
146
+ }
127
147
  }
@@ -3,13 +3,17 @@ import {BaseSteps} from "./base-steps.js";
3
3
 
4
4
  export class RepositorySteps extends BaseSteps {
5
5
 
6
- static visit() {
6
+ static visit(waitPageLoaded = true) {
7
7
  cy.intercept('/rest/locations').as('getLocations');
8
8
  cy.intercept(REPOSITORIES_URL + '/all').as('getRepositories');
9
9
  cy.visit('/repository');
10
- RepositorySteps.waitLoader();
10
+ if (waitPageLoaded) {
11
+ RepositorySteps.waitLoader();
12
+ }
11
13
  cy.wait('@getLocations');
12
- RepositorySteps.waitUntilRepositoriesPageIsLoaded();
14
+ if (waitPageLoaded) {
15
+ RepositorySteps.waitUntilRepositoriesPageIsLoaded();
16
+ }
13
17
  }
14
18
 
15
19
  static visitEditPage(repositoryId) {
@@ -62,6 +66,11 @@ export class RepositorySteps extends BaseSteps {
62
66
  return this.getRepositoriesList().find('.repository.active');
63
67
  }
64
68
 
69
+ static getRepositories() {
70
+ return RepositorySteps.getRepositoriesList()
71
+ .find('.repository');
72
+ }
73
+
65
74
  static getRepositoryFromList(repository) {
66
75
  RepositorySteps.waitLoader();
67
76
  return RepositorySteps.getRepositoriesList()
@@ -105,6 +114,38 @@ export class RepositorySteps extends BaseSteps {
105
114
  .click();
106
115
  }
107
116
 
117
+ static getRepositoryActions(repositoryId) {
118
+ return RepositorySteps.getRepositoryFromList(repositoryId).find('.repository-actions');
119
+ }
120
+
121
+ static getCopyRepositoryButton(repositoryId) {
122
+ return RepositorySteps.getRepositoryActions(repositoryId).find('.copy-repository-btn');
123
+ }
124
+
125
+ static getEditRepositoryButton(repositoryId) {
126
+ return RepositorySteps.getRepositoryActions(repositoryId).find('.edit-repository-btn');
127
+ }
128
+
129
+ static getDownloadRepositoryConfigurationButton(repositoryId) {
130
+ return RepositorySteps.getRepositoryActions(repositoryId).find('.download-repository-config-btn');
131
+ }
132
+
133
+ static getRestartRepositoryButton(repositoryId) {
134
+ return RepositorySteps.getRepositoryActions(repositoryId).find('.restart-repository-btn');
135
+ }
136
+
137
+ static getDeleteRepositoryButton(repositoryId) {
138
+ return RepositorySteps.getRepositoryActions(repositoryId).find('.delete-repository-btn');
139
+ }
140
+
141
+ static getSetDefaultRepositoryButton(repositoryId) {
142
+ return RepositorySteps.getRepositoryActions(repositoryId).find('.pin-repository-btn');
143
+ }
144
+
145
+ static getPageButtons() {
146
+ return RepositorySteps.getRepositoriesPage().find('.btns-all');
147
+ }
148
+
108
149
  static editRepository(repositoryId) {
109
150
  RepositorySteps.clickRepositoryIcon(repositoryId, '.repository-actions .edit-repository-btn');
110
151
  }
@@ -147,12 +147,4 @@ export class ResourceSteps {
147
147
  static getDataTable() {
148
148
  return cy.get('.dataTable');
149
149
  }
150
-
151
- static getVisualizeReactodiaButton() {
152
- return cy.getByTestId('visualize-reactodia-button');
153
- }
154
-
155
- static clickOnVisualizeReactodiaButton() {
156
- ResourceSteps.getVisualizeReactodiaButton().click();
157
- }
158
150
  }
@@ -7,7 +7,7 @@ export class SettingsSteps {
7
7
 
8
8
  static visitInProdMode() {
9
9
  cy.visit('/settings', {
10
- onBeforeLoad: (win) => {
10
+ onBeforeLoad: () => {
11
11
  EnvironmentStubs.stubWbProdMode();
12
12
  }
13
13
  });
@@ -15,7 +15,7 @@ export class SettingsSteps {
15
15
 
16
16
  static visitInDevMode() {
17
17
  cy.visit('/settings', {
18
- onBeforeLoad: (win) => {
18
+ onBeforeLoad: () => {
19
19
  EnvironmentStubs.stubWbDevMode();
20
20
  }
21
21
  });
@@ -71,7 +71,7 @@ export class SettingsSteps {
71
71
  }
72
72
 
73
73
  static getUserRolePanel() {
74
- return this.getSettingsPage().find('.user-role');
74
+ return this.getSettingsPage().find('.user-roles');
75
75
  }
76
76
 
77
77
  static getUserRoleRadioButton() {
@@ -169,8 +169,12 @@ export class UserAndAccessSteps {
169
169
  return cy.get('#user-repos');
170
170
  }
171
171
 
172
- static clickWriteAccess() {
173
- cy.get('.write').click();
172
+ static getRepositoryRightsLine(repoName) {
173
+ if (repoName === '*') {
174
+ return this.getRepositoryRightsList().find('.any-repo');
175
+ } else {
176
+ return this.getRepositoryRightsList().contains(repoName).parent('tr');
177
+ }
174
178
  }
175
179
 
176
180
  static getCustomRoleFieldError() {
@@ -186,7 +190,7 @@ export class UserAndAccessSteps {
186
190
  }
187
191
 
188
192
  static getRepositoryRightsError() {
189
- return cy.get('#user-repos [ng-show="repositoryCheckError"].form-control-feedback');
193
+ return this.getRepositoryRightsList().find('[ng-show="repositoryCheckError"].form-control-feedback');
190
194
  }
191
195
 
192
196
  static getError() {
@@ -231,23 +235,21 @@ export class UserAndAccessSteps {
231
235
 
232
236
  static clickGraphqlAccessAny() {
233
237
  cy.get('#user-repos')
234
- .contains('Any data repository')
238
+ .contains('Global (any data repository)')
235
239
  .parent('tr')
236
240
  .find('.graphql')
237
241
  .realClick();
238
242
  }
239
243
 
240
244
  static clickGraphqlAccessRepo(repoName) {
241
- cy.get('#user-repos')
242
- .contains(repoName)
243
- .parent('tr')
245
+ this.getRepositoryRightsLine(repoName)
244
246
  .find('.graphql')
245
247
  .realClick();
246
248
  }
247
249
 
248
250
  static clickReadAccessAny() {
249
251
  cy.get('#user-repos')
250
- .contains('Any data repository')
252
+ .contains('Global (any data repository)')
251
253
  .parent('tr')
252
254
  .find('.read')
253
255
  .realClick();
@@ -263,7 +265,7 @@ export class UserAndAccessSteps {
263
265
 
264
266
  static clickWriteAccessAny() {
265
267
  cy.get('#user-repos')
266
- .contains('Any data repository')
268
+ .contains('Global (any data repository)')
267
269
  .parent('tr')
268
270
  .find('.write')
269
271
  .realClick();
@@ -289,7 +291,7 @@ export class UserAndAccessSteps {
289
291
 
290
292
  static getRepoLine(userRowAlias, matchText) {
291
293
  return cy.get(userRowAlias)
292
- .find('.repository-rights > div')
294
+ .find('.repository-rights-list')
293
295
  .filter(`:contains("${matchText}")`)
294
296
  }
295
297
 
@@ -301,6 +303,10 @@ export class UserAndAccessSteps {
301
303
  return cy.get(repoLineAlias).find('.ri-edit-line');
302
304
  }
303
305
 
306
+ static findMaintainIconAlias(repoLineAlias) {
307
+ return cy.get(repoLineAlias).find('.ri-folder-settings-line');
308
+ }
309
+
304
310
  static findGraphqlIconAlias(repoLineAlias) {
305
311
  return cy.get(repoLineAlias).find('.icon-graphql');
306
312
  }
@@ -308,38 +314,98 @@ export class UserAndAccessSteps {
308
314
  static openEditUserPage(username) {
309
315
  this.findUserInTable(username); // sets @user
310
316
  cy.get('@user').find('.edit-user-btn').click();
317
+ cy.url().should('include', `/user/${username}`);
318
+ UserAndAccessSteps.getUsernameField().should('be.visible');
311
319
  }
312
320
 
313
321
  static confirmUserEdit() {
314
322
  cy.get('#wb-user-submit').click();
315
323
  }
316
324
 
325
+ static validateRightsForRepo(repoName, checkbox, expectedState) {
326
+ const {checked, disabled} = expectedState;
327
+ if (checked === true) {
328
+ checkbox.should('be.checked');
329
+ } else if (checked === false) {
330
+ checkbox.should('not.be.checked');
331
+ }
332
+ if (disabled === true) {
333
+ checkbox.should('be.disabled');
334
+ } else if (disabled === false) {
335
+ checkbox.should('not.be.disabled');
336
+ }
337
+ }
338
+
339
+ // ============= Read Access Toggles and Validations =============
340
+
317
341
  static getReadAccessForRepo(repoName) {
318
- const matchText = (repoName === '*') ? 'Any data repository' : repoName;
342
+ const matchText = (repoName === '*') ? 'Global (any data repository)' : repoName;
319
343
  return cy.get('#user-repos')
320
344
  .contains(matchText)
321
345
  .parent('tr')
322
346
  .find('.read')
323
347
  }
324
348
 
349
+ static toggleReadAccessAny() {
350
+ UserAndAccessSteps.toggleReadAccessForRepo('*');
351
+ }
352
+
325
353
  static toggleReadAccessForRepo(repoName) {
326
354
  return this.getReadAccessForRepo(repoName).realClick();
327
355
  }
328
356
 
357
+ static validateReadAccessForRepo(repoName, expectedState) {
358
+ const readAccessCheckbox = this.getReadAccessForRepo(repoName);
359
+ this.validateRightsForRepo(repoName, readAccessCheckbox, expectedState);
360
+ }
361
+
362
+ // ============= Write Access Toggles and Validations =============
363
+
329
364
  static getWriteAccessForRepo(repoName) {
330
- const matchText = (repoName === '*') ? 'Any data repository' : repoName;
365
+ const matchText = (repoName === '*') ? 'Global (any data repository)' : repoName;
331
366
  return cy.get('#user-repos')
332
367
  .contains(matchText)
333
368
  .parent('tr')
334
369
  .find('.write')
335
370
  }
336
371
 
372
+ static toggleWriteAccessAny() {
373
+ UserAndAccessSteps.toggleWriteAccessForRepo('*');
374
+ }
375
+
337
376
  static toggleWriteAccessForRepo(repoName) {
338
377
  return this.getWriteAccessForRepo(repoName).realClick();
339
378
  }
340
379
 
380
+ static validateWriteAccessForRepo(repoName, expectedState) {
381
+ const writeAccessCheckbox = this.getWriteAccessForRepo(repoName);
382
+ this.validateRightsForRepo(repoName, writeAccessCheckbox, expectedState);
383
+ }
384
+
385
+ // ============= Maintain Repository Access Toggles and Validations =============
386
+
387
+ static getMaintainAccessRepoCheckbox(repoName) {
388
+ return this.getRepositoryRightsLine(repoName)
389
+ .find('.maintain-repository');
390
+ }
391
+
392
+ static clickMaintainAccessRepo(repoName) {
393
+ UserAndAccessSteps.getMaintainAccessRepoCheckbox(repoName).realClick();
394
+ }
395
+
396
+ static toggleMaintainRepoForRepo(repoName) {
397
+ return this.clickMaintainAccessRepo(repoName);
398
+ }
399
+
400
+ static validateMaintainAccessForRepo(repoName, expectedState) {
401
+ const maintainAccessCheckbox = this.getMaintainAccessRepoCheckbox(repoName);
402
+ this.validateRightsForRepo(repoName, maintainAccessCheckbox, expectedState);
403
+ }
404
+
405
+ // ============= GraphQL Access Toggles and Validations =============
406
+
341
407
  static getGraphqlAccessForRepo(repoName) {
342
- const matchText = (repoName === '*') ? 'Any data repository' : repoName;
408
+ const matchText = (repoName === '*') ? 'Global (any data repository)' : repoName;
343
409
  return cy.get('#user-repos')
344
410
  .contains(matchText)
345
411
  .parent('tr')
@@ -350,6 +416,11 @@ export class UserAndAccessSteps {
350
416
  return this.getGraphqlAccessForRepo(repoName).realClick();
351
417
  }
352
418
 
419
+ static validateGraphqlAccessForRepo(repoName, expectedState) {
420
+ const graphqlAccessCheckbox = this.getGraphqlAccessForRepo(repoName);
421
+ this.validateRightsForRepo(repoName, graphqlAccessCheckbox, expectedState);
422
+ }
423
+
353
424
  static clickMenuItem(label) {
354
425
  return cy.get('.main-menu').contains(label).click({force: true});
355
426
  }
@@ -1,8 +1,21 @@
1
1
  import {BaseSteps} from "../base-steps";
2
+ import {DeprecationSteps} from '../deprecation-banner/deprecation-banner-steps.js';
2
3
 
3
4
  export class TTYGViewSteps extends BaseSteps {
4
- static visit() {
5
+ /**
6
+ * Visits the TTYG page and closes the Solr deprecation banner by default.
7
+ *
8
+ * @param {boolean} closeSolrBanner Whether to close the banner. Set to `false`
9
+ * when revisiting the page after the banner has already been closed.
10
+ */
11
+ static visit(closeSolrBanner = true) {
5
12
  cy.visit('/ttyg');
13
+ // Temporary workaround until the Solr deprecation banner is removed.
14
+ // The banner changes the page layout, causing tests to fail randomly.
15
+ // This quick fix prevents GraphDB build failures and should be deleted together with the banner.
16
+ if (closeSolrBanner) {
17
+ DeprecationSteps.closeBanner();
18
+ }
6
19
  }
7
20
 
8
21
  static getTtygView() {
@@ -243,6 +256,7 @@ export class TTYGViewSteps extends BaseSteps {
243
256
  }
244
257
 
245
258
  static getOpenAgentActionsButton(index) {
259
+ this.getAgent(index).scrollIntoView();
246
260
  return this.getAgent(index).realHover().find('.open-agent-actions-btn');
247
261
  }
248
262
 
@@ -247,4 +247,8 @@ export class RepositoriesStubs extends Stubs {
247
247
  }
248
248
  });
249
249
  }
250
+
251
+ static spyGetJDBCProperties() {
252
+ cy.intercept('GET', '/rest/repositories/ontop/jdbc-properties?**').as('getJDBCProperties');
253
+ }
250
254
  }
@@ -14,6 +14,10 @@ export class SecurityStubs {
14
14
  cy.intercept('POST', 'rest/security/users/*').as('create-user');
15
15
  }
16
16
 
17
+ static spyOnUserGet() {
18
+ cy.intercept('GET', 'rest/security/users/*').as('get-user');
19
+ }
20
+
17
21
  static stubInferAndSameAsDefaults() {
18
22
  cy.intercept('rest/security/all', (req) => {
19
23
  req.reply(SecurityStubs.getResponseSecurityEnabled());
@@ -29,6 +29,30 @@ Cypress.Commands.add('loginAsAdmin', () => {
29
29
  });
30
30
  });
31
31
 
32
+ Cypress.Commands.add('loginAs', (username, password) => {
33
+ return cy.request({
34
+ method: 'POST',
35
+ url: '/rest/login',
36
+ body: {
37
+ username,
38
+ password,
39
+ },
40
+ headers: {
41
+ 'Content-Type': 'application/json',
42
+ },
43
+ failOnStatusCode: true,
44
+ }).then((response) => {
45
+ const authHeader = response.headers['authorization'];
46
+ const token = Array.isArray(authHeader)
47
+ ? authHeader[0]
48
+ : authHeader;
49
+ cy.window().then((win) => {
50
+ win.localStorage.setItem('ontotext.gdb.auth.jwt', token);
51
+ win.localStorage.setItem('ontotext.gdb.auth.authenticated', 'true');
52
+ });
53
+ });
54
+ });
55
+
32
56
  Cypress.Commands.add('switchOffSecurity', (secured = false) => {
33
57
  let headers = {'Content-Type': 'application/json'};
34
58
  if (secured) {
@@ -64,3 +88,22 @@ Cypress.Commands.add('switchOffFreeAccess', (secured = false) => {
64
88
  failOnStatusCode: true,
65
89
  });
66
90
  });
91
+
92
+ Cypress.Commands.add('switchOnFreeAccess', (secured = false) => {
93
+ let headers = {'Content-Type': 'application/json'};
94
+ if (secured) {
95
+ const authHeader = Cypress.env('adminToken');
96
+ headers = {...headers,
97
+ 'Authorization': authHeader
98
+ }
99
+ }
100
+ return cy.request({
101
+ method: 'POST',
102
+ url: '/rest/security/free-access',
103
+ body: {
104
+ 'enabled': true
105
+ },
106
+ headers,
107
+ failOnStatusCode: false,
108
+ });
109
+ });
@@ -1,45 +0,0 @@
1
- import { defineConfig } from 'cypress';
2
- import setupPlugins from './plugins/index.js';
3
-
4
- const isCoverage = process.env.COVERAGE === 'true';
5
-
6
- const loadCodeCoverage = async (on, config) => {
7
- const mod = await import('@bahmutov/cypress-code-coverage/plugin');
8
- const plugin = ('default' in mod) ? mod.default : mod;
9
- plugin(on, config);
10
- };
11
-
12
- export default defineConfig({
13
- projectId: 'v35btb',
14
- fixturesFolder: 'fixtures',
15
- screenshotsFolder: 'report/screenshots',
16
- videosFolder: 'report/videos',
17
- video: true,
18
- defaultCommandTimeout: 25000,
19
- numTestsKeptInMemory: 10,
20
- viewportWidth: 1600,
21
- viewportHeight: 1200,
22
- e2e: {
23
- retries: {
24
- runMode: 2,
25
- openMode: 0
26
- },
27
- async setupNodeEvents(on, config) {
28
- setupPlugins(on, config);
29
- if (isCoverage) {
30
- await loadCodeCoverage(on, config);
31
- }
32
- return config;
33
- },
34
- baseUrl: 'http://localhost:9000',
35
- specPattern: 'e2e-legacy/guides/**/*.{js,jsx,ts,tsx}',
36
- supportFile: 'support/e2e.js',
37
- reporter: "cypress-multi-reporters",
38
- reporterOptions: {
39
- configFile: 'cypress-reporter-config.json'
40
- }
41
- },
42
- env: {
43
- set_default_user_data: true
44
- }
45
- });