test: add another testing scenario

This commit is contained in:
tomasz-io 2024-12-20 09:46:14 -08:00
parent d59971c61e
commit bcdc7f75b2

View file

@ -13,6 +13,8 @@ import { GUISelectors } from "../selectors/GUI.selectors";
import { GUIActions } from "../actions/GUI.actions";
import { expect } from "chai";
import { TestUtils } from "../TestUtils";
import { Test } from "mocha";
import { KeyboardShortcutsActions } from "../actions/KeyboardShortcuts.actions";
describe("Cmd+L Shortcut Test", () => {
let driver: WebDriver;
@ -77,6 +79,42 @@ describe("Cmd+L Shortcut Test", () => {
expect(await textInput.isDisplayed()).to.equal(false);
}).timeout(DEFAULT_TIMEOUT.XL);
it("Send a message → focus code editor (not sidebar) → cmd+L → should focus sidebar and start a new session", async () => {
await GUIActions.executeFocusContinueInputShortcut(driver);
({ view } = await GUIActions.switchToReactIframe());
const { userMessage: userMessage0 } = TestUtils.generateTestMessagePair(0);
await GUIActions.sendMessage({
view,
message: userMessage0,
inputFieldIndex: 0,
});
await view.switchBack();
KeyboardShortcutsActions.HACK__typeWithSelect(editor, "hello");
await TestUtils.waitForTimeout(DEFAULT_TIMEOUT.XS);
await GUIActions.executeFocusContinueInputShortcut(driver);
({ view } = await GUIActions.switchToReactIframe());
await TestUtils.waitForTimeout(DEFAULT_TIMEOUT.XS);
const textInput = await TestUtils.waitForSuccess(() =>
GUISelectors.getMessageInputFieldAtIndex(view, 0),
);
const activeElement: WebElement = await driver.switchTo().activeElement();
const textInputHtml = await textInput.getAttribute("outerHTML");
const activeElementHtml = await activeElement.getAttribute("outerHTML");
expect(textInputHtml).to.equal(activeElementHtml);
await GUIActions.executeFocusContinueInputShortcut(driver);
expect(await textInput.isDisplayed()).to.equal(false);
}).timeout(DEFAULT_TIMEOUT.XL * 1000);
it("Should create a code block when Cmd+L is pressed with text highlighted", async () => {
const text = "Hello, world!";