graphdb-workbench-tests 3.4.0-dynamic-guides-test → 3.5.0-reactodia-poc

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 (71) hide show
  1. package/e2e-legacy/cluster/cluster-states.spec.js +3 -3
  2. package/e2e-legacy/explore/visual-graph/node-info-panel.spec.js +58 -0
  3. package/e2e-legacy/explore/visual-graph/visual-graph-links-limit.spec.js +167 -0
  4. package/e2e-legacy/explore/visual-graph/visual.graph.spec.js +55 -78
  5. package/e2e-legacy/graphql/graphql-in-remote-location.spec.js +49 -0
  6. package/e2e-legacy/guides/navigation/navigation-guide.spec.js +64 -0
  7. package/e2e-legacy/guides/table-graph-explore/table-graph-explore-guide.spec.js +2 -1
  8. package/e2e-legacy/guides/ttyg/configure-agent/configure-agent-guide.spec.js +34 -26
  9. package/e2e-legacy/guides/ttyg/edit-agent/edit-ttyg-agent-guide.spec.js +1 -0
  10. package/e2e-legacy/guides/visual-graph/visual-graph-guide.spec.js +330 -124
  11. package/e2e-legacy/help/guides/guides-autostart.spec.js +36 -3
  12. package/e2e-legacy/help/guides/guides-confirm-cancel-dialog.js +83 -0
  13. package/e2e-legacy/home/cookie-policy/cookie-policy.spec.js +182 -0
  14. package/e2e-legacy/home/create-repository.spec.js +6 -0
  15. package/e2e-legacy/repository/attach-remote-location.spec.js +47 -12
  16. package/e2e-legacy/repository/url-with-repository-id-parameter.spec.js +1 -1
  17. package/e2e-legacy/resource/resource.spec.js +33 -13
  18. package/e2e-legacy/setup/aclmanagement/acl-management-with-selected repository.spec.js +44 -0
  19. package/e2e-legacy/sparql-editor/actions/execute-query.spec.js +2 -0
  20. package/e2e-legacy/sparql-editor/actions/expand-results-over-sameas.spec.js +8 -8
  21. package/e2e-legacy/sparql-editor/actions/include-inferred-statements.spec.js +4 -4
  22. package/e2e-legacy/sparql-editor/actions/inferred-sameas.spec.js +3 -3
  23. package/e2e-legacy/sparql-editor/yasr/toolbar/visual-graph-button.spec.js +90 -36
  24. package/e2e-legacy/sparql-editor/yasr/yasr.spec.js +80 -0
  25. package/e2e-legacy/ttyg/chat-panel.spec.js +9 -0
  26. package/e2e-legacy/ttyg/clone-agent.spec.js +22 -0
  27. package/e2e-legacy/ttyg/edit-agent.spec.js +17 -0
  28. package/e2e-security/setup/home/cookie-policy.spec.js +232 -6
  29. package/e2e-security/setup/users-and-access/turn-on-security-and-password-change.spec.js +72 -59
  30. package/fixtures/graph/graph-configurations.json +59 -0
  31. package/fixtures/guides/confirm-cancel-dialog/confirm-cancel-dialog-guide.json +15 -0
  32. package/fixtures/guides/navigation/navigation-guide.json +60 -0
  33. package/fixtures/guides/ttyg/configure-agent/configure-ttyg-agent-guide.json +6 -1
  34. package/fixtures/guides/visual-graph/visual-graph-config-guide.json +39 -0
  35. package/fixtures/ttyg/chats/explain-response-1.json +2 -48
  36. package/npm-shrinkwrap.json +32 -33
  37. package/package.json +1 -1
  38. package/steps/cookie-policy/cookie-consent-banner-steps.js +21 -0
  39. package/steps/cookie-policy/cookie-policy-modal.steps.js +56 -0
  40. package/steps/graphql/create-graphql-endpoint-steps.js +8 -0
  41. package/steps/graphql/graphql-endpoint-management-steps.js +8 -0
  42. package/steps/graphql/graphql-playground-steps.js +8 -0
  43. package/steps/guides/guide-dialog-steps.js +56 -2
  44. package/steps/guides/movies-guide-steps.js +2 -1
  45. package/steps/header-steps.js +13 -0
  46. package/steps/home-steps.js +4 -27
  47. package/steps/login-steps.js +1 -0
  48. package/steps/main-menu-steps.js +1 -0
  49. package/steps/repositories/attach-repository-steps.js +16 -0
  50. package/steps/repository-steps.js +24 -0
  51. package/steps/resource/resource-steps.js +0 -8
  52. package/steps/setup/acl-management-steps.js +12 -0
  53. package/steps/setup/settings-steps.js +1 -1
  54. package/steps/shared-modal-dialog-steps.js +45 -0
  55. package/steps/sparql-editor-steps.js +18 -4
  56. package/steps/ttyg/ttyg-agent-settings-modal.steps.js +1 -1
  57. package/steps/visual-graph-split-button-steps.js +45 -0
  58. package/steps/visual-graph-steps.js +69 -3
  59. package/steps/yasgui/yasr-steps.js +30 -6
  60. package/stubs/cluster/remote-location-stubs.js +4 -0
  61. package/stubs/graph-config-stubs.js +17 -0
  62. package/stubs/guides/guides-stubs.js +8 -0
  63. package/stubs/repositories/repositories-stubs.js +22 -0
  64. package/stubs/security-stubs.js +4 -0
  65. package/stubs/sparql-stubs.js +10 -0
  66. package/support/commands.js +1 -0
  67. package/support/e2e-security.js +1 -1
  68. package/support/repository-commands.js +22 -3
  69. package/support/settings-commands.js +18 -2
  70. package/support/url-commands.js +13 -0
  71. package/e2e-legacy/home/cookie-policy.spec.js +0 -108
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Basic steps for interacting with the onto-dialog component. This class is designed to be extended by more specific
3
+ * dialog steps classes.
4
+ */
5
+ export class SharedModalDialogSteps {
6
+ /**
7
+ * Returns the onto-dialog element.
8
+ * This is the generic method to get the dialog element.
9
+ */
10
+ static getDialog() {
11
+ return cy.get('onto-dialog');
12
+ }
13
+
14
+ /**
15
+ * Returns a child component of the dialog based on the provided CSS class. The onto-dialog component is designed to
16
+ * be flexible and can contain be composed of various child components included in different slots: header, body,
17
+ * and footer.
18
+ * The purpose of this method is to allow selection of specific dialog in case there are multiple dialogs in the page.
19
+ * @param cssClass - The CSS class of the child component to retrieve. Defaults to '.dialog', which will return the
20
+ * dialog itself.
21
+ */
22
+ static getDialogComponent(cssClass = '.dialog') {
23
+ return cy.get(cssClass);
24
+ }
25
+
26
+ static getHeader() {
27
+ return this.getDialog().find('.dialog-header');
28
+ }
29
+
30
+ static getBody() {
31
+ return this.getDialog().find('.dialog-body');
32
+ }
33
+
34
+ static getFooter() {
35
+ return this.getDialog().find('.dialog-footer');
36
+ }
37
+
38
+ static getCloseButton() {
39
+ return this.getHeader().find('.close');
40
+ }
41
+
42
+ static close() {
43
+ this.getCloseButton().click();
44
+ }
45
+ }
@@ -1,14 +1,16 @@
1
1
  import {YasqeSteps} from "./yasgui/yasqe-steps";
