graphdb-workbench-tests 2.0.0-TR7 → 2.0.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.
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "graphdb-workbench-tests",
3
- "version": "2.0.0-TR7",
3
+ "version": "2.0.0",
4
4
  "description": "Cypress tests for GraphDB workbench",
5
5
  "scripts": {
6
6
  "start": "cypress open",
7
- "test": "cypress run"
7
+ "test": "cypress run",
8
+ "test:partial": "cypress run --spec \"integration/repository/**\""
8
9
  },
9
10
  "author": {
10
11
  "name": "\"Sirma AI\" JSC, trading as Ontotext",
@@ -23,6 +24,7 @@
23
24
  "cypress": "^7.3.0",
24
25
  "cypress-failed-log": "^2.5.1",
25
26
  "cypress-localstorage-commands": "^1.4.4",
27
+ "cypress-terminal-report": "^4.0.1",
26
28
  "cypress-wait-until": "^1.7.1"
27
29
  },
28
30
  "bin": {
package/plugins/index.js CHANGED
@@ -17,4 +17,13 @@ module.exports = (on, config) => {
17
17
  on('task', {
18
18
  failed: require('cypress-failed-log/src/failed')()
19
19
  });
20
+
21
+ require('cypress-terminal-report/src/installLogsPrinter')(on, {
22
+ logToFilesOnAfterRun: true,
23
+ printLogsToConsole: 'onFail',
24
+ outputRoot: config.projectRoot + '/logs/',
25
+ outputTarget: {
26
+ 'cypress-logs|txt': 'txt'
27
+ }
28
+ });
20
29
  };
@@ -160,5 +160,21 @@ class HomeSteps {
160
160
  .and('be.focused');
161
161
  }
162
162
 
163
+ static getViewResourceAsLabel() {
164
+ return cy.get('#view-resource-label-home');
165
+ }
166
+
167
+ static getActiveRepoAsLabel() {
168
+ return cy.get('#active-repo-label-home');
169
+ }
170
+
171
+ static getSavedSparqlQueriesAsLabel() {
172
+ return cy.get('#saved-queries-label-home');
173
+ }
174
+
175
+ static getLicenseAsLabel() {
176
+ return cy.get('#license-label-home');
177
+ }
178
+
163
179
  }
164
180
  export default HomeSteps;
