graphdb-workbench-tests 3.2.0-TR2 → 3.2.0-TR3

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.
@@ -190,6 +190,36 @@ describe('Ttyg ChatPanel', () => {
190
190
  .and('contain', 'completion tokens');
191
191
  });
192
192
 
193
+ it('Should abort question', () => {
194
+ // When I type a question
195
+ ChatPanelSteps.getQuestionInputElement()
196
+ .should('be.visible')
197
+ .and('not.have.attr', 'disabled');
198
+ ChatPanelSteps.getQuestionInputElement()
199
+ .type('Who is Han Solo?');
200
+
201
+ // Then I expect the "Ask" button be active
202
+ ChatPanelSteps.getAskButtonElement().should('be.enabled');
203
+
204
+ // When I click on "Ask" button
205
+ TTYGStubs.stubAnswerQuestionWithDelay();
206
+ TTYGStubs.stubCancelQuestion();
207
+ ChatPanelSteps.askQuestion();
208
+ // Then the Cancel button should become visible and the Ask button should be hidden
209
+ ChatPanelSteps.getAskButtonElement().should('not.exist');
210
+ ChatPanelSteps.getCancelButton().should('be.visible');
211
+ // When I cancel the question
212
+ ChatPanelSteps.cancelQuestion();
213
+ // Then the Cancel button should be replaced with the Ask button
214
+ ChatPanelSteps.getCancelButton().should('not.exist');
215
+ ChatPanelSteps.getAskButtonElement().should('be.visible');
216
+ // Then the default Agent response should be visible
217
+ ChatPanelSteps.getAssistantAnswer(2).invoke('text').then((text) => {
218
+ expect(text.trim()).to.equal('Request cancelled by the user.');
219
+ });
220
+ ChatPanelSteps.getAssistantIcon(2).should('not.exist');
221
+ });
222
+
193
223
  // Can't test this on CI