2
+ import {YasrSteps} from './yasgui/yasr-steps.js';
2
3
 
3
4
  const VIEW_URL = '/sparql';
4
5
 
5
6
  export class SparqlEditorSteps {
6
- static visitSparqlEditorPage() {
7
- cy.visit(VIEW_URL);
7
+ static visitSparqlEditorPage(urlParameters) {
8
+ const url = urlParameters ? `${VIEW_URL}?${urlParameters}` : VIEW_URL;
9
+ cy.visit(url);
8
10
  }
9
11
 
10
- static visitSparqlEditorPageAndWaitForEditor() {
11
- SparqlEditorSteps.visitSparqlEditorPage();
12
+ static visitSparqlEditorPageAndWaitForEditor(urlParameters ) {
13
+ SparqlEditorSteps.visitSparqlEditorPage(urlParameters);
12
14
  // Because we use angularjs less than 1.7.3 we use additional library ng-custom-element.umd.js to solve problem with property bindings
13
15
  // This library make additional call to ontotext-yasgui-web-component and the component that's way the component renders twice when page loaded.
14
16
  // This is bad because in tests cypress can find an element when it is rendered from first call and try to click it for example.
@@ -19,6 +21,18 @@ export class SparqlEditorSteps {
19
21
  YasqeSteps.waitUntilQueryIsVisible();
20
22
  }
21
23
 
24
+ static visitSparqlEditorPageAndWaitForResults(urlParameters ) {
25
+ SparqlEditorSteps.visitSparqlEditorPage(urlParameters);
26
+ // Because we use angularjs less than 1.7.3 we use additional library ng-custom-element.umd.js to solve problem with property bindings
27
+ // This library make additional call to ontotext-yasgui-web-component and the component that's way the component renders twice when page loaded.
28
+ // This is bad because in tests cypress can find an element when it is rendered from first call and try to click it for example.
29
+ // If time of clicking such element is when second call to the component is done then exception that element is detached will be thrown.
30
+ // We will wait a little , to give a chance page is loaded correctly before test start.
31
+ // eslint-disable-next-line cypress/no-unnecessary-waiting
32
+ cy.wait(1000);
33
+ YasrSteps.waitUntilResultsIsVisible();
34
+ }
35
+
22
36
  static verifyUrl() {
23
37
  cy.url().should('include', `${Cypress.config('baseUrl')}${VIEW_URL}`);
24
38
  }
@@ -429,7 +429,7 @@ export class TtygAgentSettingsModalSteps extends ModalDialogSteps {
429
429
  }
430
430
 
431
431
  static enterContextSize(input) {
432
- this.getContextSizeField().type(input);
432
+ this.getContextSizeField().type(input, {force: true});
433
433
  }
434
434
 
435
435
  static getContextSizeError() {
@@ -0,0 +1,45 @@
1
+ export class VisualGraphSplitButtonSteps {
2
+ static getGraphExploreSplitButton() {
3
+ return cy.get('onto-graph-explore-split-button');
4
+ }
5
+
6
+ static getVisualizeMainButton() {
7
+ return VisualGraphSplitButtonSteps.getGraphExploreSplitButton().find('.explore-visual-graph-button');
8
+ }
9
+
10
+ static clickOnVisualizeMainButton() {
11
+ VisualGraphSplitButtonSteps.getVisualizeMainButton().click();
12
+ }
13
+
14
+ static getDropdownToggleButton() {
15
+ return VisualGraphSplitButtonSteps.getGraphExploreSplitButton().find('.onto-dropdown-button');
16
+ }
17
+
18
+ static toggleGraphConfigDropdown() {
19
+ VisualGraphSplitButtonSteps.getDropdownToggleButton().click();
20
+ }
21
+
22
+ static getGraphConfigs() {
23
+ return VisualGraphSplitButtonSteps.getGraphExploreSplitButton().find('.onto-dropdown-menu-item');
24
+ }
25
+
26
+ static getGraphConfig(index = 0) {
27
+ return VisualGraphSplitButtonSteps.getGraphConfigs().eq(index);
28
+ }
29
+
30
+ static selectGraphConfig(index = 0) {
31
+ VisualGraphSplitButtonSteps.getGraphConfig(index).click();
32
+ }
33
+
34
+ static getCreateGraphConfigLink() {
35
+ return VisualGraphSplitButtonSteps.getGraphExploreSplitButton().find('.graph-create-link');
36
+ }
37
+
38
+ static clickCreateGraphConfigLink() {
39
+ VisualGraphSplitButtonSteps.getCreateGraphConfigLink().click();
40
+ }
41
+
42
+ static getNoConfigurationsMessage() {
43
+ return VisualGraphSplitButtonSteps.getGraphExploreSplitButton().find('.no-configurations-message');
44
+ }
45
+ }
@@ -87,6 +87,30 @@ export class VisualGraphSteps extends BaseSteps {
87
87
  return cy.get('.autocomplete-toast a');
88
88
  }
89
89
 
90
+ static getRdfResourceSearchInput() {
91
+ return cy.getByTestId('rdf-resource-input');
92
+ }
93
+
94
+ static searchForRdfResource(resource) {
95
+ this.getRdfResourceSearchInput().type(resource, {force: true});
96
+ }
97
+
98
+ static shareVisualGraphWithOtherUsers() {
99
+ this.getShareGraphButton().click();
100
+ }
101
+
102
+ static getShareGraphButton() {
103
+ return cy.getByTestId('share-graph-config');
104
+ }
105
+
106
+ static selectConfig(configName) {
107
+ this.getConfigByName(configName).click();
108
+ }
109
+
110
+ static getConfigByName(name) {
111
+ return cy.getByTestId(`graph-config-${name}`);
112
+ }
113
+
90
114
  static getGraphVisualizationNodes() {
91
115
  return this.getGraphVisualizationPane().find('.node-wrapper');
92
116
  }
@@ -133,7 +157,7 @@ export class VisualGraphSteps extends BaseSteps {
133
157
  }
134
158
 
135
159
  static getNodeLabel(nodeId) {
136
- return this.getNode(nodeId).find('.node-label-body');
160
+ return this.getNode(nodeId).find('.node-label-body div');
137
161
  }
138
162
 
139
163
  static getPredicates() {
@@ -153,7 +177,7 @@ export class VisualGraphSteps extends BaseSteps {
153
177
  }
154
178
 
155
179
  static dblclickOnNode(nodeId) {
156
- this.getCircleOfNodeByNodeId(nodeId).dblclick();
180
+ this.getCircleOfNodeByNodeId(nodeId).trigger('dblclick');
157
181
  }
158
182
 
159
183
  static getLineBetweenNodesById(narrowId) {
@@ -172,10 +196,24 @@ export class VisualGraphSteps extends BaseSteps {
172
196
  return cy.get('.rdf-side-panel-content');
173
197
  }
174
198
 
199
+ static getPropertyByIndex(index) {
200
+ return this.getSidePanelContent().find('.rdf-list .datasource').eq(index);
201
+ }
202
+
175
203
  static closeSidePanel() {
176
204
  this.getSidePanelCloseButton().click();
177
205
  }
178
206
 
207
+ // Note the index is 1-based
208
+ static openConfigTab(tabIndex) {
209
+ return this.getConfigTab(tabIndex).click();
210
+ }
211
+
212
+ // Note the index is 1-based
213
+ static getConfigTab(tabIndex) {
214
+ return cy.getByTestId(`graph-config-tab-${tabIndex}`);
215
+ }
216
+
179
217
  // Visual graph settings form field access
180
218
 
181
219
  static openPredicatesTab() {
@@ -263,12 +301,32 @@ export class VisualGraphSteps extends BaseSteps {
263
301
  return cy.get('.create-graph-config').should('be.visible');
264
302
  }
265
303
 
304
+ static createCustomGraph() {
305
+ this.getCreateCustomGraphLink().click();
306
+ }
307
+
266
308
  static getGraphConfigName() {
267
309
  return cy.get('.graph-config-name').should('be.visible');
268
310
  }
269
311
 
270
312
  static typeGraphConfigName(name) {
271
- this.getGraphConfigName().type(name);
313
+ this.getGraphConfigName().type(name, {force: true});
314
+ }
315
+
316
+ static typeGraphConfigDescription(description) {
317
+ return this.getGraphConfigDescription().type(description, {force: true});
318
+ }
319
+
320
+ static getGraphConfigDescription() {
321
+ return cy.get('.graph-config-description').should('be.visible');
322
+ }
323
+
324
+ static typeGraphConfigHint(hint) {
325
+ return this.getGraphConfigHint().type(hint, {force: true});
326
+ }
327
+
328
+ static getGraphConfigHint() {
329
+ return cy.get('.graph-config-example').should('be.visible');
272
330
  }
273
331
 
274
332
  static getSaveConfigButton() {
@@ -349,6 +407,14 @@ export class VisualGraphSteps extends BaseSteps {
349
407
  return this.getTruncateLabelsCheckbox().click();
350
408
  }
351
409
 
410
+ static getInvalidLinksMessage() {
411
+ return this.getByTestId('invalid-links-limit');
412
+ }
413
+
414
+ static getShownLimitMessage() {
415
+ return this.getByTestId('shown-links-limit');
416
+ }
417
+
352
418
  static openVisualGraphHome() {
353
419
  cy.get('.toolbar-holder').should('be.visible')
354
420
  .find('.return-home-btn').should('be.visible').click();
@@ -1,8 +1,14 @@
1
- export class YasrSteps {
1
+ import {BaseSteps} from "../base-steps.js";
2
+
3
+ export class YasrSteps extends BaseSteps {
2
4
  static getYasr() {
3
5
  return cy.get('.tabPanel.active .yasr');
4
6
  }
5
7
 
8
+ static waitUntilResultsIsVisible() {
9
+ return cy.waitUntil(() => this.getYasr().should('be.visible'));
10
+ }
11
+
6
12
  static getResultHeader() {
7
13
  return cy.get('.yasr_header');
8
14
  }
@@ -28,7 +34,8 @@ export class YasrSteps {
28
34
  }
29
35
 
30
36
  static getResults() {
31
- return YasrSteps.getYasr().find('.yasr_results tbody').find('tr');
37
+ this.getYasrResultsContainer().should('not.have.class', 'rendering_result')
38
+ return this.getYasrResultsContainer().find('tbody').find('tr');
32
39
  }
33
40
 
34
41
  static getResultTableHeader() {
@@ -107,15 +114,32 @@ export class YasrSteps {
107
114
  return YasrSteps.getYasr().find('.yasr-toolbar');
108
115
  }
109
116
 
110
- static getVisualButton() {
111
- return YasrSteps.getYasrToolbar().find('.explore-visual-graph-button');
112
- }
113
-
114
117
  static getNoDataElement() {
118
+ this.getYasrResultsContainer().should('not.have.class', 'rendering_result')
115
119
  return cy.get('.dataTables_empty');
116
120
  }
117
121
 
118
122
  static getNoResultsMessage() {
119
123
  return YasrSteps.getYasr().find('.alert-success');
120
124
  }
125
+
126
+ static getPivotTablePlugin() {
127
+ return YasrSteps.getYasr().find('.pivot-table-plugin');
128
+ }
129
+
130
+ static getGoogleChartPlugin() {
131
+ return YasrSteps.getYasr().find('.google-visualization-table');
132
+ }
133
+
134
+ static getExtendedTablePlugin() {
135
+ return YasrSteps.getYasr().find('.dataTables_wrapper');
136
+ }
137
+
138
+ static getFullscreenButton() {
139
+ return cy.get('.yasr-fullscreen-button');
140
+ }
141
+
142
+ static toggleFullscreen() {
143
+ YasrSteps.getFullscreenButton().click();
144
+ }
121
145
  }
@@ -7,6 +7,10 @@ export class RemoteLocationStubs extends Stubs {
7
7
  }).as('add-remote-location');
8
8
  }
9
9
 
10
+ static spyRemoteLocationCreate() {
11
+ cy.intercept('POST', '/rest/locations').as('add-remote-location');
12
+ }
13
+
10
14
  static stubGetRemoteLocations(count = 'no') {
11
15
  cy.intercept('GET', '/rest/locations', {
12
16
  fixture: `/remote-location/get-${count}-remote-locations.json`,
@@ -0,0 +1,17 @@
1
+ import {Stubs} from './stubs.js';
2
+
3
+ export class GraphConfigStubs extends Stubs {
4
+ static stubGetEmptyGraphConfigs() {
5
+ cy.intercept('GET', '/rest/explore-graph/config', {
6
+ statusCode: 200,
7
+ body: [],
8
+ }).as('getEmptyGraphConfigs');
9
+ }
10
+
11
+ static stubGetGraphConfigs(fixture = '/graph/graph-configurations.json') {
12
+ GraphConfigStubs.stubQueryResponse(
13
+ '/rest/explore-graph/config',
14
+ fixture,
15
+ 'getGraphConfigs');
16
+ }
17
+ }
@@ -85,6 +85,14 @@ export class GuidesStubs {
85
85
  GuidesStubs.stubWithFixture('../fixtures/guides/visual-graph/visual-graph-guide.json');
86
86
  }
87
87
 
88
+ static stubVisualGraphConfigGuide() {
89
+ GuidesStubs.stubWithFixture('../fixtures/guides/visual-graph/visual-graph-config-guide.json');
90
+ }
91
+
92
+ static stubNavigationGuide() {
93
+ GuidesStubs.stubWithFixture('../fixtures/guides/navigation/navigation-guide.json');
94
+ }
95
+
88
96
  static stubWithFixture(fixturePath) {
89
97
  cy.intercept('/rest/guides', {fixture: fixturePath}).as('getGuides');
90
98
  }
@@ -1,6 +1,7 @@
1
1
  import {Stubs} from '../stubs';
2
2
  import {REPOSITORIES_URL} from '../../support/repository-commands';
3
3
  import {GlobalOperationsStatusesStub} from '../global-operations-statuses-stub.js';
4
+ import repoTemplate from "../../fixtures/repo-template.json";
4
5
 
5
6
  export class RepositoriesStubs extends Stubs {
6
7
  static stubRepositories(withDelay = 0, fixture = '/repositories/get-repositories.json') {
@@ -225,4 +226,25 @@ export class RepositoriesStubs extends Stubs {
225
226
  RepositoriesStubs.stubAutocomplete();
226
227
  GlobalOperationsStatusesStub.stubNoOperationsResponse('starwars');
227
228
  }
229
+
230
+ static stubRepositoryModel(repositoryId, options = {}) {
231
+ const body = Cypress._.defaultsDeep(
232
+ { id: repositoryId, ...options },
233
+ repoTemplate
234
+ );
235
+ cy.intercept('GET', `/rest/repositories/${repositoryId}`, {
236
+ statusCode: 200,
237
+ body
238
+ }).as('repository-model');
239
+ }
240
+
241
+ static stubFtsSearchDisabled(repositoryId) {
242
+ RepositoriesStubs.stubRepositoryModel(repositoryId, {
243
+ params: {
244
+ enableFtsIndex: {
245
+ value: 'false'
246
+ }
247
+ }
248
+ });
249
+ }
228
250
  }
@@ -20,6 +20,10 @@ export class SecurityStubs {
20
20
  }).as('security-all');
21
21
  }
22
22
 
23
+ static spyOnUserUpdate(userName) {
24
+ cy.intercept('PATCH', `rest/security/users/${userName}`).as('updateUser');
25
+ }
26
+
23
27
  static stubUpdateUserData(userName) {
24
28
  cy.intercept('PATCH', `/rest/security/users/${userName}`, {
25
29
  statusCode: 200,
@@ -0,0 +1,10 @@
1
+ import {Stubs} from './stubs.js';
2
+
3
+ export class SparqlStubs extends Stubs {
4
+ static spyAddKnownPrefixes() {
5
+ cy.intercept('/rest/sparql/add-known-prefixes', {
6
+ method: 'POST',
7
+ body: 'PREFIX voc: <https://swapi.co/vocabulary/> SELECT ?name ?height WHERE { ?character voc:height ?height; rdfs:label ?name. FILTER(?name = "Luke Skywalker" || ?name = "Leia Organa") }'
8
+ }).as('addKnownPrefixes')
9
+ }
10
+ }
@@ -8,6 +8,7 @@ import './user-commands';
8
8
  import './security-command';
9
9
  import './connector-commands';
10
10
  import 'cypress-wait-until';
11
+ import './url-commands.js';
11
12
 
12
13
  /**
13
14
  * Loads fixtures from the given paths recursively and returns them as an array.
@@ -1,6 +1,6 @@
1
1
  import './e2e';
2
2
 
3
- afterEach(() => {
3
+ beforeEach(() => {
4
4
  cy.loginAsAdmin();
5
5
  // Switch off security after each test to ensure that tests are independent and don't affect each other.
6
6
  // For example, if security is enabled in one test, it can cause other tests that don't expect security to fail.
@@ -47,13 +47,13 @@ Cypress.Commands.add('deleteRepository', (id, secured = false) => {
47
47
  });
48
48
  });
49
49
 
50
- Cypress.Commands.add('presetRepository', (id) => {
51
- cy.setLocalStorage(PRESET_REPO, JSON.stringify({id: id, location: ''}));
50
+ Cypress.Commands.add('presetRepository', (id, location = '') => {
51
+ cy.setLocalStorage(PRESET_REPO, JSON.stringify({id: id, location}));
52
52
  cy.waitUntil(() =>
53
53
  cy.getLocalStorage(PRESET_REPO)
54
54
  .then((preset) => {
55
55
  const presetRepo = JSON.parse(preset);
56
- return presetRepo && presetRepo.id === id
56
+ return presetRepo && presetRepo.id === id && presetRepo.location === location;
57
57
  }));
58
58
  cy.log('Pre-set repository:', id);
59
59
  });
@@ -78,6 +78,25 @@ Cypress.Commands.add('initializeRepository', (id) => {
78
78
  });
79
79
  });
80
80
 
81
+ /**
82
+ * A command for deleting remote locations by URI. It sends a DELETE request to the appropriate endpoint and waits until
83
+ * the response is received.
84
+ *
85
+ * @param {string} uri - The URI of the remote location to be deleted.
86
+ */
87
+ Cypress.Commands.add('deleteRemoteLocation', (uri) => {
88
+ cy.request({
89
+ method: 'DELETE',
90
+ url: '/rest/locations?uri=' + encodeURIComponent(uri),
91
+ headers: {
92
+ 'Content-Type': 'application/json'
93
+ },
94
+ failOnStatusCode: false
95
+ }).then((response) => {
96
+ cy.waitUntil(() => response);
97
+ });
98
+ });
99
+
81
100
  Cypress.Commands.add('enableAutocomplete', (repositoryId) => {
82
101
  toggleAutocomplete(repositoryId, true);
83
102
  });
@@ -1,4 +1,12 @@
1
- Cypress.Commands.add('setDefaultUserData', (cookieConsent = true) => {
1
+ /**
2
+ * Sets the default user settings for the admin user, including cookie consent.
3
+ * @param {CookieConsent} cookieConsent - The value to set for cookie consent.
4
+ * - policyAccepted: boolean indicating whether the cookie policy has been accepted.
5
+ * - statistic: boolean indicating consent for statistical cookies.
6
+ * - thirdParty: boolean indicating consent for third-party cookies.
7
+ * - updatedAt: epoch timestamp of last update in seconds.
8
+ */
9
+ Cypress.Commands.add('setDefaultUserData', (cookieConsent) => {
2
10
  const defaultUserSettings = {
3
11
  'COOKIE_CONSENT': cookieConsent,
4
12
  'DEFAULT_SAMEAS': true,
@@ -19,7 +27,15 @@ Cypress.Commands.add('setDefaultUserData', (cookieConsent = true) => {
19
27
  });
20
28
  });
21
29
 
22
- Cypress.Commands.add('setCookieConsent', (cookieConsent) => {
30
+ /**
31
+ * Sets the cookie consent in user settings for the admin user.
32
+ * @param {CookieConsent} cookieConsent - The value to set for cookie consent.
33
+ * - policyAccepted: boolean indicating whether the cookie policy has been accepted.
34
+ * - statistic: boolean indicating consent for statistical cookies.
35
+ * - thirdParty: boolean indicating consent for third-party cookies.
36
+ * - updatedAt: epoch timestamp of last update in seconds.
37
+ */
38
+ Cypress.Commands.add('setCookieConsent', (cookieConsent ) => {
23
39
  const defaultUserSettings = {
24
40
  'COOKIE_CONSENT': cookieConsent
25
41
  };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Custom Cypress command to retrieve the value of a query parameter from the current page URL.
3
+ *
4
+ * @param {string} key - The name of the query parameter to retrieve.
5
+ * @returns {Cypress.Chainable<string | null>} A chainable that resolves to the value of the query parameter,
6
+ * or null if the parameter is not present.
7
+ */
8
+ Cypress.Commands.add('getQueryParam', (key) => {
9
+ return cy.location('search').then((search) => {
10
+ const params = new URLSearchParams(search);
11
+ return params.get(key);
12
+ });
13
+ });
@@ -1,108 +0,0 @@
1
- import HomeSteps from '../../steps/home-steps';
2
- import {SecurityStubs} from '../../stubs/security-stubs';
3
- import {SettingsSteps} from '../../steps/setup/settings-steps';
4
- import {LicenseStubs} from '../../stubs/license-stubs';
5
-
6
- Cypress.env('set_default_user_data', false);
7
-
8
- describe('Cookie policy', () => {
9
- beforeEach(() => {
10
- cy.setCookieConsent(undefined);
11
- cy.viewport(1280, 1000);
12
- LicenseStubs.stubFreeLicense();
13
- });
14
-
15
- afterEach(() => cy.setCookieConsent(true));
16
-
17
- context('should show', () => {
18
- it('Should show consent popup to user', () => {
19
- HomeSteps.visitInProdMode();
20
- HomeSteps.getCookieConsentPopup().should('exist').and('be.visible');
21
- // When I click on the link
22
- HomeSteps.clickCookiePolicyLink();
23
- // Then I see the cookie policy
24
- HomeSteps.getCookiePolicyModal().should('exist').and('be.visible');
25
- });
26
-
27
- it('Should show cookie policy to user in user settings', () => {
28
- SettingsSteps.visitInProdMode();
29
- SettingsSteps.getCookiePolicyButton().should('exist').and('be.visible');
30
-
31
- // When I click on the link
32
- SettingsSteps.clickCookiePolicyLink();
33
- // Then I see the cookie policy
34
- SettingsSteps.getCookiePolicyModal().should('exist').and('be.visible');
35
- });
36
-
37
- it('Should save consent in user settings', () => {
38
- HomeSteps.visitInProdMode();
39
- SecurityStubs.stubUpdateUserData('admin');
40
-
41
- // When I click Agree button
42
- HomeSteps.clickAgreeButton();
43
-
44
- // I expect to save cookie consent in user settings
45
- cy.wait('@updateUser').then((xhr) => {
46
- expect(xhr.request.body.appSettings).to.include({
47
- DEFAULT_INFERENCE: true,
48
- DEFAULT_VIS_GRAPH_SCHEMA: true,
49
- DEFAULT_SAMEAS: true,
50
- IGNORE_SHARED_QUERIES: false,
51
- EXECUTE_COUNT: true
52
- });
53
-
54
- // Assert COOKIE_CONSENT properties, excluding updatedAt
55
- expect(xhr.request.body.appSettings.COOKIE_CONSENT).to.include({
56
- policyAccepted: true
57
- });
58
-
59
- // Assert that updatedAt is present, is a number, and is a reasonable timestamp
60
- const updatedAt = xhr.request.body.appSettings.COOKIE_CONSENT.updatedAt;
61
- expect(updatedAt).to.exist;
62
- expect(updatedAt).to.be.a('number');
63
-
64
- // Check that updatedAt is within 1 hour of the current time
65
- const oneHourInMilliseconds = 60 * 60 * 1000;
66
- const now = Date.now();
67
- expect(updatedAt).to.be.within(now - oneHourInMilliseconds, now + oneHourInMilliseconds);
68
- });
69
- });
70
-
71
- it('Should set cookies for tracking when accepted', () => {
72
- cy.intercept('PATCH', `/rest/security/users/admin`).as('updateUser');
73
- HomeSteps.visitInProdMode();
74
-
75
- // When I click Agree button
76
- HomeSteps.clickAgreeButton();
77
-
78
- // I expect to save cookie consent in user settings
79
- // There are two requests one from the new shared component and one in the legacy
80
- cy.wait('@updateUser');
81
- cy.wait('@updateUser');
82
-
83
- // Check if the GA tracking script is set correctly in the head
84
- cy.document()
85
- .get('head script')
86
- .should("have.attr", "src")
87
- .should('include', 'https://www.googletagmanager.com/gtm.js?id=GTM-WBP6C6Z4');
88
-
89
- // Check if the installation ID cookie is set correctly
90
- cy.getCookie('_wb').then((cookie) => {
91
- expect(cookie).to.exist;
92
- expect(cookie.value).to.match(/^WB1\.[a-zA-Z0-9\-]+\.\d+$/); // Check the cookie structure: WB1.<installationId>.<timestamp>
93
- });
94
- })
95
- })
96
-
97
- context('should not show', () => {
98
- it('Should NOT show consent popup to user when tracking is not applicable', () => {
99
- HomeSteps.visitInDevMode();
100
- HomeSteps.getCookieConsentPopup().should('not.exist');
101
- });
102
-
103
- it('Should NOT show cookie policy to user when tracking is not applicable', () => {
104
- SettingsSteps.visitInDevMode();
105
- SettingsSteps.getCookiePolicyButton().should('not.exist');
106
- });
107
- });
108
- });