@@ -0,0 +1,154 @@
1
+ class SparqlSteps {
2
+
3
+ static changeLanguage(language) {
4
+ // Change the language
5
+ cy.get('#languageGroupDrop').should('be.visible').click();
6
+ cy.get('#lang-select-' + language).click();
7
+ }
8
+
9
+ static createRepoAndVisit(repositoryId, repoOptions = {}) {
10
+ this.createRepository(repositoryId, repoOptions);
11
+ this.visitSparql(true, repositoryId);
12
+ }
13
+
14
+ static createRepository(repositoryId, repoOptions = {}) {
15
+ repoOptions.id = repositoryId;
16
+ cy.createRepository(repoOptions);
17
+ cy.initializeRepository(repositoryId);
18
+ }
19
+
20
+ static waitUntilSparqlPageIsLoaded() {
21
+ cy.window();
22
+ // Workbench loading screen should not be visible
23
+ cy.get('.ot-splash').should('not.be.visible');
24
+
25
+ // Run query button should be clickable
26
+ this.getRunQueryButton().should('be.visible').and('not.be.disabled');
27
+
28
+ this.waitUntilQueryIsVisible();
29
+
30
+ // Run query button should be clickable
31
+ this.getRunQueryButton().should('be.visible').and('not.be.disabled');
32
+
33
+ // Editor should have a visible tab
34
+ this.getTabs().find('.nav-link').should('be.visible');
35
+
36
+ // No active loader
37
+ this.getLoader().should('not.exist');
38
+ }
39
+
40
+ static visitSparql(resetLocalStorage, repositoryId) {
41
+ cy.visit('/sparql', {
42
+ onBeforeLoad: (win) => {
43
+ if (resetLocalStorage) {
44
+ // Needed because the workbench app is very persistent with its local storage (it's hooked on before unload event)
45
+ // TODO: Add a test that tests this !
46
+ if (win.localStorage) {
47
+ win.localStorage.clear();
48
+ }
49
+ if (win.sessionStorage) {
50
+ win.sessionStorage.clear();
51
+ }
52
+ }
53
+ win.localStorage.setItem('com.ontotext.graphdb.repository', repositoryId);
54
+ }
55
+ });
56
+ this.waitUntilSparqlPageIsLoaded();
57
+ }
58
+
59
+ static getLoader() {
60
+ return cy.get('.ot-loader-new-content');
61
+ }
62
+
63
+ static executeQuery() {
64
+ this.getRunQueryButton().click();
65
+ this.getLoader().should('not.exist');
66
+ }
67
+
68
+ static getRunQueryButton() {
69
+ return cy.get('#wb-sparql-runQuery');
70
+ }
71
+
72
+ static getQueryArea() {
73
+ return cy.get('#queryEditor .CodeMirror');
74
+ }
75
+
76
+ static waitUntilQueryIsVisible() {
77
+ return cy.waitUntil(() =>
78
+ this.getQueryArea()
79
+ .then(codeMirrorEl =>
80
+ codeMirrorEl && codeMirrorEl[0].CodeMirror.getValue().trim().length > 0));
81
+ }
82
+
83
+ static getTabs() {
84
+ return cy.get('#sparql-content .nav-tabs .sparql-tab');
85
+ }
86
+
87
+ static getSavedQueriesPopupBtn() {
88
+ return cy.get('#wb-sparql-toggleSampleQueries');
89
+ }
90
+
91
+ static openSavedQueriesPopup() {
92
+ this.getSavedQueriesPopupBtn().click();
93
+ }
94
+
95
+ static getPopover() {
96
+ return cy.get('.popover')
97
+ .should('not.have.class', 'ng-animate')
98
+ .and('not.have.class', 'in-add')
99
+ .and('not.have.class', 'in-add-active');
100
+ }
101
+
102
+ static getSavedQueryFromPopup(savedQueryName) {
103
+ return cy.get('#wb-sparql-queryInSampleQueries')
104
+ .contains(savedQueryName)
105
+ .closest('.saved-query');
106
+ }
107
+
108
+ static selectSavedQuery(savedQueryName) {
109
+ this.openSavedQueriesPopup();
110
+ this.getPopover().should('be.visible');
111
+ this.getSavedQueryFromPopup(savedQueryName)
112
+ .find('a')
113
+ // the popup is opened and the link with the text is visible but cypress think it's 0x0px width/height
114
+ .click({force: true});
115
+ }
116
+
117
+ static getSparqlQueryUpdateLabel() {
118
+ return cy.get('#sparql-query-update-title-label');
119
+ }
120
+
121
+ static getDownloadBtn() {
122
+ return cy.get('#saveAsBtn');
123
+ }
124
+
125
+ static getEditorAndResultsBtn() {
126
+ return cy.get('.editor-and-results-btn');
127
+ }
128
+
129
+ static getResultsOnlyBtn() {
130
+ return cy.get('.results-only-btn');
131
+ }
132
+
133
+ static getTabWithTableText() {
134
+ return cy.get('.select_table');
135
+ }
136
+
137
+ static getTabWithRawResponseText() {
138
+ return cy.get('.select_rawResponse');
139
+ }
140
+
141
+ static getTabWithPivotTableText() {
142
+ return cy.get('.select_pivot');
143
+ }
144
+
145
+ static getTabWithGoogleChartText() {
146
+ return cy.get('.select_gchart');
147
+ }
148
+
149
+ static getResultsDescription() {
150
+ return cy.get('.results-description');
151
+ }
152
+ }
153
+
154
+ export default SparqlSteps;
@@ -1,7 +1,8 @@
1
1
  import snippetImportTemplate from '../fixtures/snippet-import-template.json';
2
2
 
3
- const UPLOAD_URL = '/rest/data/import/upload/';
4
- const SERVER_IMPORT_URL = '/rest/data/import/server/';
3
+ const REPOSITORIES_URL = '/rest/repositories/';
4
+ const UPLOAD_URL = '/import/upload/';
5
+ const SERVER_URL = '/import/server/';
5
6
  const POLL_INTERVAL = 200;
6
7
 