194
224
  it.skip('Should copy an answer when click on copy button', () => {
195
225
  // When I click on copy button
@@ -47,9 +47,10 @@ describe('TTYG create chat', () => {
47
47
  ChatPanelSteps.getAskButtonElement().should('be.enabled');
48
48
 
49
49
  // When I click on "Ask" button.
50
- TTYGStubs.stubCrateNewChat();
50
+ TTYGStubs.stubCreateNewChat();
51
51
  ChatPanelSteps.getAskButtonElement().scrollIntoView().click();
52
52
  cy.wait('@create-chat');
53
+ cy.wait('@ask-first-chat-question');
53
54
 
54
55
  // Then I expect new chat to be created in a new group "Today" and be selected
55
56
  TTYGViewSteps.getChatGroup(0).should('contain', 'Today');
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": "thread_YHVy625Ir8TJkUuwy94l46Om",
3
+ "name": "New chat",
4
+ "messages": [],
5
+ "timestamp": 1756128759,
6
+ "continueRunId": null,
7
+ "usage": {
8
+ "completionTokens": 0,
9
+ "promptTokens": 0,
10
+ "totalTokens": 0
11
+ }
12
+ }
@@ -0,0 +1 @@
1
+ {"runStatus":"cancelled","message":"Request cancelled by the user."}
@@ -1,16 +1,12 @@
1
1
  {
2
- "id": "thread_new_created_chat",
3
- "name": "New chat of Han Solo is a character",
4
- "timestamp": "creationDate",
5
- "messages": [
6
- {
7
- "id": "msg_Bn07kVDCYT1qmgu1G7Zw0KNeс_",
8
- "conversationId": "thread_new_created_chat",
9
- "role": "assistant",
10
- "agentId": "asst_gAPcrHQQ9ZIxD5eXWH2BNFfo",
11
- "message": "Han Solo is a character...",
12
- "timestamp": "creationDate",
13
- "name": null
14
- }
15
- ]
2
+ "id": null,
3
+ "conversationId": "thread_new_created_chat",
4
+ "agentId": null,
5
+ "role": null,
6
+ "message": null,
7
+ "timestamp": 0,
8
+ "name": "New chat",
9
+ "usage": null,
10
+ "isTerminalState": false,
11
+ "terminalStatusCode": null
16
12
  }
@@ -0,0 +1,29 @@
1
+ {
2
+ "id": "thread_tpv1izmd9bIjxkhUiCd5x2Xz",
3
+ "name": "Hello! How can I assist you today?",
4
+ "messages": [
5
+ {
6
+ "id": "msg_drDW9OTkPkY0oGoXSdPD5qEx",
7
+ "conversationId": "thread_tpv1izmd9bIjxkhUiCd5x2Xz",
8
+ "agentId": "asst_0llP8yAJlFY2yCWrz8Ovfzjs",
9
+ "role": "assistant",
10
+ "message": "Hello! How can I assist you today?",
11
+ "timestamp": 1756129125,
12
+ "name": null,
13
+ "usage": {
14
+ "completionTokens": 11,
15
+ "promptTokens": 374,
16
+ "totalTokens": 385
17
+ },
18
+ "isTerminalState": false,
19
+ "terminalStatusCode": null
20
+ }
21
+ ],
22
+ "timestamp": 1756129125,
23
+ "continueRunId": null,
24
+ "usage": {
25
+ "completionTokens": 11,
26
+ "promptTokens": 374,
27
+ "totalTokens": 385
28
+ }
29
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "graphdb-workbench-tests",
3
- "version": "3.2.0-TR2",
3
+ "version": "3.2.0-TR3",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "graphdb-workbench-tests",
9
- "version": "3.2.0-TR2",
9
+ "version": "3.2.0-TR3",
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": "3.2.0-TR2",
3
+ "version": "3.2.0-TR3",
4
4
  "description": "Cypress tests for GraphDB workbench",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -16,6 +16,10 @@ export class ChatPanelSteps {
16
16
  return ChatPanelSteps.getChatDetailElement(chatDetailIndex).find('.actions').eq(answerIndex);
17
17
  }
18
18
 
19
+ static getAssistantAnswer(index) {
20
+ return ChatPanelSteps.getChatPanel().find('.assistant-message markdown-content').eq(index);
21
+ }
22
+
19
23
  static getQuestionInputElement() {
20
24
  return ChatPanelSteps.getChatPanel().find('.question-input .contenteditable');
21
25
  }
@@ -24,6 +28,10 @@ export class ChatPanelSteps {
24
28
  return ChatPanelSteps.getChatPanel().find('.ask-button');
25
29
  }
26
30
 
31
+ static askQuestion() {
32
+ ChatPanelSteps.getAskButtonElement().scrollIntoView().click();
33
+ }
34
+
27
35
  static getChatDetailQuestionElement(index = 0) {
28
36
  return ChatPanelSteps.getChatDetailElement(index).find('.question');
29
37
  }
@@ -59,4 +67,16 @@ export class ChatPanelSteps {
59
67
  static getCopyToClipboardElement(index = 0) {
60
68
  return ChatPanelSteps.getCopyToClipboardElements().eq(index);
61
69
  }
70
+
71
+ static getCancelButton() {
72
+ return ChatPanelSteps.getChatPanel().find('.cancel-ask-button');
73
+ }
74
+
75
+ static cancelQuestion() {
76
+ ChatPanelSteps.getCancelButton().click();
77
+ }
78
+
79
+ static getAssistantIcon(index) {
80
+ return ChatPanelSteps.getChatDetailElement(index).find('.assistant-icon');
81
+ }
62
82
  }
@@ -143,22 +143,52 @@ export class TTYGStubs extends Stubs {
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/chat/chats/**/question', {
147
147
  fixture,
148
148
  statusCode: 200
149
149
  }).as('get-agent-defaults');
150
150
  }
151
151
 
152
- static stubCrateNewChat(fixture = 'ttyg/chats/create/create-chat-response.json') {
153
- cy.fixture(fixture).then((fixtureData) => {
152
+ static stubAnswerQuestionWithDelay(fixture = '/ttyg/chats/ask-question-cancel.json', delay = 1000) {
153
+ cy.intercept({
154
+ method: 'POST',
155
+ url: '/rest/chat/chats/**/question',
156
+ }, (req) => {
157
+ req.reply({
158
+ fixture,
159
+ statusCode: 200,
160
+ delay
161
+ });
162
+ }).as('get-cancelled-answer');
163
+ }
164
+
165
+ static stubCancelQuestion(fixture = '/ttyg/chats/cancel-question-response.json', delay = 1000) {
166
+ cy.intercept({
167
+ method: 'POST',
168
+ url: 'rest/chat/chats/**/cancel'
169
+ }, (req) => {
170
+ req.reply({
171
+ fixture,
172
+ statusCode: 200,
173
+ delay
174
+ });
175
+ }).as('get-cancel-response');
176
+ }
177
+
178
+ static stubCreateNewChat() {
179
+ cy.intercept('POST', '/rest/chat/chats', {
180
+ fixture: 'ttyg/chats/create/create-chat-response.json',
181
+ statusCode: 200
182
+ }).as('ask-first-chat-question');
183
+
184
+ cy.fixture('ttyg/chats/create/question-response-after-chat-creation.json').then((fixtureData) => {
154
185
  const today = Math.floor(Date.now() / 1000) + '';
155
186
  const body = JSON.stringify(fixtureData).replace(/"creationDate"/g, today);
156
- cy.intercept('POST', '/rest/chat/conversations', {
187
+ cy.intercept('POST', '/rest/chat/chats/**/question', {
157
188
  statusCode: 200,
158
189
  body: JSON.parse(body)
159
190
  }).as('create-chat');
160
191
  });
161
-
162
192
  }
163
193
 
164
194
  static stubExplainResponse(fixture = '/ttyg/chats/explain-response-1.json') {