graphdb-workbench-tests 3.1.0-TR2 → 3.1.0-TR4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphdb-workbench-tests",
3
- "version": "3.1.0-TR2",
3
+ "version": "3.1.0-TR4",
4
4
  "description": "Cypress tests for GraphDB workbench",
5
5
  "scripts": {
6
6
  "prepack": "npm shrinkwrap",
@@ -11,6 +11,7 @@
11
11
  "cy:run": "npm run cy:run-legacy && cypress run",
12
12
  "cy:run:partial": "cypress run --config-file cypress-legacy.config.js --spec \"e2e-legacy/**/jdbc-create.spec.js\" --browser chrome",
13
13
  "cy:run-legacy": "cypress run --config-file cypress-legacy.config.js --browser chrome",
14
+ "cy:run-legacy:coverage": "cypress run --config-file cypress-legacy.config.js --browser chrome",
14
15
  "cy:run-flaky": "cypress run --config-file cypress-flaky.config.js --browser chrome",
15
16
  "test": "npm run cy:run-legacy",
16
17
  "test:core": "cypress run --spec e2e-legacy/repository/**,e2e-legacy/import/**,e2e-legacy/sparql-editor/**,e2e-legacy/monitor/**,e2e-legacy/cluster/**,e2e-legacy/ttyg/**"
@@ -29,7 +30,9 @@
29
30
  "url": "git+https://github.com/Ontotext-AD/graphdb-workbench.git"
30
31
  },
31
32
  "devDependencies": {
32
- "cypress": "^14.5.0",
33
+ "@bahmutov/cypress-code-coverage": "^2.7.2",
34
+ "babel-plugin-istanbul": "^7.0.0",
35
+ "cypress": "14.5.1",
33
36
  "cypress-failed-log": "^2.10.0",
34
37
  "cypress-file-upload": "^5.0.8",
35
38
  "cypress-localstorage-commands": "^2.2.7",
@@ -38,6 +41,7 @@
38
41
  "cypress-terminal-report": "^7.2.0",
39
42
  "cypress-wait-until": "^3.0.2",
40
43
  "del": "^8.0.0",
44
+ "dotenv": "^17.0.1",
41
45
  "minimist": "^1.2.8",
42
46
  "mocha-junit-reporter": "^2.2.1"
43
47
  }
package/plugins/index.js CHANGED
@@ -95,4 +95,5 @@ module.exports = (on, config) => {
95
95
  printGroup('[FAIL] Broken tests', broken);
96
96
  console.log('====================================================================================================\n');
97
97
  });
98
+ return config;
98
99
  };
@@ -4,6 +4,7 @@ import {ActiveRepositoryWidgetSteps} from "./widgets/active-repository-widget-st
4
4
  import {SavedSparqlQueriesWidgetSteps} from "./widgets/saved-sparql-queries-widget-steps";
5
5
  import {RepositorySteps} from "./repository-steps";
6
6
  import {BaseSteps} from "./base-steps";
7
+ import {EnvironmentStubs} from "../stubs/environment-stubs";
7
8
 
8
9
  class HomeSteps extends BaseSteps {
9
10
 
@@ -12,6 +13,22 @@ class HomeSteps extends BaseSteps {
12
13
  HomeSteps.getTutorialPanel().should('be.visible');
13
14
  }
14
15
 
16
+ static visitInProdMode() {
17
+ cy.visit('/', {
18
+ onBeforeLoad: (win) => {
19
+ EnvironmentStubs.stubWbProdMode();
20
+ }
21
+ });
22
+ }
23
+
24
+ static visitInDevMode() {
25
+ cy.visit('/', {
26
+ onBeforeLoad: (win) => {
27
+ EnvironmentStubs.stubWbDevMode();
28
+ }
29
+ });
30
+ }
31
+
15
32
  static visitAndWaitLoader() {
16
33
  cy.visit('/');
17
34
  return cy.get('.ot-loader-new-content').should('not.exist');
@@ -1,8 +1,26 @@
1
+ import {EnvironmentStubs} from "../../stubs/environment-stubs";
2
+
1
3
  export class SettingsSteps {
2
4
  static visit() {
3
5
  cy.visit('/settings');
4
6
  }
5
7
 
8
+ static visitInProdMode() {
9
+ cy.visit('/settings', {
10
+ onBeforeLoad: (win) => {
11
+ EnvironmentStubs.stubWbProdMode();
12
+ }
13
+ });
14
+ }
15
+
16
+ static visitInDevMode() {
17
+ cy.visit('/settings', {
18
+ onBeforeLoad: (win) => {
19
+ EnvironmentStubs.stubWbDevMode();
20
+ }
21
+ });
22
+ }
23
+
6
24
  static getSettingsPage() {
7
25
  return cy.get('#wb-user');
8
26
  }
@@ -18,14 +18,4 @@ export class BrowserStubs {
18
18
  cy.spy(win.singleSpa, 'navigateToUrl').as(BrowserStubs.NAVIGATE_TO_URL_ALIAS(true))
19
19
  })
20
20
  }
21
-
22
- /**
23
- * Stubs `window.crypto.randomUUID` to return a specified UUID, because in headless mode the window cripto not exist.
24
- * @param uuid The UUID string to return each time `crypto.randomUUID()` is called.
25
- */
26
- static stubCryptoUUID(uuid = '999e8888-e77b-66d3-a456-426655440999') {
27
- cy.on('window:before:load', (win) => {
28
- win.crypto.randomUUID = () => uuid;
29
- });
30
- }
31
21
  }
