| 1 | import { expect } from "chai"; |
| 2 | import { |
| 3 | By, |
| 4 | EditorView, |
| 5 | Key, |
| 6 | VSBrowser, |
| 7 | WebDriver, |
| 8 | WebElement, |
| 9 | WebView, |
| 10 | until, |
| 11 | } from "vscode-extension-tester"; |
| 12 | |
| 13 | import { GlobalActions } from "../actions/Global.actions"; |
| 14 | import { GUIActions } from "../actions/GUI.actions"; |
| 15 | import { DEFAULT_TIMEOUT } from "../constants"; |
| 16 | import { GUISelectors } from "../selectors/GUI.selectors"; |
| 17 | import { TestUtils } from "../TestUtils"; |
| 18 | |
| 19 | describe("GUI Test", () => { |
| 20 | let view: WebView; |
| 21 | let driver: WebDriver; |
| 22 | |
| 23 | before(async function () { |
| 24 | this.timeout(DEFAULT_TIMEOUT.XL); |
| 25 | // Uncomment this line for faster testing |
| 26 | await GUIActions.moveContinueToSidebar(VSBrowser.instance.driver); |
| 27 | await GlobalActions.openTestWorkspace(); |
| 28 | await GlobalActions.clearAllNotifications(); |
| 29 | }); |
| 30 | |
| 31 | beforeEach(async function () { |
| 32 | this.timeout(DEFAULT_TIMEOUT.XL); |
| 33 | |
| 34 | await GUIActions.toggleGui(); |
| 35 | |
| 36 | ({ view, driver } = await GUIActions.switchToReactIframe()); |
| 37 | await GUIActions.selectModelFromDropdown(view, "TEST LLM"); |
| 38 | }); |
| 39 | |
| 40 | afterEach(async function () { |
| 41 | this.timeout(DEFAULT_TIMEOUT.XL); |
| 42 | |
| 43 | await view.switchBack(); |
| 44 | await TestUtils.waitForSuccess( |
| 45 | async () => (await GUISelectors.getContinueExtensionBadge(view)).click(), |
| 46 | DEFAULT_TIMEOUT.XS, |
| 47 | ); |
| 48 | await new EditorView().closeAllEditors(); |
| 49 | }); |
| 50 | |
| 51 | describe("Onboarding", () => { |
| 52 | it.skip("should display correct panel description", async () => { |
| 53 | const description = await GUISelectors.getDescription(view); |
| 54 | |
| 55 | expect(await description.getText()).has.string( |
| 56 | "Log in to quickly build your first custom AI code assistant", |
| 57 | ); |
| 58 | }).timeout(DEFAULT_TIMEOUT.XL); |
| 59 | |
| 60 | // We no longer have a quick start button |
| 61 | it.skip( |
| 62 | "should display tutorial card after accepting onboarding quick start", |
| 63 | async () => { |
| 64 | // Get paragraph with text Best |
| 65 | const bestTab = await GUISelectors.getOnboardingTabButton(view, "Best"); |
| 66 | await bestTab.click(); |
| 67 | |
| 68 | const anthropicInput = await TestUtils.waitForSuccess( |
| 69 | async () => await GUISelectors.getBestChatApiKeyInput(view), |
| 70 | ); |
| 71 | anthropicInput.sendKeys("invalid_api_key"); |
| 72 | |
| 73 | const mistralInput = |
| 74 | await GUISelectors.getBestAutocompleteApiKeyInput(view); |
| 75 | mistralInput.sendKeys("invalid_api_key"); |
| 76 | |
| 77 | // Get button with text "Connect" and click it |
| 78 | const connectButton = await view.findWebElement( |
| 79 | By.xpath("//button[text()='Connect']"), |
| 80 | ); |
| 81 | await connectButton.click(); |
| 82 | |
| 83 | await TestUtils.waitForSuccess( |
| 84 | async () => await GUISelectors.getTutorialCard(view), |
| 85 | ); |
| 86 | |
| 87 | // TODO validate that claude has been added to list |
| 88 | |
| 89 | // Skip testing Quick Start because github auth opens external app and breaks test |
| 90 | // const quickStartButton = await view.findWebElement( |
| 91 | // By.xpath("//*[contains(text(), 'Get started using our API keys')]") |
| 92 | // ); |
| 93 | // await quickStartButton.click(); |
| 94 | // await view.switchBack(); |
| 95 | // const allowButton = await TestUtils.waitForSuccess( |
| 96 | // async () => await driver.findElement(By.xpath(`//a[contains(text(), "Allow")]`)) |
| 97 | // ); |
| 98 | // await allowButton.click(); |
| 99 | // ({ view, driver } = await GUIActions.switchToReactIframe()); |
| 100 | }, |
| 101 | ).timeout(DEFAULT_TIMEOUT.XL); |
| 102 | }); |
| 103 | |
| 104 | describe("Chat", () => { |
| 105 | it("Can submit message by pressing enter", async () => { |
| 106 | const [messageInput] = await GUISelectors.getMessageInputFields(view); |
| 107 | const messagePair = TestUtils.generateTestMessagePair(); |
| 108 | await messageInput.sendKeys(messagePair.userMessage); |
| 109 | await messageInput.sendKeys(Key.ENTER); |
| 110 | await TestUtils.waitForSuccess(() => |
| 111 | GUISelectors.getThreadMessageByText(view, messagePair.llmResponse), |
| 112 | ); |
| 113 | }); |
| 114 | |
| 115 | it("Can submit message by button click", async () => { |
| 116 | const [messageInput] = await GUISelectors.getMessageInputFields(view); |
| 117 | const messagePair = TestUtils.generateTestMessagePair(); |
| 118 | await messageInput.sendKeys(messagePair.userMessage); |
| 119 | (await GUISelectors.getSubmitInputButton(view)).click(); |
| 120 | await TestUtils.waitForSuccess(() => |
| 121 | GUISelectors.getThreadMessageByText(view, messagePair.llmResponse), |
| 122 | ); |
| 123 | }); |
| 124 | |
| 125 | it("Can delete messages", async () => { |
| 126 | const { userMessage: userMessage0, llmResponse: llmResponse0 } = |
| 127 | TestUtils.generateTestMessagePair(0); |
| 128 | await GUIActions.sendMessage({ |
| 129 | view, |
| 130 | message: userMessage0, |
| 131 | inputFieldIndex: 0, |
| 132 | }); |
| 133 | await TestUtils.waitForSuccess(() => |
| 134 | GUISelectors.getThreadMessageByText(view, llmResponse0), |
| 135 | ); |
| 136 | |
| 137 | const { userMessage: userMessage1, llmResponse: llmResponse1 } = |
| 138 | TestUtils.generateTestMessagePair(1); |
| 139 | await GUIActions.sendMessage({ |
| 140 | view, |
| 141 | message: userMessage1, |
| 142 | inputFieldIndex: 1, |
| 143 | }); |
| 144 | await TestUtils.waitForSuccess(() => |
| 145 | GUISelectors.getThreadMessageByText(view, llmResponse1), |
| 146 | ); |
| 147 | |
| 148 | const { userMessage: userMessage2, llmResponse: llmResponse2 } = |
| 149 | TestUtils.generateTestMessagePair(2); |
| 150 | await GUIActions.sendMessage({ |
| 151 | view, |
| 152 | message: userMessage2, |
| 153 | inputFieldIndex: 2, |
| 154 | }); |
| 155 | await TestUtils.waitForSuccess(() => |
| 156 | GUISelectors.getThreadMessageByText(view, llmResponse2), |
| 157 | ); |
| 158 | |
| 159 | GUISelectors.getThreadMessageByText(view, llmResponse1); |
| 160 | await (await GUISelectors.getNthMessageDeleteButton(view, 1)).click(); |
| 161 | await TestUtils.expectNoElement(() => |
| 162 | GUISelectors.getThreadMessageByText(view, llmResponse1), |
| 163 | ); |
| 164 | |
| 165 | GUISelectors.getThreadMessageByText(view, llmResponse0); |
| 166 | await (await GUISelectors.getNthMessageDeleteButton(view, 0)).click(); |
| 167 | await TestUtils.expectNoElement(() => |
| 168 | GUISelectors.getThreadMessageByText(view, llmResponse0), |
| 169 | ); |
| 170 | |
| 171 | GUISelectors.getThreadMessageByText(view, llmResponse2); |
| 172 | await (await GUISelectors.getNthMessageDeleteButton(view, 0)).click(); |
| 173 | await TestUtils.expectNoElement(() => |
| 174 | GUISelectors.getThreadMessageByText(view, llmResponse2), |
| 175 | ); |
| 176 | }).timeout(DEFAULT_TIMEOUT.XL); |
| 177 | |
| 178 | it("Can edit messages", async () => { |
| 179 | const { userMessage: userMessage0, llmResponse: llmResponse0 } = |
| 180 | TestUtils.generateTestMessagePair(0); |
| 181 | await GUIActions.sendMessage({ |
| 182 | view, |
| 183 | message: userMessage0, |
| 184 | inputFieldIndex: 0, |
| 185 | }); |
| 186 | await TestUtils.waitForSuccess(() => |
| 187 | GUISelectors.getThreadMessageByText(view, llmResponse0), |
| 188 | ); |
| 189 | |
| 190 | const { userMessage: userMessage1, llmResponse: llmResponse1 } = |
| 191 | TestUtils.generateTestMessagePair(1); |
| 192 | await GUIActions.sendMessage({ |
| 193 | view, |
| 194 | message: userMessage1, |
| 195 | inputFieldIndex: 1, |
| 196 | }); |
| 197 | await TestUtils.waitForSuccess(() => |
| 198 | GUISelectors.getThreadMessageByText(view, llmResponse1), |
| 199 | ); |
| 200 | |
| 201 | const { userMessage: userMessage2, llmResponse: llmResponse2 } = |
| 202 | TestUtils.generateTestMessagePair(2); |
| 203 | await GUIActions.sendMessage({ |
| 204 | view, |
| 205 | message: userMessage2, |
| 206 | inputFieldIndex: 2, |
| 207 | }); |
| 208 | await TestUtils.waitForSuccess(() => |
| 209 | GUISelectors.getThreadMessageByText(view, llmResponse2), |
| 210 | ); |
| 211 | |
| 212 | const secondInputField = await GUISelectors.getMessageInputFieldAtIndex( |
| 213 | view, |
| 214 | 1, |
| 215 | ); |
| 216 | await secondInputField.clear(); |
| 217 | |
| 218 | const { userMessage: userMessage3, llmResponse: llmResponse3 } = |
| 219 | TestUtils.generateTestMessagePair(3); |
| 220 | |
| 221 | await GUIActions.sendMessage({ |
| 222 | view, |
| 223 | message: userMessage3, |
| 224 | inputFieldIndex: 1, |
| 225 | }); |
| 226 | await GUISelectors.getThreadMessageByText(view, llmResponse0); |
| 227 | |
| 228 | await TestUtils.waitForSuccess(() => |
| 229 | GUISelectors.getThreadMessageByText(view, llmResponse3), |
| 230 | ); |
| 231 | await Promise.all([ |
| 232 | TestUtils.expectNoElement(() => |
| 233 | GUISelectors.getThreadMessageByText(view, llmResponse1), |
| 234 | ), |
| 235 | TestUtils.expectNoElement(() => |
| 236 | GUISelectors.getThreadMessageByText(view, llmResponse2), |
| 237 | ), |
| 238 | ]); |
| 239 | }).timeout(DEFAULT_TIMEOUT.XL); |
| 240 | }); |
| 241 | |
| 242 | describe("Agent with tools", () => { |
| 243 | beforeEach(async () => { |
| 244 | await GUIActions.selectModelFromDropdown(view, "TOOL MOCK LLM"); |
| 245 | await GUIActions.selectModeFromDropdown(view, "Agent"); |
| 246 | }); |
| 247 | |
| 248 | it("should render tool call", async () => { |
| 249 | const [messageInput] = await GUISelectors.getMessageInputFields(view); |
| 250 | await messageInput.sendKeys("Hello"); |
| 251 | await messageInput.sendKeys(Key.ENTER); |
| 252 | |
| 253 | const statusMessage = await TestUtils.waitForSuccess( |
| 254 | () => GUISelectors.getToolCallStatusMessage(view), // Defined in extensions/vscode/e2e/test-continue/config.json's TOOL MOCK LLM that we are calling the exact search tool |
| 255 | DEFAULT_TIMEOUT.SM, |
| 256 | ); |
| 257 | |
| 258 | expect(await statusMessage.getText()).contain( |
| 259 | "Continue viewed the git diff", |
| 260 | ); |
| 261 | }).timeout(DEFAULT_TIMEOUT.MD); |
| 262 | |
| 263 | it("should call tool after approval", async () => { |
| 264 | await GUIActions.toggleToolPolicy(view, "builtin_view_diff", 2); |
| 265 | |
| 266 | const [messageInput] = await GUISelectors.getMessageInputFields(view); |
| 267 | await messageInput.sendKeys("Hello"); |
| 268 | await messageInput.sendKeys(Key.ENTER); |
| 269 | |
| 270 | const acceptToolCallButton = await TestUtils.waitForSuccess(() => |
| 271 | GUISelectors.getAcceptToolCallButton(view), |
| 272 | ); |
| 273 | await acceptToolCallButton.click(); |
| 274 | |
| 275 | const statusMessage = await TestUtils.waitForSuccess( |
| 276 | () => GUISelectors.getToolCallStatusMessage(view), // Defined in extensions/vscode/e2e/test-continue/config.json's TOOL MOCK LLM that we are calling the exact search tool |
| 277 | DEFAULT_TIMEOUT.SM, |
| 278 | ); |
| 279 | |
| 280 | const text = await statusMessage.getText(); |
| 281 | expect(text).contain("the git diff"); |
| 282 | }).timeout(DEFAULT_TIMEOUT.XL); |
| 283 | |
| 284 | it("should cancel tool", async () => { |
| 285 | await GUIActions.toggleToolPolicy(view, "builtin_view_diff", 2); |
| 286 | |
| 287 | const [messageInput] = await GUISelectors.getMessageInputFields(view); |
| 288 | await messageInput.sendKeys("Hello"); |
| 289 | await messageInput.sendKeys(Key.ENTER); |
| 290 | |
| 291 | const cancelToolCallButton = await TestUtils.waitForSuccess(() => |
| 292 | GUISelectors.getRejectToolCallButton(view), |
| 293 | ); |
| 294 | await cancelToolCallButton.click(); |
| 295 | |
| 296 | const statusMessage = await TestUtils.waitForSuccess( |
| 297 | () => GUISelectors.getToolCallStatusMessage(view), // Defined in extensions/vscode/e2e/test-continue/config.json's TOOL MOCK LLM that we are calling the exact search tool |
| 298 | DEFAULT_TIMEOUT.SM, |
| 299 | ); |
| 300 | |
| 301 | const text = await statusMessage.getText(); |
| 302 | expect(text).contain("Continue tried to view the git diff"); |
| 303 | }).timeout(DEFAULT_TIMEOUT.XL); |
| 304 | }); |
| 305 | |
| 306 | describe("Context providers", () => { |
| 307 | it("should successfully use the terminal context provider", async () => { |
| 308 | await GUIActions.selectModelFromDropdown(view, "LAST MESSAGE MOCK LLM"); |
| 309 | |
| 310 | // Enter just the context provider in the input and send |
| 311 | const [messageInput] = await GUISelectors.getMessageInputFields(view); |
| 312 | await messageInput.sendKeys("@"); |
| 313 | await messageInput.sendKeys("terminal"); |
| 314 | await messageInput.sendKeys(Key.ENTER); |
| 315 | await messageInput.sendKeys(Key.ENTER); |
| 316 | |
| 317 | // Open the context items peek |
| 318 | const contextItemsPeek = await GUISelectors.getContextItemsPeek(view); |
| 319 | await contextItemsPeek.click(); |
| 320 | |
| 321 | await TestUtils.waitForSuccess(async () => { |
| 322 | const firstContextItemInPeek = |
| 323 | await GUISelectors.getFirstContextItemsPeekItem(view); |
| 324 | await firstContextItemInPeek.click(); |
| 325 | |
| 326 | // Check that item is there with correct name |
| 327 | const description = await firstContextItemInPeek.getText(); |
| 328 | expect(description).to.include("Terminal"); |
| 329 | }); |
| 330 | |
| 331 | // Check that the contents match what we expect (repeated back by the mock LLM) |
| 332 | await TestUtils.waitForSuccess(() => { |
| 333 | return GUISelectors.getThreadMessageByText( |
| 334 | view, |
| 335 | "Current terminal contents:", |
| 336 | ); |
| 337 | }); |
| 338 | }).timeout(DEFAULT_TIMEOUT.MD); |
| 339 | }); |
| 340 | |
| 341 | describe("Repeat back the system message", () => { |
| 342 | it("should repeat back the system message", async () => { |
| 343 | await GUIActions.selectModelFromDropdown(view, "SYSTEM MESSAGE MOCK LLM"); |
| 344 | const [messageInput] = await GUISelectors.getMessageInputFields(view); |
| 345 | await messageInput.sendKeys("Hello"); |
| 346 | await messageInput.sendKeys(Key.ENTER); |
| 347 | await TestUtils.waitForSuccess(() => |
| 348 | GUISelectors.getThreadMessageByText(view, "TEST_SYS_MSG"), |
| 349 | ); |
| 350 | }); |
| 351 | }); |
| 352 | |
| 353 | describe("Chat Paths", () => { |
| 354 | it("Send many messages → chat auto scrolls → go to history → open previous chat → it is scrolled to the bottom", async () => { |
| 355 | for (let i = 0; i <= 20; i++) { |
| 356 | const { userMessage, llmResponse } = |
| 357 | TestUtils.generateTestMessagePair(i); |
| 358 | await GUIActions.sendMessage({ |
| 359 | view, |
| 360 | message: userMessage, |
| 361 | inputFieldIndex: i, |
| 362 | }); |
| 363 | const response = await TestUtils.waitForSuccess(() => |
| 364 | GUISelectors.getThreadMessageByText(view, llmResponse), |
| 365 | ); |
| 366 | |
| 367 | const viewportHeight = await driver.executeScript( |
| 368 | "return window.innerHeight", |
| 369 | ); |
| 370 | |
| 371 | const isInViewport = await driver.executeScript( |
| 372 | ` |
| 373 | const rect = arguments[0].getBoundingClientRect(); |
| 374 | return ( |
| 375 | rect.top >= 0 && |
| 376 | rect.bottom <= ${viewportHeight} |
| 377 | ); |
| 378 | `, |
| 379 | response, |
| 380 | ); |
| 381 | |
| 382 | expect(isInViewport).to.eq(true); |
| 383 | } |
| 384 | |
| 385 | await view.switchBack(); |
| 386 | |
| 387 | await (await GUISelectors.getHistoryNavButton(view)).click(); |
| 388 | await GUIActions.switchToReactIframe(); |
| 389 | TestUtils.waitForSuccess(async () => { |
| 390 | await (await GUISelectors.getNthHistoryTableRow(view, 0)).click(); |
| 391 | }); |
| 392 | |
| 393 | const { llmResponse } = TestUtils.generateTestMessagePair(20); |
| 394 | const response = await TestUtils.waitForSuccess(() => |
| 395 | GUISelectors.getThreadMessageByText(view, llmResponse), |
| 396 | ); |
| 397 | |
| 398 | const viewportHeight = await driver.executeScript( |
| 399 | "return window.innerHeight", |
| 400 | ); |
| 401 | |
| 402 | const isInViewport = await driver.executeScript( |
| 403 | ` |
| 404 | const rect = arguments[0].getBoundingClientRect(); |
| 405 | return ( |
| 406 | rect.top >= 0 && |
| 407 | rect.bottom <= ${viewportHeight} |
| 408 | ); |
| 409 | `, |
| 410 | response, |
| 411 | ); |
| 412 | |
| 413 | expect(isInViewport).to.eq(true); |
| 414 | }).timeout(DEFAULT_TIMEOUT.XL * 1000); |
| 415 | |
| 416 | it("Open chat and send message → press arrow up and arrow down to cycle through messages → submit another message → press arrow up and arrow down to cycle through messages", async () => { |
| 417 | await GUIActions.sendMessage({ |
| 418 | view, |
| 419 | message: "MESSAGE 1", |
| 420 | inputFieldIndex: 0, |
| 421 | }); |
| 422 | |
| 423 | const input1 = await TestUtils.waitForSuccess(async () => { |
| 424 | return GUISelectors.getMessageInputFieldAtIndex(view, 1); |
| 425 | }); |
| 426 | expect(await input1.getText()).to.equal(""); |
| 427 | |
| 428 | await input1.sendKeys(Key.ARROW_UP); |
| 429 | await driver.wait( |
| 430 | until.elementTextIs(input1, "MESSAGE 1"), |
| 431 | DEFAULT_TIMEOUT.SM, |
| 432 | ); |
| 433 | |
| 434 | await input1.sendKeys(Key.ARROW_DOWN); // First press - bring caret to the end of the message |
| 435 | await input1.sendKeys(Key.ARROW_DOWN); // Second press - trigger message change |
| 436 | await driver.wait(until.elementTextIs(input1, ""), DEFAULT_TIMEOUT.SM); |
| 437 | |
| 438 | await GUIActions.sendMessage({ |
| 439 | view, |
| 440 | message: "MESSAGE 2", |
| 441 | inputFieldIndex: 1, |
| 442 | }); |
| 443 | |
| 444 | const input2 = await TestUtils.waitForSuccess(async () => { |
| 445 | return GUISelectors.getMessageInputFieldAtIndex(view, 2); |
| 446 | }); |
| 447 | expect(await input2.getText()).to.equal(""); |
| 448 | |
| 449 | await input2.sendKeys(Key.ARROW_UP); |
| 450 | await driver.wait( |
| 451 | until.elementTextIs(input2, "MESSAGE 2"), |
| 452 | DEFAULT_TIMEOUT.SM, |
| 453 | ); |
| 454 | |
| 455 | await input2.sendKeys(Key.ARROW_UP); |
| 456 | await driver.wait( |
| 457 | until.elementTextIs(input2, "MESSAGE 1"), |
| 458 | DEFAULT_TIMEOUT.SM, |
| 459 | ); |
| 460 | |
| 461 | await input2.sendKeys(Key.ARROW_DOWN); // First press - bring caret to the end of the message |
| 462 | await input2.sendKeys(Key.ARROW_DOWN); // Second press - trigger message change |
| 463 | await driver.wait( |
| 464 | until.elementTextIs(input2, "MESSAGE 2"), |
| 465 | DEFAULT_TIMEOUT.SM, |
| 466 | ); |
| 467 | |
| 468 | await input2.sendKeys(Key.ARROW_DOWN); |
| 469 | await driver.wait(until.elementTextIs(input2, ""), DEFAULT_TIMEOUT.SM); |
| 470 | }).timeout(DEFAULT_TIMEOUT.XL); |
| 471 | |
| 472 | it("Open chat and type → open history → press new session button → chat opens, empty and in focus", async () => { |
| 473 | const originalTextInput = await GUISelectors.getMessageInputFieldAtIndex( |
| 474 | view, |
| 475 | 0, |
| 476 | ); |
| 477 | await originalTextInput.click(); |
| 478 | await originalTextInput.sendKeys("Hello"); |
| 479 | expect(await originalTextInput.getText()).to.equal("Hello"); |
| 480 | |
| 481 | await view.switchBack(); |
| 482 | |
| 483 | await (await GUISelectors.getHistoryNavButton(view)).click(); |
| 484 | await GUIActions.switchToReactIframe(); |
| 485 | |
| 486 | await view.switchBack(); |
| 487 | await (await GUISelectors.getNewSessionNavButton(view)).click(); |
| 488 | await GUIActions.switchToReactIframe(); |
| 489 | |
| 490 | const newTextInput = await TestUtils.waitForSuccess(() => |
| 491 | GUISelectors.getMessageInputFieldAtIndex(view, 0), |
| 492 | ); |
| 493 | const activeElement: WebElement = await driver.switchTo().activeElement(); |
| 494 | const newTextInputHtml = await newTextInput.getAttribute("outerHTML"); |
| 495 | const activeElementHtml = await activeElement.getAttribute("outerHTML"); |
| 496 | expect(newTextInputHtml).to.equal(activeElementHtml); |
| 497 | |
| 498 | const textInputValue = await newTextInput.getText(); |
| 499 | expect(textInputValue).to.equal(""); |
| 500 | }).timeout(DEFAULT_TIMEOUT.XL); |
| 501 | |
| 502 | it("chat → history → chat", async () => { |
| 503 | const messagePair1 = TestUtils.generateTestMessagePair(1); |
| 504 | await GUIActions.sendMessage({ |
| 505 | view, |
| 506 | message: messagePair1.userMessage, |
| 507 | inputFieldIndex: 0, |
| 508 | }); |
| 509 | await TestUtils.waitForSuccess(() => |
| 510 | GUISelectors.getThreadMessageByText(view, messagePair1.llmResponse), |
| 511 | ); |
| 512 | |
| 513 | const messagePair2 = TestUtils.generateTestMessagePair(2); |
| 514 | await GUIActions.sendMessage({ |
| 515 | view, |
| 516 | message: messagePair2.userMessage, |
| 517 | inputFieldIndex: 1, |
| 518 | }); |
| 519 | await TestUtils.waitForSuccess(() => |
| 520 | GUISelectors.getThreadMessageByText(view, messagePair2.llmResponse), |
| 521 | ); |
| 522 | |
| 523 | /** |
| 524 | * SWITCHING BACK AND FORTH |
| 525 | * We are switching back and forth here because the history is broken. |
| 526 | * It only updates once a another chat is opened, so we need to open a |
| 527 | * different chat first. |
| 528 | */ |
| 529 | await view.switchBack(); |
| 530 | await (await GUISelectors.getHistoryNavButton(view)).click(); |
| 531 | await GUIActions.switchToReactIframe(); |
| 532 | |
| 533 | await (await GUISelectors.getNthHistoryTableRow(view, 0)).click(); |
| 534 | |
| 535 | await view.switchBack(); |
| 536 | await (await GUISelectors.getHistoryNavButton(view)).click(); |
| 537 | /** |
| 538 | * END OF SWITCHING BACK AND FORTH |
| 539 | */ |
| 540 | |
| 541 | await GUIActions.switchToReactIframe(); |
| 542 | await (await GUISelectors.getNthHistoryTableRow(view, 0)).click(); |
| 543 | |
| 544 | await GUISelectors.getThreadMessageByText(view, messagePair1.llmResponse); |
| 545 | await GUISelectors.getThreadMessageByText(view, messagePair2.llmResponse); |
| 546 | |
| 547 | const messagePair3 = TestUtils.generateTestMessagePair(3); |
| 548 | await GUIActions.sendMessage({ |
| 549 | view, |
| 550 | message: messagePair3.userMessage, |
| 551 | inputFieldIndex: 2, |
| 552 | }); |
| 553 | await TestUtils.waitForSuccess(() => |
| 554 | GUISelectors.getThreadMessageByText(view, messagePair3.llmResponse), |
| 555 | ); |
| 556 | }).timeout(DEFAULT_TIMEOUT.XL); |
| 557 | }); |
| 558 | }); |