graphdb-workbench-tests 4.0.0-TR4 → 4.0.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": "4.0.0-TR4",
3
+ "version": "4.0.0-TR5",
4
4
  "description": "Cypress tests for GraphDB workbench",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -218,64 +218,4 @@ export class YasqeSteps {
218
218
  static getActionButton(index) {
219
219
  return YasqeSteps.getActionButtons().eq(index);
220
220
  }
221
-
222
- static getRunSplitButton() {
223
- return YasqeSteps.getYasqe().find('query-split-button');
224
- }
225
-
226
- static getRunSplitButtonToggle() {
227
- return YasqeSteps.getRunSplitButton().find('.yasqe_querySplitToggle');
228
- }
229
-
230
- static openRunDropdown() {
231
- YasqeSteps.getRunSplitButtonToggle().click({scrollBehavior: false});
232
- }
233
-
234
- static getRunDropdownMenu() {
235
- return YasqeSteps.getRunSplitButton().find('.ontotext-run-dropdown-menu');
236
- }
237
-
238
- static getRunDropdownItems() {
239
- return YasqeSteps.getRunDropdownMenu().find('.ontotext-run-dropdown-menu-item');
240
- }
241
-
242
- static getRunDropdownItem(index) {
243
- return YasqeSteps.getRunDropdownItems().eq(index);
244
- }
245
-
246
- static selectRunDropdownItem(index) {
247
- YasqeSteps.openRunDropdown();
248
- YasqeSteps.getRunDropdownItem(index).click({scrollBehavior: false});
249
- // Hides the tooltip of the split button, which otherwise stays visible and overlaps both
250
- // the run button and the toggle itself. The mouseleave has to be forced, because the
251
- // tooltip covers the very element it is triggered on, which fails Cypress's actionability
252
- // check. This mirrors YasqeSteps.clickExecuteQueryButtonAndHideTooltip.
253
- YasqeSteps.getRunSplitButtonToggle().trigger('mouseleave', {force: true});
254
- }
255
-
256
- static executeExplainQueryPlan() {
257
- YasqeSteps.selectRunDropdownItem(RunDropdownOption.EXPLAIN_PLAN);
258
- }
259
-
260
- static executeLlmExplainAll() {
261
- YasqeSteps.selectRunDropdownItem(RunDropdownOption.LLM_EXPLAIN_ALL);
262
- }
263
-
264
- static executeLlmExplainQuery() {
265
- YasqeSteps.selectRunDropdownItem(RunDropdownOption.LLM_EXPLAIN_QUERY);
266
- }
267
-
268
- static executeLlmExplainResults() {
269
- YasqeSteps.selectRunDropdownItem(RunDropdownOption.LLM_EXPLAIN_RESULTS);
270
- }
271
221
  }
272
-
273
- /**
274
- * The order of the options in the run dropdown of the query split button.
275
- */
276
- export const RunDropdownOption = {
277
- 'EXPLAIN_PLAN': 0,
278
- 'LLM_EXPLAIN_ALL': 1,
279
- 'LLM_EXPLAIN_QUERY': 2,
280
- 'LLM_EXPLAIN_RESULTS': 3
281
- };
@@ -135,21 +135,6 @@ export class YasrSteps extends BaseSteps {
135
135
  return YasrSteps.getYasr().find('.dataTables_wrapper');
136
136
  }
137
137
 
138
- static getExplainPlanPlugin() {
139
- return YasrSteps.getYasr().find('.yasr-explain-plan-plugin');
140
- }
141
-
142
- /**
143
- * While an explain plan is rendered, the regular yasr header is replaced with a plain title.
144
- */
145
- static getExplainPlanHeader() {
146
- return YasrSteps.getYasr().find('.yasr-header-replacement');
147
- }
148
-
149
- static getExplainPlan() {
150
- return YasrSteps.getExplainPlanPlugin().find('.explainPlanQuery');
151
- }
152
-
153
138
  static getFullscreenButton() {
154
139
  return cy.get('.yasr-fullscreen-button');
155
140
  }
@@ -20,6 +20,10 @@ export class RepositoriesStubs extends Stubs {
20
20
  cy.intercept('GET', '/rest/locations/active').as('getActiveLocations');
21
21
  }
22
22
 
23
+ static spyGetRepository(id) {
24
+ cy.intercept(`GET`, `${REPOSITORIES_URL}/${id}?location=`).as('getRepository');
25
+ }
26
+
23
27
  static stubLocations(withDelay = 0) {
24
28
  RepositoriesStubs.stubQueryResponse('/rest/locations', '/repositories/get-locations.json', 'get-locations', withDelay);
25
29
  }