@@ -1,5 +1,9 @@
1
1
  export class SecurityStubs {
2
2
 
3
+ static spyOnAuthenticatedUser() {
4
+ cy.intercept('/rest/security/authenticated-user').as('get-authenticated-user')
5
+ }
6
+
3
7
  static stubUserSecurity(infer = true, sameAs = true, userName = 'admin') {
4
8
  cy.intercept(`rest/security/users/${userName}`, (req) => {
5
9
  req.reply(SecurityStubs.getAdminResponse(infer, sameAs));
@@ -2,7 +2,7 @@ import {Stubs} from "../stubs";
2
2
 
3
3
  export class TTYGStubs extends Stubs {
4
4
  static stubChatsListGet(fixture = '/ttyg/chats/get-chat-list.json', delay = 0) {
5
- cy.intercept('GET', '/rest/chat/conversations', {
5
+ cy.intercept('GET', '/rest/ttyg/chats', {
6
6
  fixture: fixture,
7
7
  statusCode: 200,
8
8
  delay: delay
@@ -10,7 +10,7 @@ export class TTYGStubs extends Stubs {
10
10
  }
11
11
 
12
12
  static stubChatListGetError() {
13
- cy.intercept('GET', '/rest/chat/conversations', {
13
+ cy.intercept('GET', '/rest/ttyg/chats', {
14
14
  statusCode: 500,
15
15
  response: {
16
16
  error: 'Internal Server Error'
@@ -19,7 +19,7 @@ export class TTYGStubs extends Stubs {
19
19
  }
20
20
 
21
21
  static stubChatsListGetNoResults() {
22
- cy.intercept('GET', '/rest/chat/conversations', {
22
+ cy.intercept('GET', '/rest/ttyg/chats', {
23
23
  fixture: '/ttyg/chats/get-chat-list-0.json',
24
24
  statusCode: 200
25
25
  }).as('get-chat-list');
@@ -34,7 +34,7 @@ export class TTYGStubs extends Stubs {
34
34
  cy.fixture('/ttyg/chats/get-chat.json').then((body) => {
35
35
  cy.intercept({
36
36
  method: 'GET',
37
- url: '/rest/chat/conversations/*'
37
+ url: '/rest/ttyg/chats/*'
38
38
  }, (req) => {
39
39
  const chatId = req.url.split('/').pop();
40
40
  const chat = body[chatId];
@@ -49,7 +49,7 @@ export class TTYGStubs extends Stubs {
49
49
  }
50
50
 
51
51
  static stubChatGet404Error() {
52
- cy.intercept('GET', '/rest/chat/conversations/*', {
52
+ cy.intercept('GET', '/rest/ttyg/chats/*', {
53
53
  statusCode: 404,
54
54
  response: {
55
55
  error: 'Not Found'
@@ -58,28 +58,28 @@ export class TTYGStubs extends Stubs {
58
58
  }
59
59
 
60
60
  static stubChatUpdate() {
61
- cy.intercept('PUT', '/rest/chat/conversations/*', {
61
+ cy.intercept('PUT', '/rest/ttyg/chats/*', {
62
62
  fixture: '/ttyg/chats/renamed-chat.json',
63
63
  statusCode: 200
64
64
  }).as('update-chat');
65
65
  }
66
66
 
67
67
  static stubChatDelete() {
68
- cy.intercept('DELETE', '/rest/chat/conversations/*', {
68
+ cy.intercept('DELETE', '/rest/ttyg/chats/*', {
69
69
  fixture: '/ttyg/chats/deleted-chat.json',
70
70
  statusCode: 200
71
71
  }).as('delete-chat');
72
72
  }
73
73
 
74
74
  static stubChatExport() {
75
- cy.intercept('GET', '/rest/chat/conversations/export/*', {
75
+ cy.intercept('GET', '/rest/ttyg/chats/export/*', {
76
76
  fixture: '/ttyg/chats/export-chat.json',
77
77
  statusCode: 200
78
78
  }).as('export-chat');
79
79
  }
80
80
 
81
81
  static stubAgentListGet(fixture = '/ttyg/agent/get-agent-list.json', delay = 0) {
82
- cy.intercept('GET', '/rest/chat/agents', {
82
+ cy.intercept('GET', '/rest/ttyg/agents', {
83
83
  fixture: fixture,
84
84
  statusCode: 200,
85
85
  delay: delay
@@ -91,7 +91,7 @@ export class TTYGStubs extends Stubs {
91
91
  }
92
92
 
93
93
  static stubAgentGet(fixture = '/ttyg/agent/get-agent.json', delay = 0) {
94
- cy.intercept('GET', '/rest/chat/agents/*', {
94
+ cy.intercept('GET', '/rest/ttyg/agents/*', {
95
95
  fixture: fixture,
96
96
  statusCode: 200,
97
97
  delay: delay
@@ -99,7 +99,7 @@ export class TTYGStubs extends Stubs {
99
99
  }
100
100
 
101
101
  static stubAgentListGetError() {
102
- cy.intercept('GET', '/rest/chat/agents', {
102
+ cy.intercept('GET', '/rest/ttyg/agents', {
103
103
  statusCode: 500,
104
104
  response: {
105
105
  error: 'Internal Server Error'
@@ -108,7 +108,7 @@ export class TTYGStubs extends Stubs {
108
108
  }
109
109
 
110
110
  static stubAgentCreate(delay = 0) {
111
- cy.intercept('POST', '/rest/chat/agents', {
111
+ cy.intercept('POST', '/rest/ttyg/agents', {
112
112
  fixture: '/ttyg/agent/create-agent.json',
113
113
  statusCode: 200,
114
114
  delay: delay
@@ -118,7 +118,7 @@ export class TTYGStubs extends Stubs {
118
118
  static stubAgentEdit() {
119
119
  cy.intercept({
120
120
  method: 'PUT',
121
- url: '/rest/chat/agents'
121
+ url: '/rest/ttyg/agents'
122
122
  }, (req) => {
123
123
  const requestBody = req.body;
124
124
  req.reply({
@@ -129,21 +129,21 @@ export class TTYGStubs extends Stubs {
129
129
  }
130
130
 
131
131
  static stubAgentDelete(delay = 0) {
132
- cy.intercept('DELETE', '/rest/chat/agents/**', {
132
+ cy.intercept('DELETE', '/rest/ttyg/agents/**', {
133
133
  statusCode: 200,
134
134
  delay: delay
135
135
  }).as('delete-agent');
136
136
  }
137
137
 
138
138
  static stubAgentDefaultsGet() {
139
- cy.intercept('GET', '/rest/chat/agents/default', {
139
+ cy.intercept('GET', '/rest/ttyg/agents/default', {
140
140
  fixture: '/ttyg/agent/get-agent-defaults.json',
141
141
  statusCode: 200
142
142
  }).as('get-agent-defaults');
143
143
  }
144
144
 
145
145
  static stubAnswerQuestion(fixture = '/ttyg/chats/ask-question.json') {
146
- cy.intercept('POST', '/rest/chat/conversations', {
146
+ cy.intercept('POST', '/rest/ttyg/chats', {
147
147
  fixture,
148
148
  statusCode: 200
149
149
  }).as('get-agent-defaults');
@@ -153,7 +153,7 @@ export class TTYGStubs extends Stubs {
153
153
  cy.fixture(fixture).then((fixtureData) => {
154
154
  const today = Math.floor(Date.now() / 1000) + '';
155
155
  const body = JSON.stringify(fixtureData).replace(/"creationDate"/g, today);
156
- cy.intercept('POST', '/rest/chat/conversations', {
156
+ cy.intercept('POST', '/rest/ttyg/chats', {
157
157
  statusCode: 200,
158
158
  body: JSON.parse(body)
159
159
  }).as('create-chat');
@@ -162,7 +162,7 @@ export class TTYGStubs extends Stubs {
162
162
  }
163
163
 
164
164
  static stubExplainResponse(fixture = '/ttyg/chats/explain-response-1.json') {
165
- cy.intercept('POST', 'rest/chat/conversations/explain', {
165
+ cy.intercept('POST', 'rest/ttyg/chats/explain', {
166
166
  fixture,
167
167
  statusCode: 200
168
168
  }).as('explain-response');
package/support/e2e.js CHANGED
@@ -23,6 +23,8 @@ import 'cypress-real-events';
23
23
  import 'cypress-file-upload';
24
24
  import {LicenseStubs} from "../stubs/license-stubs";
25
25
  import {SecurityStubs} from "../stubs/security-stubs";
26
+ // https://github.com/bahmutov/cypress-code-coverage
27
+ require('@bahmutov/cypress-code-coverage/support');
26
28
 
27
29
  // Configures an environment variable with the key used for common actions (cmd on mac, ctrl on other OS).
28
30
  // This variable must be used in all actions that type e.g. ctrl-a to select text.
@@ -44,6 +46,5 @@ beforeEach(() => {
44
46
  // for some reason.
45
47
  // It'll be good to investigate it a bit sometime.
46
48
  SecurityStubs.stubGetAdminUser();
47
- // SecurityStubs.stubUpdateUserData('admin');
48
49
  }
49
50
  });
@@ -1,67 +0,0 @@
1
- import {RepositoriesStubs} from "../../stubs/repositories/repositories-stubs";
2
- import {RepositoriesStub} from "../../stubs/repositories-stub";
3
- import {UserAndAccessSteps} from "../../steps/setup/user-and-access-steps";
4
- import {TTYGStubs} from "../../stubs/ttyg/ttyg-stubs";
5
- import {TTYGViewSteps} from "../../steps/ttyg/ttyg-view-steps";
6
- import {LoginSteps} from "../../steps/login-steps";
7
-
8
- const USER_WITH_ROLE_USER = 'ttyg_user';
9
- const USER_WITH_ROLE_REPO_MANAGER = 'ttyg_repo_manager';
10
- const USER_ADMINISTRATOR = 'admin';
11
- const PASSWORD = 'root';
12
- const ENABLED = true;
13
- const DISABLED = false;
14
-
15
- describe('TTYG permissions', () => {
16
-
17
-
18
- before(() => {
19
- RepositoriesStubs.stubRepositories(0, '/repositories/get-ttyg-repositories.json');
20
- RepositoriesStub.stubBaseEndpoints('starwars');
21
- cy.presetRepository('starwars');
22
- cy.createUser({username: USER_WITH_ROLE_USER, password: PASSWORD});
23
- cy.createUser({
24
- username: USER_WITH_ROLE_REPO_MANAGER,
25
- password: PASSWORD,
26
- grantedAuthorities: ["ROLE_REPO_MANAGER", "WRITE_REPO_*", "READ_REPO_*"]
27
- });
28
- UserAndAccessSteps.visit();
29
- UserAndAccessSteps.toggleSecurity();
30
- });
31
-
32
- after(() => {
33
- UserAndAccessSteps.visit();
34
- LoginSteps.loginWithUser(USER_ADMINISTRATOR, PASSWORD);
35
- UserAndAccessSteps.toggleSecurity();
36
- cy.deleteUser(USER_WITH_ROLE_USER);
37
- cy.deleteUser(USER_WITH_ROLE_REPO_MANAGER);
38
- });
39
-
40
- it('should disable all buttons that can modify the agent', () => {
41
-
42
- // When I log in with a user who has the ROLE_USER role, I expect all buttons modifying the agent to be disabled.
43
- verifyCanCreateAgentForFirstTime(USER_WITH_ROLE_USER, PASSWORD, DISABLED);
44
-
45
- // When I log in with a user who has the ROLE_REPO_MANAGER role, I expect all buttons modifying the agent to be enabled.
46
- verifyCanCreateAgentForFirstTime(USER_WITH_ROLE_REPO_MANAGER, PASSWORD, ENABLED);
47
-
48
- // When I log in with a user who is administrator, I expect all buttons modifying the agent to be enabled.
49
- verifyCanCreateAgentForFirstTime(USER_ADMINISTRATOR, PASSWORD, ENABLED);
50
- });
51
-
52
- function verifyCanCreateAgentForFirstTime(user, password, enable) {
53
- const shouldBe = enable ? 'be.enabled' : 'be.disabled';
54
- TTYGStubs.stubAgentListGet('/ttyg/agent/get-agent-list-0.json');
55
- TTYGViewSteps.visit();
56
- LoginSteps.loginWithUser(user, password);
57
- TTYGViewSteps.getCreateFirstAgentButton().should(shouldBe);
58
- TTYGStubs.stubChatsListGet();
59
- TTYGStubs.stubAgentListGet();
60
- TTYGStubs.stubChatGet();
61
- TTYGViewSteps.visit();
62
- TTYGViewSteps.getCreateAgentButton().should(shouldBe);
63
- TTYGViewSteps.getEditCurrentAgentButton().should(shouldBe);
64
- TTYGViewSteps.getToggleAgentsSidebarButton().should(shouldBe);
65
- LoginSteps.logout();
66
- }
67
- });