graphdb-workbench-tests 3.1.0-TR3 → 3.1.0-TR5

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-TR3",
3
+ "version": "3.1.0-TR5",
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
  }
@@ -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));
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
- });