@@ -225,25 +225,6 @@ export class QueryStubs {
225
225
  static interceptSavedQueryCreation() {
226
226
  cy.intercept('POST', '/rest/sparql/saved-queries').as('saveQuery');
227
227
  }
228
-
229
- /**
230
- * Aliases the requests towards the repository endpoint, so that an explain plan query can be
231
- * told apart from a regular query and from the count query which yasgui sends for the
232
- * pagination. They all go to the same endpoint and can only be distinguished by their body.
233
- * @param {string} repositoryId - the repository against which the queries are executed.
234
- */
235
- static interceptQueries(repositoryId) {
236
- cy.intercept('POST', `/repositories/${repositoryId}`, (req) => {
237
- const body = typeof req.body === 'string' ? req.body : '';
238
- if (body.includes('count=1')) {
239
- req.alias = 'countQuery';
240
- } else if (body.includes('explain=true')) {
241
- req.alias = 'explainQuery';
242
- } else {
243
- req.alias = 'plainQuery';
244
- }
245
- });
246
- }
247
228
  }
248
229
 
249
230
  export class QueryStubDescription {
@@ -1,174 +0,0 @@
1
- import {SparqlEditorSteps} from "../../../steps/sparql-editor-steps";
2
- import {YasguiSteps} from "../../../steps/yasgui/yasgui-steps";
3
- import {YasqeSteps} from "../../../steps/yasgui/yasqe-steps";
4
- import {YasrSteps} from "../../../steps/yasgui/yasr-steps";
5
- import {ErrorPluginSteps} from "../../../steps/yasgui/plugin/error-plugin-steps";
6
- import {ToasterSteps} from "../../../steps/toaster-steps";
7
- import {QueryStubs} from "../../../stubs/yasgui/query-stubs";
8
- import {RepositoriesStubs} from "../../../stubs/repositories/repositories-stubs";
9
- import {AutocompleteStubs} from "../../../stubs/autocomplete/autocomplete-stubs";
10
-
11
- // GraphDB marks every explain plan response with this comment. Yasgui recognizes it and renders the
12
- // response with the explain plan plugin instead of the regular table one.
13
- const EXPLAIN_PLAN_MARKER = '# NOTE: Optimization groups';
14
- const EXPLAIN_PLAN_TITLE = 'Query explain plan';
15
- // Comments which the LLM explain actions prepend to the query in order to narrow down what the LLM
16
- // should explain.
17
- const LLM_QUERY_ONLY_COMMENT = '# :gpt-query-only:';
18
- const LLM_RESULT_ONLY_COMMENT = '# :gpt-result-only:';
19
-
20
- const SELECT_QUERY = 'SELECT * WHERE { ?s ?p ?o } LIMIT 10';
21
- const CONSTRUCT_QUERY = 'CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o } LIMIT 10';
22
- const DESCRIBE_QUERY = 'DESCRIBE <http://example.com/resource>';
23
- const UPDATE_QUERY = 'PREFIX : <http://bedrock/> INSERT DATA { :fred :hasSpouse :wilma. }';
24
-
25
- describe('Explain query plan', () => {
26
-
27
- let repositoryId;
28
-
29
- beforeEach(() => {
30
- repositoryId = 'sparql-editor-explain-plan-' + Date.now();
31
- cy.createRepository({id: repositoryId});
32
- cy.presetRepository(repositoryId);
33
- QueryStubs.interceptQueries(repositoryId);
34
-
35
- SparqlEditorSteps.visitSparqlEditorPageAndWaitForEditor();
36
- YasguiSteps.getYasgui().should('be.visible');
37
- YasqeSteps.getRunSplitButton().should('have.class', 'hydrated');
38
- YasqeSteps.pasteQuery(SELECT_QUERY);
39
- });
40
-
41
- afterEach(() => {
42
- cy.deleteRepository(repositoryId);
43
- });
44
-
45
- it('Should render the query plan when explain query plan is executed', () => {
46
- // Given I have opened the sparql editor with a select query
47
- // When I execute the explain query plan action
48
- YasqeSteps.executeExplainQueryPlan();
49
- // Then I expect the query to be sent as an explain plan query
50
- verifyExplainRequest('explain');
51
- // And I expect the plan to be rendered instead of the regular results
52
- YasrSteps.getExplainPlanHeader().should('be.visible').and('contain', EXPLAIN_PLAN_TITLE);
53
- YasrSteps.getExplainPlan().should('be.visible').and('contain', EXPLAIN_PLAN_MARKER);
54
- // And I expect no error to be reported
55
- ErrorPluginSteps.getErrorPlugin().should('not.exist');
56
- });
57
-
58
- it('Should allow explain query plan for construct and describe queries', () => {
59
- // Given I have opened the sparql editor
60
- // When I execute the explain query plan action for a construct query
61
- YasqeSteps.pasteQuery(CONSTRUCT_QUERY);
62
- YasqeSteps.executeExplainQueryPlan();
63
- // Then I expect the query to be accepted and sent as an explain plan query.
64
- verifyExplainRequest('explain');
65
- ErrorPluginSteps.getErrorPlugin().should('not.exist');
66
-
67
- // When I execute the explain query plan action for a describe query
68
- YasqeSteps.pasteQuery(DESCRIBE_QUERY);
69
- YasqeSteps.executeExplainQueryPlan();
70
- // Then I expect the query to be accepted and sent as an explain plan query
71
- verifyExplainRequest('explain');
72
- ErrorPluginSteps.getErrorPlugin().should('not.exist');
73
- });
74
-
75
- it('Should reset the explain plan mode when the query is executed again', () => {
76
- // Given I have executed an explain query plan
77
- YasqeSteps.executeExplainQueryPlan();
78
- cy.wait('@explainQuery');
79
- YasrSteps.getExplainPlanPlugin().should('be.visible');
80
-
81
- // When I execute the query with the run button
82
- YasqeSteps.executeQuery();
83
- // Then I expect a regular query to be sent
84
- cy.wait('@plainQuery').then((interception) => {
85
- expect(interception.request.body).to.not.contain('explain=true');
86
- });
87
- // And I expect the results to be rendered with the regular plugin
88
- YasrSteps.getExplainPlanPlugin().should('not.exist');
89
- YasrSteps.getExtendedTablePlugin().should('be.visible');
90
- });
91
-
92
- it('Should not allow explain query plan for update queries', () => {
93
- // Given I have opened the sparql editor
94
- // When I execute the explain query plan action for an update query
95
- YasqeSteps.pasteQuery(UPDATE_QUERY);
96
- YasqeSteps.executeExplainQueryPlan();
97
- // Then I expect to be warned that explain works only with select, construct or describe
98
- ToasterSteps.getToasterMessage()
99
- .should('contain', 'Explain only works with SELECT, CONSTRUCT or DESCRIBE queries.');
100
- // And I expect no plan to be rendered
101
- YasrSteps.getExplainPlanPlugin().should('not.exist');
102
- });
103
-
104
- it('Should execute an explain request when LLM explain all is selected', () => {
105
- // Given I have opened the sparql editor with a select query
106
- // When I execute the LLM explain all action
107
- YasqeSteps.executeLlmExplainAll();
108
- // Then I expect a gpt explain request to be sent
109
- verifyExplainRequest('gpt');
110
- // And I expect the query to be sent without any of the LLM comments
111
- YasqeSteps.getQuery().should('not.contain', LLM_QUERY_ONLY_COMMENT);
112
- YasqeSteps.getQuery().should('not.contain', LLM_RESULT_ONLY_COMMENT);
113
- });
114
-
115
- it('Should execute an explain request when LLM explain query is selected', () => {
116
- // Given I have opened the sparql editor with a select query
117
- // When I execute the LLM explain query action
118
- YasqeSteps.executeLlmExplainQuery();
119
- // Then I expect a gpt explain request to be sent
120
- verifyExplainRequest('gpt');
121
- // And I expect the query to be marked, so that only the query gets explained
122
- YasqeSteps.getQuery().should('contain', LLM_QUERY_ONLY_COMMENT);
123
- });
124
-
125
- it('Should execute an explain request when LLM explain results is selected', () => {
126
- // Given I have opened the sparql editor with a select query
127
- // When I execute the LLM explain results action
128
- YasqeSteps.executeLlmExplainResults();
129
- // Then I expect a gpt explain request to be sent
130
- verifyExplainRequest('gpt');
131
- // And I expect the query to be marked, so that only the results get explained
132
- YasqeSteps.getQuery().should('contain', LLM_RESULT_ONLY_COMMENT);
133
- });
134
- });
135
-
136
- describe('Explain query plan for a virtual repository', () => {
137
-
138
- let repositoryId;
139
-
140
- beforeEach(() => {
141
- repositoryId = 'sparql-editor-explain-plan-' + Date.now();
142
- cy.presetRepository(repositoryId);
143
- RepositoriesStubs.stubOntopRepository(repositoryId);
144
- RepositoriesStubs.stubNameSpaces(repositoryId);
145
- AutocompleteStubs.stubAutocompleteEnabled(false);
146
-
147
- SparqlEditorSteps.visitSparqlEditorPageAndWaitForEditor();
148
- YasguiSteps.getYasgui().should('be.visible');
149
- YasqeSteps.getRunSplitButton().should('have.class', 'hydrated');
150
- });
151
-
152
- it('Should not allow explain query plan for virtual repositories', () => {
153
- // Given I have opened the editor configured for a virtual repository
154
- // When I execute the explain query plan action
155
- YasqeSteps.executeExplainQueryPlan();
156
- // Then I expect to be warned that explain is not supported
157
- ToasterSteps.getToasterMessage()
158
- .should('contain', 'Explain not supported for Virtual repositories.');
159
- // And I expect no plan to be rendered
160
- YasrSteps.getExplainPlanPlugin().should('not.exist');
161
- });
162
- });
163
-
164
- /**
165
- * Verifies that an explain request has been sent and has succeeded.
166
- * @param {string} explainType - 'explain' for the query plan, 'gpt' for the LLM explanations.
167
- */
168
- const verifyExplainRequest = (explainType) => {
169
- cy.wait('@explainQuery').then((interception) => {
170
- expect(interception.request.body).to.contain('explain=true');
171
- expect(interception.request.body).to.contain(`explainType=${explainType}`);
172
- expect(interception.response.statusCode).to.equal(200);
173
- });
174
- };