7
8
  Cypress.Commands.add('importRDFTextSnippet', (repositoryId, rdf, importSettings = {}) => {
@@ -10,7 +11,8 @@ Cypress.Commands.add('importRDFTextSnippet', (repositoryId, rdf, importSettings
10
11
 
11
12
  cy.request({
12
13
  method: 'POST',
13
- url: UPLOAD_URL + repositoryId + '/text',
14
+ //url: UPLOAD_URL + repositoryId + '/text',
15
+ url: REPOSITORIES_URL + repositoryId + UPLOAD_URL + '/text',
14
16
  body: importData
15
17
  }).should((response) => expect(response.status).to.equal(202));
16
18
  waitServerOperation(UPLOAD_URL, repositoryId, importData.name);
@@ -24,16 +26,16 @@ Cypress.Commands.add('importServerFile', (repositoryId, fileName, importSettings
24
26
 
25
27
  cy.request({
26
28
  method: 'POST',
27
- url: SERVER_IMPORT_URL + repositoryId,
29
+ url: REPOSITORIES_URL + repositoryId + SERVER_URL,
28
30
  body: importData
29
31
  }).should((response) => expect(response.status).to.equal(202));
30
- waitServerOperation(SERVER_IMPORT_URL, repositoryId, fileName);
32
+ waitServerOperation(SERVER_URL, repositoryId, fileName);
31
33
  });
32
34
 
33
35
  function waitServerOperation(url, repositoryId, fileName) {
34
36
  cy.request({
35
37
  method: 'GET',
36
- url: url + repositoryId,
38
+ url: REPOSITORIES_URL + repositoryId + url
37
39
  }).then((response) => {
38
40
  const importStatus = Cypress._.find(response.body, (importStatus) => importStatus.name === fileName);
39
41
  if (importStatus.status === 'DONE') {
package/support/index.js CHANGED
@@ -24,3 +24,5 @@ import './commands';
24
24
  Cypress.env('modifierKey', Cypress.platform === 'darwin' ? '{cmd}' : '{ctrl}');
25
25
 
26
26
  require('cypress-failed-log');
27
+ require('cypress-terminal-report/src/installLogsCollector')();
28
+
@@ -8,7 +8,7 @@ Cypress.Commands.add('setDefaultUserData', () => {
8
8
  };
9
9
  cy.request({
10
10
  method: 'PATCH',
11
- url: `rest/security/user/${encodeURIComponent('admin')}`,
11
+ url: `rest/security/users/${encodeURIComponent('admin')}`,
12
12
  headers: {
13
13
  'X-GraphDB-Password': 'root'
14
14
  },
@@ -1,7 +1,7 @@
1
1
  Cypress.Commands.add('pasteQuery', (query) => {
2
2
  clearQuery();
3
3
  // Using force because the textarea is not visible
4
- getQueryTextArea().invoke('val', query).trigger('change', {force: true});
4
+ getQueryTextArea().invoke('val', query).trigger('change', {force: true}).should('have.value', query);
5
5
  waitUntilQueryIsVisible();
6
6
  });
7
7
 
@@ -19,9 +19,7 @@ Cypress.Commands.add('verifyResultsPageLength', (resultLength) => {
19
19
  Cypress.Commands.add('verifyResultsMessage', (msg) => {
20
20
  cy.waitUntil(() =>
21
21
  getResultsMessage()
22
- .then((resultInfo) => {
23
- console.log(resultInfo.text());
24
- return resultInfo && resultInfo.text().trim().indexOf(msg) > -1; }));
22
+ .then((resultInfo) => resultInfo && resultInfo.text().trim().indexOf(msg) > -1));
25
23
  });
26
24
 
27
25
  Cypress.Commands.add('getResultsMessage', () => {
@@ -53,7 +51,7 @@ function getQueryTextArea() {
53
51
  }
54
52
 
55
53
  function waitUntilQueryIsVisible() {
56
- cy.waitUntil(() =>
54
+ return cy.waitUntil(() =>
57
55
  getQueryArea()
58
56
  .then(codeMirrorEl =>
59
57
  codeMirrorEl && codeMirrorEl[0].CodeMirror.getValue().trim().length > 0));
@@ -1,135 +0,0 @@
1
- describe('Import/ OntoRefine', () => {
2
-
3
- let repositoryId;
4
-
5
- beforeEach(() => {
6
- repositoryId = 'onto-refine-' + Date.now();
7
- cy.createRepository({id: repositoryId});
8
-
9
- cy.visit('/ontorefine');
10
- cy.window();
11
-
12
- cy.get('.ot-splash').should('not.exist');
13
- getOntoRefineFrame().should('be.visible');
14
- });
15
-
16
- afterEach(() => {
17
- cy.deleteRepository(repositoryId);
18
- });
19
-
20
- const REFINE_TABS = ['Create Project', 'Open Project', 'Import Project', 'Language Settings'];
21
- const CREATE_PROJECT_TABS = ['This Computer', 'Web Addresses (URLs)', 'Clipboard'];
22
-
23
- xit('should properly render OntoRefine transformation tool frame', () => {
24
-
25
- // Refine should provide navigation tabs
26
- getOntoRefineTabs()
27
- .should('be.visible')
28
- .and('have.length', 4)
29
- .each(($tab, $index) => expect($tab.text()).to.equal(REFINE_TABS[$index]))
30
- .eq(0)
31
- // The first tab should be automatically selected
32
- .should('have.class', 'selected')
33
- .and('be.visible');
34
-
35
- // -------- Create project --------
36
-
37
- // The create project panel should be rendered by default and provide its own tabs
38
- getCreateProjectPanel().should('be.visible');
39
- getCreateProjectPanelTabs()
40
- .should('be.visible')
41
- .and('have.length', 3)
42
- .each(($tab, $index) => expect($tab.text()).to.equal(CREATE_PROJECT_TABS[$index]))
43
- .eq(0)
44
- .should('have.class', 'selected')
45
- .and('be.visible');
46
-
47
- // The upload panel should be opened by default
48
- getCreateProjectPanelBody()
49
- .find('.upload-parent #upload')
50
- .should('be.visible');
51
-
52
- // Go to URL panel
53
- getCreateProjectPanelTabs().eq(1).click();
54
- getCreateProjectPanelBody()
55
- .find('.default-importing-web-url')
56
- .should('be.visible');
57
-
58
- // Go to Clipboard panel
59
- getCreateProjectPanelTabs().eq(2).click();
60
- getCreateProjectPanelBody()
61
- .find('#default-importing-clipboard-textarea')
62
- .should('be.visible');
63
-
64
- // -------- Open project --------
65
-
66
- // Go to Open project and check if the panels are properly switched
67
- getOntoRefineTabs().eq(1).click();
68
- getCreateProjectPanel().should('not.exist');
69
- getOpenProjectPanel()
70
- .should('be.visible')
71
- // Should have no existing projects for new repositories
72
- .find('#no-project-message')
73
- .should('be.visible');
74
-
75
- // -------- Import project --------
76
-
77
- getOntoRefineTabs().eq(2).click();
78
- getOpenProjectPanel().should('not.exist');
79
- getImportProjectPanel()
80
- .should('be.visible')
81
- .find('#import-project-button')
82
- .should('be.visible');
83
-
84
- // -------- Language Settings --------
85
-
86
- getOntoRefineTabs().eq(3).click();
87
- getImportProjectPanel().should('not.exist');
88
- getLanguageSettingsPanel()
89
- .should('be.visible')
90
- .find('#set-lang-button')
91
- .should('be.visible');
92
- });
93
-
94
- function getOntoRefineFrame() {
95
- return cy.get('#ontorefine-iframe').iframe();
96
- }
97
-
98
- function getOntoRefineLeftPanel() {
99
- return getOntoRefineFrame().find('#left-panel');
100
- }
101
-
102
- function getOntoRefineTabs() {
103
- return getOntoRefineLeftPanel().find('#action-area-tabs .action-area-tab');
104
- }
105
-
106
- function getOntoRefineRightPanel() {
107
- return getOntoRefineFrame().find('#right-panel');
108
- }
109
-
110
- function getCreateProjectPanel() {
111
- return getOntoRefineRightPanel().find('#create-project-ui-source-selection-layout');
112
- }
113
-
114
- function getCreateProjectPanelTabs() {
115
- return getCreateProjectPanel().find('#create-project-ui-source-selection-tabs .create-project-ui-source-selection-tab')
116
- }
117
-
118
- function getCreateProjectPanelBody() {
119
- return getCreateProjectPanel().find('#create-project-ui-source-selection-tab-bodies')
120
- }
121
-
122
- function getOpenProjectPanel() {
123
- return getOntoRefineRightPanel().find('#projects-container');
124
- }
125
-
126
- function getImportProjectPanel() {
127
- // TODO Note: The third and fourth tab bodies have the same identifier....
128
- return getOntoRefineRightPanel().find('.action-area-tab-body').eq(2);
129
- }
130
-
131
- function getLanguageSettingsPanel() {
132
- return getOntoRefineRightPanel().find('.action-area-tab-body').eq(3);
133
- }
134
-
135
- });