graphdb-workbench-tests 4.0.0-TR19 → 4.0.0-TR20

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.
@@ -36,7 +36,7 @@ describe('Connectors - Lucene', () => {
36
36
  it('should create Lucene connector.', () => {
37
37
  // When I execute create lucene connector query.
38
38
  YasqeSteps.pasteQuery(LuceneConnectorSteps.getCreateConnectorQuery('my_index'));
39
- YasqeSteps.executeQueryWithoutWaiteResult();
39
+ YasqeSteps.executeQueryWithoutWaitingForResult();
40
40
 
41
41
  // Then I expect Lucene connector to be created.
42
42
  TablePluginSteps.getQueryResultInfo().contains('Created connector my_index');
@@ -28,7 +28,7 @@ describe('Abort query', () => {
28
28
  // and execute a query that takes a long time.
29
29
  YasqeSteps.pasteQuery(
30
30
  'select (count(*) as ?count) where {?s ?p ?o. ?s1 ?p1 ?o1. ?s2 ?p2 ?o2. ?s3 ?p3 ?o3.}');
31
- YasqeSteps.executeQueryWithoutWaiteResult();
31
+ YasqeSteps.executeQueryWithoutWaitingForResult();
32
32
 
33
33
  // Then I expect to an "Abort query" button to be displayed,
34
34
  YasqeSteps.getAbortQueryButton().should('exist');
@@ -0,0 +1,219 @@
1
+ import {QueryStubs} from '../../stubs/yasgui/query-stubs.js';
2
+ import {SparqlEditorSteps} from '../../steps/sparql-editor-steps.js';
3
+ import {YasqeSteps} from '../../steps/yasgui/yasqe-steps.js';
4
+ import ImportSteps from '../../steps/import/import-steps.js';
5
+ import {MainMenuSteps} from '../../steps/main-menu-steps.js';
6
+ import {ModalDialogSteps} from '../../steps/modal-dialog-steps.js';
7
+ import {RepositorySelectorSteps} from '../../steps/repository-selector-steps.js';
8
+ import {LanguageSelectorSteps} from '../../steps/language-selector-steps.js';
9
+ import {UserAndAccessSteps} from '../../steps/setup/user-and-access-steps.js';
10
+ import {LoginSteps} from '../../steps/login-steps.js';
11
+ import {HeaderSteps} from '../../steps/header-steps.js';
12
+
13
+ const LONG_RUNNING_QUERY_DELAY = 10000;
14
+
15
+ describe('SPARQL Editor Navigation', () => {
16
+ let repositoryId;
17
+ let secondRepositoryId;
18
+ beforeEach(() => {
19
+ repositoryId = 'sparql-editor-' + Date.now();
20
+ QueryStubs.stubQueryCountResponse();
21
+ cy.createRepository({id: repositoryId});
22
+ cy.presetRepository(repositoryId);
23
+ QueryStubs.spyAbortQuery();
24
+ });
25
+
26
+ afterEach(() => {
27
+ cy.deleteRepository(repositoryId);
28
+ if (secondRepositoryId) {
29
+ cy.deleteRepository(secondRepositoryId);
30
+ }
31
+ });
32
+
33
+ it('should navigate to other view if user confirmed navigation', () => {
34
+ // GIVEN: I visit a page with the ontotext-yasgui-web-component on it.
35
+ SparqlEditorSteps.visitSparqlEditorPage();
36
+ MainMenuSteps.getMainMenu().should('be.visible');
37
+
38
+ // WHEN: I try to go to another view
39
+ MainMenuSteps.clickOnMenuImport();
40
+ // THEN: I expect to navigate because there is no running query
41
+ ImportSteps.getView().should('exist');
42
+
43
+ // WHEN: I return to the view with the ontotext-yasgui-web-component.
44
+ SparqlEditorSteps.visitSparqlEditorPage();
45
+ // AND: I run a long-running query
46
+ QueryStubs.stubLongRunningQuery(repositoryId, LONG_RUNNING_QUERY_DELAY);
47
+ YasqeSteps.executeQueryWithoutWaitingForResult();
48
+ // AND: I try to leave the page
49
+ MainMenuSteps.clickOnMenuImport();
50
+ // THEN: I expect to see a confirmation dialog
51
+ ModalDialogSteps.getDialog().should('exist');
52
+ ModalDialogSteps.getDialogBody().should('contain.text', 'You have running 1 query, that will be aborted.');
53
+
54
+ // WHEN: I cancel the dialog
55
+ ModalDialogSteps.cancel();
56
+ // THEN: I expect to stay on the same view
57
+ SparqlEditorSteps.verifyUrl();
58
+ ImportSteps.getView().should('not.exist');
59
+ // AND: I expect the query not to be aborted
60
+ cy.get('@abortQuery.all').should('have.length', 0);
61
+
62
+ // WHEN: I confirm leaving the page
63
+ MainMenuSteps.clickOnMenuImport();
64
+ ModalDialogSteps.getDialog().should('exist');
65
+ ModalDialogSteps.getDialogBody().should('contain.text', 'You have running 1 query, that will be aborted.');
66
+ ModalDialogSteps.confirm();
67
+ // THEN: I expect to navigate to the other view
68
+ ImportSteps.verifyUrl();
69
+ ImportSteps.getView().should('exist');
70
+ // AND: I expect the query to be aborted
71
+ cy.get('@abortQuery.all').should('have.length', 1);
72
+ });
73
+
74
+ it('should change active repository if user confirmed', () => {
75
+ // GIVEN: There are at least two repositories and one is selected
76
+ secondRepositoryId = 'sparql-editor-' + Date.now();
77
+ cy.createRepository({id: secondRepositoryId});
78
+
79
+ // WHEN: I visit a page with the ontotext-yasgui-web-component on it.
80
+ SparqlEditorSteps.visitSparqlEditorPage();
81
+ // AND: I run a long-running query
82
+ QueryStubs.stubLongRunningQuery(repositoryId, LONG_RUNNING_QUERY_DELAY);
83
+ YasqeSteps.executeQueryWithoutWaitingForResult();
84
+ // AND: I try to change the repository
85
+ RepositorySelectorSteps.selectRepository(secondRepositoryId);
86
+ // THEN: I expect to see a confirmation dialog
87
+ ModalDialogSteps.getDialog().should('exist');
88
+ ModalDialogSteps.getDialogBody().should('contain.text', 'You have running 1 query, that will be aborted.');
89
+
90
+ // WHEN: I cancel the dialog
91
+ ModalDialogSteps.cancel();
92
+ // THEN: I expect the repository not to be changed.
93
+ RepositorySelectorSteps.getSelectedRepository().should('contain', repositoryId);
94
+ // AND: I expect the query not to be aborted
95
+ cy.get('@abortQuery.all').should('have.length', 0);
96
+
97
+ // WHEN: I confirm changing of repository
98
+ RepositorySelectorSteps.selectRepository(secondRepositoryId);
99
+ ModalDialogSteps.getDialog().should('exist');
100
+ ModalDialogSteps.getDialogBody().should('contain.text', 'You have running 1 query, that will be aborted.');
101
+ ModalDialogSteps.confirm();
102
+ // THEN: I expect the active repository to be changed
103
+ RepositorySelectorSteps.getSelectedRepository().should('contain', secondRepositoryId);
104
+ // AND: I expect the query to be aborted
105
+ cy.get('@abortQuery.all').should('have.length', 1);
106
+
107
+ // WHEN: I change the repository again, but this time there is no running query
108
+ RepositorySelectorSteps.selectRepository(repositoryId);
109
+ // THEN: I expect the repository to be changed without confirmation, because there are no running queries.
110
+ RepositorySelectorSteps.getSelectedRepository().should('contain', repositoryId);
111
+ ModalDialogSteps.getDialog().should('not.exist');
112
+ });
113
+
114
+ it('should change application language if user confirmed', () => {
115
+ // GIVEN: I visit a page with the ontotext-yasgui-web-component on it, in English. The test switches the language to French.
116
+ SparqlEditorSteps.visitSparqlEditorPage();
117
+ // Execute and wait for result give chance to application to be ready for the test, otherwise listeners are not
118
+ // attached and the test will fail
119
+ YasqeSteps.executeQuery();
120
+ LanguageSelectorSteps.getLanguageSelectorDropdownButton().should('contain', 'en');
121
+
122
+ // WHEN: I run a long-running query
123
+ QueryStubs.stubLongRunningQuery(repositoryId, LONG_RUNNING_QUERY_DELAY);
124
+ YasqeSteps.executeQueryWithoutWaitingForResult();
125
+ // AND: I try to change the application language
126
+ LanguageSelectorSteps.switchToFr();
127
+ // THEN: I expect to see a confirmation dialog
128
+ ModalDialogSteps.getDialog().should('exist');
129
+ ModalDialogSteps.getDialogBody().should('contain.text', 'You have running 1 query, that will be aborted.');
130
+
131
+ // WHEN: I cancel the dialog
132
+ ModalDialogSteps.cancel();
133
+ // THEN: I expect the application language not to be changed.
134
+ LanguageSelectorSteps.getLanguageSelectorDropdownButton().should('contain', 'en');
135
+ // AND: I expect the query not to be aborted
136
+ cy.get('@abortQuery.all').should('have.length', 0);
137
+
138
+ // WHEN: I confirm changing the language
139
+ LanguageSelectorSteps.switchToFr();
140
+ ModalDialogSteps.getDialog().should('exist');
141
+ ModalDialogSteps.getDialogBody().should('contain.text', 'You have running 1 query, that will be aborted.');
142
+ ModalDialogSteps.confirm();
143
+ // THEN: I expect the query to be aborted
144
+ cy.get('@abortQuery.all').should('have.length', 1);
145
+ // AND: I expect the application language to be changed
146
+ LanguageSelectorSteps.getLanguageSelectorDropdownButton().should('contain', 'fr');
147
+ });
148
+
149
+ it('should abort query when page is reloaded', () => {
150
+ // GIVEN: I visit a page with the ontotext-yasgui-web-component on it.
151
+ SparqlEditorSteps.visitSparqlEditorPage();
152
+ // AND: I run a long-running query
153
+ QueryStubs.stubLongRunningQuery(repositoryId, LONG_RUNNING_QUERY_DELAY);
154
+ YasqeSteps.executeQueryWithoutWaitingForResult();
155
+
156
+ // WHEN: I reload the page
157
+ SparqlEditorSteps.visitSparqlEditorPage();
158
+ // THEN: I expect the query to be aborted
159
+ cy.get('@abortQuery.all').should('have.length', 1);
160
+ });
161
+
162
+ context('Security', () => {
163
+
164
+ beforeEach(() => {
165
+ UserAndAccessSteps.visit();
166
+ UserAndAccessSteps.toggleSecurity();
167
+ LoginSteps.loginWithUser('admin', 'root');
168
+ // Wait for the login to finish, otherwise the next visit reloads the page before the session is stored.
169
+ HeaderSteps.getUserMenu().should('be.visible');
170
+ });
171
+
172
+ afterEach(() => {
173
+ cy.loginAsAdmin().then(() => {
174
+ cy.switchOffSecurity(true);
175
+ });
176
+ });
177
+
178
+ it('should sign out if user confirmed', () => {
179
+ // GIVEN: The security is on
180
+ // AND: I visit a page with the ontotext-yasgui-web-component on it.
181
+ SparqlEditorSteps.visitSparqlEditorPage();
182
+
183
+ // WHEN: I log out
184
+ LoginSteps.logout();
185
+ // THEN: I expect to navigate to the login page, because there are no long-running queries.
186
+ LoginSteps.verifyUrl();
187
+
188
+ // WHEN: I am logged in
189
+ LoginSteps.loginWithUser('admin', 'root');
190
+ // AND: I run a long-running query
191
+ QueryStubs.stubLongRunningQuery(repositoryId, LONG_RUNNING_QUERY_DELAY);
192
+ YasqeSteps.executeQueryWithoutWaitingForResult();
193
+ // AND: I try to log out
194
+ LoginSteps.logout();
195
+ // THEN: I expect to see a sign-out confirmation dialog
196
+ ModalDialogSteps.getDialog().should('exist');
197
+ ModalDialogSteps.getDialogBody()
198
+ .should('contain.text', 'You have running 1 query, that will be aborted.')
199
+ .and('contain.text', 'Are you sure that you want to sign out?');
200
+
201
+ // WHEN: I cancel the dialog
202
+ ModalDialogSteps.cancel();
203
+ // THEN: I expect to stay logged in
204
+ HeaderSteps.getUserMenu().should('be.visible');
205
+ // AND: I expect the query not to be aborted
206
+ cy.get('@abortQuery.all').should('have.length', 0);
207
+
208
+ // WHEN: I confirm signing out
209
+ LoginSteps.logout();
210
+ ModalDialogSteps.getDialog().should('exist');
211
+ ModalDialogSteps.getDialogBody().should('contain.text', 'You have running 1 query, that will be aborted.');
212
+ ModalDialogSteps.confirm();
213
+ // THEN: I expect to navigate to the login page.
214
+ LoginSteps.verifyUrl();
215
+ // AND: I expect the query to be aborted
216
+ cy.get('@abortQuery.all').should('have.length', 1);
217
+ });
218
+ });
219
+ });
@@ -93,7 +93,7 @@ describe('Yasgui tabs', () => {
93
93
  // When I execute a long-running query,
94
94
  QueryStubs.stubLongRunningQuery(repositoryId);
95
95
  SparqlEditorSteps.visitSparqlEditorPage();
96
- YasqeSteps.executeQueryWithoutWaiteResult();
96
+ YasqeSteps.executeQueryWithoutWaitingForResult();
97
97
  // and try to navigate to other page.
98
98
  MainMenuSteps.clickOnMenuImport();
99
99
 
@@ -133,6 +133,10 @@ describe('Cookie policy', () => {
133
133
  cy.reload();
134
134
  // Then I expect the banner to be hidden
135
135
  CookieConsentBannerSteps.getCookieConsentBanner().should('not.exist');
136
+ // Wait for the page to be fully loaded.
137
+ // Cypress executes actions very quickly, and without this wait the logout subscribers may not be registered yet.
138
+ // As a result, the logout event is not handled correctly and the logout operation may fail.
139
+ SettingsSteps.getCookiePolicyButton().should('be.visible');
136
140
  // When I logout
137
141
  LoginSteps.logout();
138
142
  // Then I should see the login page
@@ -0,0 +1,57 @@
1
+ import {LicenseStubs} from '../../../stubs/license-stubs';
2
+ import {LoginSteps} from '../../../steps/login-steps';
3
+ import {HeaderSteps} from '../../../steps/header-steps';
4
+
5
+ Cypress.env('set_default_user_data', false);
6
+
7
+ describe('License loading', () => {
8
+ beforeEach(() => {
9
+ cy.switchOnSecurity();
10
+ cy.loginAsAdmin();
11
+ LicenseStubs.spyGetLicense();
12
+ });
13
+
14
+ context('when free access is off', () => {
15
+ it('should load the license only for a logged in user', () => {
16
+ // Given I am on the login page and I am not logged in
17
+ LoginSteps.visitInProdMode();
18
+ LoginSteps.getLoginPage().should('be.visible');
19
+ // Then the license is not requested
20
+ cy.get('@get-license.all').should('have.length', 0);
21
+
22
+ // When I log in
23
+ LoginSteps.loginWithUser('admin', 'root');
24
+ // Then the license is requested
25
+ cy.wait('@get-license');
26
+
27
+ // When I reload the page
28
+ cy.reload();
29
+ // Then the license is requested again
30
+ cy.wait('@get-license');
31
+ });
32
+ });
33
+
34
+ context('when free access is on', () => {
35
+ beforeEach(() => {
36
+ cy.switchOnFreeAccess(true);
37
+ });
38
+
39
+ it('should load the license for the free access user and after each login state change', () => {
40
+ // When I open the login page without logging in
41
+ LoginSteps.visitInProdMode();
42
+ // Then the license is requested
43
+ cy.wait('@get-license');
44
+
45
+ // When I log in
46
+ HeaderSteps.login();
47
+ LoginSteps.loginWithUser('admin', 'root');
48
+ // Then the license is requested again
49
+ cy.wait('@get-license');
50
+
51
+ // When I log out
52
+ HeaderSteps.logout();
53
+ // Then the license is requested again for the free access user
54
+ cy.wait('@get-license');
55
+ });
56
+ });
57
+ });
@@ -0,0 +1,36 @@
1
+ import {LicenseStubs} from '../../../stubs/license-stubs';
2
+ import {LoginSteps} from '../../../steps/login-steps';
3
+ import {MainMenuSteps} from '../../../steps/main-menu-steps';
4
+ import ImportSteps from '../../../steps/import/import-steps';
5
+
6
+ Cypress.env('set_default_user_data', false);
7
+
8
+ describe('License on logout', () => {
9
+ beforeEach(() => {
10
+ cy.switchOnSecurity();
11
+ cy.loginAsAdmin();
12
+ LicenseStubs.spyGetLicense();
13
+ });
14
+
15
+ it('should not request the license when logging out from a legacy page', () => {
16
+ // Given I am logged in and I am on a legacy page
17
+ LoginSteps.visitInProdMode();
18
+ LoginSteps.loginWithUser('admin', 'root');
19
+ cy.wait('@get-license');
20
+ MainMenuSteps.clickOnMenuImport();
21
+ ImportSteps.getView().should('be.visible');
22
+ // And the license is not accessible without a session
23
+ LicenseStubs.stubLicenseUnauthorized();
24
+
25
+ // When I log out
26
+ LoginSteps.logout();
27
+ LoginSteps.getLoginPage().should('be.visible');
28
+ // And I log in again, which proves that the logout has been fully processed
29
+ LicenseStubs.spyGetLicense();
30
+ LoginSteps.loginWithUser('admin', 'root');
31
+ cy.wait('@get-license');
32
+
33
+ // Then no license request was sent without a session
34
+ cy.get('@unauthorizedLicense.all').should('have.length', 0);
35
+ });
36
+ });
@@ -133,7 +133,7 @@ describe('User Management – Creation, Validation, Permissions & Deletion', ()
133
133
  'ex:greeting ex:text "Hello, world!" .\n' +
134
134
  '}';
135
135
  cy.pasteIntoCodeMirror('.CodeMirror', prefix + query);
136
- YasqeSteps.executeQueryWithoutWaiteResult();
136
+ YasqeSteps.executeQueryWithoutWaitingForResult();
137
137
  // Verify read access
138
138
  YasrSteps.getResponseInfo()
139
139
  .should('not.have.class', 'hidden')
@@ -55,7 +55,7 @@ describe('Repository Admin – Permissions and Access Control', () => {
55
55
  'ex:greeting ex:text "Hello, world!" .\n' +
56
56
  '}';
57
57
  cy.pasteIntoCodeMirror('.CodeMirror', prefix + query);
58
- YasqeSteps.executeQueryWithoutWaiteResult();
58
+ YasqeSteps.executeQueryWithoutWaitingForResult();
59
59
  // Verify read access
60
60
  YasrSteps.getResponseInfo()
61
61
  .should('not.have.class', 'hidden')
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "graphdb-workbench-tests",
3
- "version": "4.0.0-TR19",
3
+ "version": "4.0.0-TR20",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "graphdb-workbench-tests",
9
- "version": "4.0.0-TR19",
9
+ "version": "4.0.0-TR20",
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-TR19",
3
+ "version": "4.0.0-TR20",
4
4
  "description": "Cypress tests for GraphDB workbench",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -3,12 +3,16 @@ export class HeaderSteps {
3
3
  return cy.get('onto-header');
4
4
  }
5
5
 
6
+ static getUserMenu() {
7
+ return HeaderSteps.getHeader().find('onto-user-menu');
8
+ }
9
+
6
10
  static openHomePage() {
7
11
  HeaderSteps.getHeader().find('.home-page').click();
8
12
  }
9
13
 
10
14
  static logout() {
11
- this.getHeader().find('onto-user-menu').click();
15
+ HeaderSteps.getUserMenu().click();
12
16
  cy.get('.onto-user-menu-dropdown')
13
17
  .contains('Logout')
14
18
  .first()
@@ -1,5 +1,6 @@
1
1
  import {ModalDialogSteps} from "../modal-dialog-steps";
2
2
 
3
+ const VIEW_URL = '/import';
3
4
  /**
4
5
  * Reusable functions for interacting with the import page.
5
6
  */
@@ -21,11 +22,15 @@ class ImportSteps {
21
22
  }
22
23
 
23
24
  static visit() {
24
- cy.visit('/import');
25
- cy.url().should('include', '/import');
25
+ cy.visit(VIEW_URL);
26
+ cy.url().should('include', VIEW_URL);
26
27
  cy.get('#wb-import h1').should('be.visible');
27
28
  }
28
29
 
30
+ static verifyUrl() {
31
+ cy.url().should('include', `${Cypress.config('baseUrl')}${VIEW_URL}`);
32
+ }
33
+
29
34
  static getView() {
30
35
  return cy.get('#wb-import');
31
36
  }
@@ -7,6 +7,10 @@ export class LanguageSelectorSteps {
7
7
  LanguageSelectorSteps.getLanguageSelectorDropdown().should('be.visible').click();
8
8
  }
9
9
 
10
+ static getLanguageSelectorDropdownButton() {
11
+ return LanguageSelectorSteps.getLanguageSelectorDropdown().getByTestId('onto-dropdown-button');
12
+ }
13
+
10
14
  static changeLanguage(language) {
11
15
  LanguageSelectorSteps.openLanguageSelectorDropdown();
12
16
  this.getLanguageSelectorDropdown().find(`button.${language}`).click();
@@ -1,12 +1,12 @@
1
1
  import {EnvironmentStubs} from "../stubs/environment-stubs";
2
-
2
+ const VIEW_URL = '/login';
3
3
  export class LoginSteps {
4
4
  static visitLoginPage() {
5
- cy.visit('/login');
5
+ cy.visit(VIEW_URL);
6
6
  }
7
7
 
8
8
  static visitInProdMode() {
9
- cy.visit('/login', {
9
+ cy.visit(VIEW_URL, {
10
10
  onBeforeLoad: () => {
11
11
  EnvironmentStubs.stubWbProdMode();
12
12
  }
@@ -18,6 +18,10 @@ export class LoginSteps {
18
18
  cy.visit(`/login?r=${returnURLEncoded}`);
19
19
  }
20
20
 
21
+ static verifyUrl() {
22
+ cy.url().should('include', `${Cypress.config('baseUrl')}${VIEW_URL}`);
23
+ }
24
+
21
25
  static getLoginPage() {
22
26
  return cy.get('app-login');
23
27
  }
@@ -64,8 +64,10 @@ export class YasqeSteps {
64
64
  .should('be.visible');
65
65
  }
66
66
 
67
- static executeQueryWithoutWaiteResult() {
67
+ static executeQueryWithoutWaitingForResult() {
68
68
  this.clickExecuteQueryButtonAndHideTooltip();
69
+ // Make sure that the query is executed before Cypress continues.
70
+ YasqeSteps.getAbortQueryButton().should('be.visible');
69
71
  }
70
72
 
71
73
  static executeErrorQuery() {
@@ -4,6 +4,10 @@ export class LicenseStubs {
4
4
  cy.intercept('GET', '/rest/graphdb-settings/license').as('get-license');
5
5
  }
6
6
 
7
+ static stubLicenseUnauthorized() {
8
+ cy.intercept('GET', '/rest/graphdb-settings/license', {statusCode: 401}).as('unauthorizedLicense');
9
+ }
10
+
7
11
  static stubFreeLicense() {
8
12
  cy.intercept('GET', '/rest/graphdb-settings/license', {
9
13
  statusCode: 200,
@@ -225,6 +225,11 @@ export class QueryStubs {
225
225
  static interceptSavedQueryCreation() {
226
226
  cy.intercept('POST', '/rest/sparql/saved-queries').as('saveQuery');
227
227
  }
228
+
229
+ static spyAbortQuery() {
230
+ cy.intercept('DELETE', /\/rest\/monitor\/repository\/[^/]+\/query\?query=yasgui-component-.*/)
231
+ .as('abortQuery');
232
+ }
228
233
  }
229
234
 
230
235
  export class QueryStubDescription {