graphdb-workbench-tests 4.0.0-TR21 → 4.0.0-TR22

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.
@@ -60,7 +60,7 @@ describe('Expand results over owl:sameAs', () => {
60
60
  // Then I expect that "sameAs" element to be enabled by default
61
61
  YasqeSteps.getActionButton(5).should('have.class', 'icon-same-as-on');
62
62
  // and the tooltip of element describes that "sameAs" element is enabled.
63
- YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Expand results over owl:sameAs: ON');
63
+ YasqeSteps.getActionButtonTooltip(5).should('have.attr', 'yasgui-data-tooltip', 'Expand results over owl:sameAs: ON');
64
64
 
65
65
  // When I open a new Tab.
66
66
  YasguiSteps.openANewTab();
@@ -68,7 +68,7 @@ describe('Expand results over owl:sameAs', () => {
68
68
  // Then I expect that "sameAs" element to be enabled in the new tab.
69
69
  YasqeSteps.getActionButton(5).should('have.class', 'icon-same-as-on');
70
70
  // and the tooltip of element describes that "sameAs" element is enabled.
71
- YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Expand results over owl:sameAs: ON');
71
+ YasqeSteps.getActionButtonTooltip(5).should('have.attr', 'yasgui-data-tooltip', 'Expand results over owl:sameAs: ON');
72
72
  });
73
73
 
74
74
  it('should not be enabled when infer is true and sameAs is false in user settings',() => {
@@ -81,7 +81,7 @@ describe('Expand results over owl:sameAs', () => {
81
81
  // Then I expect that "sameAs" element to be disabled by default
82
82
  YasqeSteps.getActionButton(5).should('have.class', 'icon-same-as-off');
83
83
  // and the tooltip of element describes that "sameAs" element is disabled.
84
- YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Expand results over owl:sameAs: OFF');
84
+ YasqeSteps.getActionButtonTooltip(5).should('have.attr', 'yasgui-data-tooltip', 'Expand results over owl:sameAs: OFF');
85
85
 
86
86
  // When I open a new Tab.
87
87
  YasguiSteps.openANewTab();
@@ -89,7 +89,7 @@ describe('Expand results over owl:sameAs', () => {
89
89
  // Then I expect that "sameAs" element to be disabled in the new tab.
90
90
  YasqeSteps.getActionButton(5).should('have.class', 'icon-same-as-off');
91
91
  // and the tooltip of element describes that "sameAs" element is disabled.
92
- YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Expand results over owl:sameAs: OFF');
92
+ YasqeSteps.getActionButtonTooltip(5).should('have.attr', 'yasgui-data-tooltip', 'Expand results over owl:sameAs: OFF');
93
93
  });
94
94
 
95
95
  it('should not be enabled when infer is false and sameAs is true in user settings', () => {
@@ -100,7 +100,7 @@ describe('Expand results over owl:sameAs', () => {
100
100
  YasguiSteps.getYasgui().should('be.visible');
101
101
 
102
102
  // Then I expect that "sameAs" element to be disabled by default
103
- YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Requires \'Include Inferred\'!');
103
+ YasqeSteps.getActionButtonTooltip(5).should('have.attr', 'yasgui-data-tooltip', 'Requires \'Include Inferred\'!');
104
104
  // and the tooltip of element describes that "infer" is required.
105
105
  YasqeSteps.getActionButton(5).should('have.class', 'icon-same-as-off');
106
106
 
@@ -110,7 +110,7 @@ describe('Expand results over owl:sameAs', () => {
110
110
  // Then I expect that "sameAs" element to be disabled in the new tab,
111
111
  YasqeSteps.getActionButton(5).should('have.class', 'icon-same-as-off');
112
112
  // and the tooltip of element describes that "infer" is required.
113
- YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Requires \'Include Inferred\'!');
113
+ YasqeSteps.getActionButtonTooltip(5).should('have.attr', 'yasgui-data-tooltip', 'Requires \'Include Inferred\'!');
114
114
  });
115
115
 
116
116
  it('should not be enabled when infer is false and sameAs is false in user settings', () => {
@@ -123,7 +123,7 @@ describe('Expand results over owl:sameAs', () => {
123
123
  // Then I expect that "sameAs" element to be disabled by default,
124
124
  YasqeSteps.getActionButton(5).should('have.class', 'icon-same-as-off');
125
125
  // and the tooltip of element describes that "infer" is required.
126
- YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Requires \'Include Inferred\'!');
126
+ YasqeSteps.getActionButtonTooltip(5).should('have.attr', 'yasgui-data-tooltip', 'Requires \'Include Inferred\'!');
127
127
 
128
128
  // When I open a new Tab.
129
129
  YasguiSteps.openANewTab();
@@ -131,6 +131,6 @@ describe('Expand results over owl:sameAs', () => {
131
131
  // Then I expect that "sameAs" element to be disabled in the new tab,
132
132
  YasqeSteps.getActionButton(5).should('have.class', 'icon-same-as-off');
133
133
  // and the tooltip of element describes that "infer" is required.
134
- YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Requires \'Include Inferred\'!');
134
+ YasqeSteps.getActionButtonTooltip(5).should('have.attr', 'yasgui-data-tooltip', 'Requires \'Include Inferred\'!');
135
135
  });
136
136
  });
@@ -66,7 +66,7 @@ describe('Include inferred statements', () => {
66
66
  // Then I expect that "infer" element to be enabled by default,
67
67
  YasqeSteps.getActionButton(4).should('have.class', 'icon-inferred-on');
68
68
  // and the tooltip of element describes that "infer" functionality is enabled.
69
- YasqeSteps.getActionButtonTooltip(3).should('have.attr', 'yasgui-data-tooltip', 'Include inferred data in results: ON');
69
+ YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Include inferred data in results: ON');
70
70
 
71
71
  // When I open a new Tab.
72
72
  YasguiSteps.openANewTab();
@@ -74,7 +74,7 @@ describe('Include inferred statements', () => {
74
74
  // Then I expect that inferred element to be enabled in the new tab,
75
75
  YasqeSteps.getActionButton(4).should('have.class', 'icon-inferred-on');
76
76
  // and the tooltip of element describes that "infer" element is enabled.
77
- YasqeSteps.getActionButtonTooltip(3).should('have.attr', 'yasgui-data-tooltip', 'Include inferred data in results: ON');
77
+ YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Include inferred data in results: ON');
78
78
  });
79
79
 
80
80
  it('should not be enabled when user settings is set to false.', () => {
@@ -87,7 +87,7 @@ describe('Include inferred statements', () => {
87
87
  // Then I expect that "infer" element to be disabled by default,
88
88
  YasqeSteps.getActionButton(4).should('have.class', 'icon-inferred-off');
89
89
  // and the tooltip of element describes that "infer" element is disabled.
90
- YasqeSteps.getActionButtonTooltip(3).should('have.attr', 'yasgui-data-tooltip', 'Include inferred data in results: OFF');
90
+ YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Include inferred data in results: OFF');
91
91
 
92
92
  // When I open a new Tab.
93
93
  YasguiSteps.openANewTab();
@@ -95,6 +95,6 @@ describe('Include inferred statements', () => {
95
95
  // Then I expect that inferred element to be disabled in the new tab,
96
96
  YasqeSteps.getActionButton(4).should('have.class', 'icon-inferred-off');
97
97
  // and the tooltip of element describes that "infer" element is disabled.
98
- YasqeSteps.getActionButtonTooltip(3).should('have.attr', 'yasgui-data-tooltip', 'Include inferred data in results: OFF');
98
+ YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Include inferred data in results: OFF');
99
99
  });
100
100
  });
@@ -36,14 +36,14 @@ describe('Expand results over owl:sameAs', () => {
36
36
  SparqlEditorSteps.visitSparqlEditorPage();
37
37
 
38
38
  // Then I expect inferred button to be on.
39
- YasqeSteps.getActionButtonTooltip(3).should('have.attr', 'yasgui-data-tooltip', 'Include inferred data in results: ON');
39
+ YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Include inferred data in results: ON');
40
40
  YasqeSteps.getActionButton(4).should('have.class', 'icon-inferred-on');
41
41
 
42
42
  // When I click on inferred button
43
43
  YasqeSteps.getActionButton(4).click({force: true});
44
44
 
45
45
  // Then I expect inferred button to not be toggled.
46
- YasqeSteps.getActionButtonTooltip(3).should('have.attr', 'yasgui-data-tooltip', 'Include inferred data in results: ON');
46
+ YasqeSteps.getActionButtonTooltip(4).should('have.attr', 'yasgui-data-tooltip', 'Include inferred data in results: ON');
47
47
  YasqeSteps.getActionButton(4).should('have.class', 'icon-inferred-on');
48
48
  });
49
49
  });
@@ -0,0 +1,49 @@
1
+ import {RepositoriesStubs} from '../../stubs/repositories/repositories-stubs';
2
+ import {TTYGStubs} from '../../stubs/ttyg/ttyg-stubs';
3
+ import {TTYGViewSteps} from '../../steps/ttyg/ttyg-view-steps';
4
+ import {ChatPanelSteps} from '../../steps/ttyg/chat-panel-steps';
5
+ import {BrowserStubs} from '../../stubs/browser-stubs.js';
6
+
7
+ const EXPRESSION = '{{7*7}}';
8
+ const QUERY = `SELECT ?s WHERE { ?s rdfs:label "${EXPRESSION}" }`;
9
+
10
+ describe('Ttyg chat template injection', () => {
11
+
12
+ beforeEach(() => {
13
+ RepositoriesStubs.stubRepositories(0, '/repositories/get-ttyg-repositories.json');
14
+ RepositoriesStubs.stubBaseEndpoints('starwars');
15
+ cy.presetRepository('starwars');
16
+ TTYGStubs.stubChatsListGet();
17
+ TTYGStubs.stubAgentListGet();
18
+ // Given a chat whose question and answer contain an AngularJS expression
19
+ TTYGStubs.stubChatGet(0, '/ttyg/chats/get-chat-with-template-injection.json');
20
+
21
+ TTYGViewSteps.visit();
22
+ cy.wait('@get-chat-list');
23
+ cy.wait('@get-agent-list');
24
+ cy.wait('@get-chat');
25
+ cy.wait('@get-all-repositories');
26
+ });
27
+
28
+ it('should show AngularJS expressions in the chat literally', () => {
29
+ // Then I expect the expression in the question to be shown as it is, not evaluated
30
+ ChatPanelSteps.getChatDetailQuestionElement(0).should('contain', `What is ${EXPRESSION}?`);
31
+ // And the expression in the answer text and in its SPARQL code block to be shown as it is
32
+ ChatPanelSteps.getAssistantAnswer(0)
33
+ .should('contain', `The answer is ${EXPRESSION}.`)
34
+ .and('contain', QUERY)
35
+ .and('not.contain', '49');
36
+ });
37
+
38
+ it('should open the SPARQL query of an answer with its AngularJS expression unchanged', () => {
39
+ // Given the browser does not open new windows
40
+ BrowserStubs.stubWindowOpen();
41
+
42
+ // When I open the SPARQL query of the answer in the SPARQL editor
43
+ ChatPanelSteps.openInSparqlEditor(0);
44
+
45
+ // Then I expect the query to be opened with the expression unchanged
46
+ cy.get(BrowserStubs.WINDOW_OPEN_ALIAS())
47
+ .should('have.been.calledWith', `sparql?query=${encodeURIComponent(QUERY)}&execute=false`);
48
+ });
49
+ });
@@ -2,6 +2,7 @@ import {RepositorySelectorSteps} from '../../steps/repository-selector-steps.js'
2
2
  import {LoginSteps} from '../../steps/login-steps.js';
3
3
  import {UserAndAccessSteps} from '../../steps/setup/user-and-access-steps.js';
4
4
  import HomeSteps from '../../steps/home-steps.js';
5
+ import {GraphNavigatorSteps} from '../../steps/graph-navigator-steps.js';
5
6
 
6
7
  describe('URL with Repository ID parameter', () => {
7
8
  let repositoryId;
@@ -39,6 +40,22 @@ describe('URL with Repository ID parameter', () => {
39
40
  cy.url().should('include', 'repositoryId=' + repositoryId);
40
41
  RepositorySelectorSteps.getSelectedRepository().should('contain', repositoryId);
41
42
  });
43
+
44
+ it('should open a page of the new Workbench with repositoryId in url after login', () => {
45
+ // Given security is on
46
+ cy.switchOnSecurity();
47
+ // When I open a page of the new Workbench, which loads its code only when it is opened
48
+ GraphNavigatorSteps.visit();
49
+ // Then the login page should be shown
50
+ LoginSteps.getLoginPage().should('be.visible');
51
+ // When I log in with user admin
52
+ LoginSteps.loginWithUser('admin', 'root');
53
+ // Then the page should open with only the repositoryId parameter in the URL
54
+ GraphNavigatorSteps.verifyUrl();
55
+ GraphNavigatorSteps.verifyOnlyRepositoryParam(repositoryId);
56
+ // And the repository should be selected in the selector
57
+ RepositorySelectorSteps.getSelectedRepository().should('contain', repositoryId);
58
+ });
42
59
  });
43
60
 
44
61
  function enableSecurity(repositoryId) {
@@ -0,0 +1,27 @@
1
+ {
2
+ "thread_jdQBvbkaU6JPoO48oQaL76dC": {
3
+ "id": "thread_jdQBvbkaU6JPoO48oQaL76dC",
4
+ "name": "Template injection",
5
+ "messages": [
6
+ {
7
+ "id": "msg_template_injection_question",
8
+ "conversationId": "thread_jdQBvbkaU6JPoO48oQaL76dC",
9
+ "agentId": null,
10
+ "role": "user",
11
+ "message": "What is {{7*7}}?",
12
+ "timestamp": "1725875323",
13
+ "name": null
14
+ },
15
+ {
16
+ "id": "msg_template_injection_answer",
17
+ "conversationId": "thread_jdQBvbkaU6JPoO48oQaL76dC",
18
+ "agentId": "asst_gAPcrHQQ9ZIxD5eXWH2BNFfo",
19
+ "role": "assistant",
20
+ "message": "The answer is {{7*7}}.\n\n```sparql\nSELECT ?s WHERE { ?s rdfs:label \"{{7*7}}\" }\n```",
21
+ "timestamp": "1725875332",
22
+ "name": null
23
+ }
24
+ ],
25
+ "timestamp": "1725875483"
26
+ }
27
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "graphdb-workbench-tests",
3
- "version": "4.0.0-TR21",
3
+ "version": "4.0.0-TR22",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "graphdb-workbench-tests",
9
- "version": "4.0.0-TR21",
9
+ "version": "4.0.0-TR22",
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-TR21",
3
+ "version": "4.0.0-TR22",
4
4
  "description": "Cypress tests for GraphDB workbench",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -86,6 +86,10 @@ export class ChatPanelSteps extends BaseSteps {
86
86
  return ChatPanelSteps.getCopyToClipboardElements().eq(index);
87
87
  }
88
88
 
89
+ static openInSparqlEditor(index = 0) {
90
+ ChatPanelSteps.getOpenInSparqlEditorElement(index).find(ChatPanelSteps.buildTestIdAttr('open-in-sparql-editor-btn')).click();
91
+ }
92
+
89
93
  static getCancelButton() {
90
94
  return ChatPanelSteps.getChatPanel().find('.cancel-ask-button');
91
95
  }
@@ -205,12 +205,8 @@ export class YasqeSteps {
205
205
  return YasqeSteps.getEditor().find('.yasqe_buttons');
206
206
  }
207
207
 
208
- static getActionButtonsTooltips() {
209
- return YasqeSteps.getActionsToolbar().find('yasgui-tooltip');
210
- }
211
-
212
- static getActionButtonTooltip(index) {
213
- return YasqeSteps.getActionButtonsTooltips().eq(index);
208
+ static getActionButtonTooltip(buttonIndex) {
209
+ return YasqeSteps.getActionButton(buttonIndex).closest('yasgui-tooltip');
214
210
  }
215
211
 
216
212
  static getActionButtons() {
@@ -29,9 +29,10 @@ export class TTYGStubs extends Stubs {
29
29
  * Loads the specified <code>fixture</code> and updates the chatId in the fixture with the actual ID passed in the endpoint call.
30
30
  *
31
31
  * @param {number} delay - Optional delay in milliseconds before responding with the fixture.
32
+ * @param {string} fixture - Optional fixture with the chats, keyed by chat ID.
32
33
  */
33
- static stubChatGet(delay = 0) {
34
- cy.fixture('/ttyg/chats/get-chat.json').then((body) => {
34
+ static stubChatGet(delay = 0, fixture = '/ttyg/chats/get-chat.json') {
35
+ cy.fixture(fixture).then((body) => {
35
36
  cy.intercept({
36
37
  method: 'GET',
37
38
  url: '/rest/chat/conversations/*'