| | import { expect, test } from "@playwright/test"; |
| |
|
| | test( |
| | "user can search and add components using keyboard shortcuts", |
| | { tag: ["@release", "@workspace"] }, |
| | async ({ page }) => { |
| | |
| | await page.goto("/"); |
| | await page.waitForSelector('[data-testid="mainpage_title"]', { |
| | timeout: 30000, |
| | }); |
| |
|
| | let modalCount = 0; |
| | try { |
| | const modalTitleElement = await page?.getByTestId("modal-title"); |
| | if (modalTitleElement) { |
| | modalCount = await modalTitleElement.count(); |
| | } |
| | } catch (error) { |
| | modalCount = 0; |
| | } |
| |
|
| | while (modalCount === 0) { |
| | await page.getByText("New Flow", { exact: true }).click(); |
| | await page.waitForSelector('[data-testid="modal-title"]', { |
| | timeout: 3000, |
| | }); |
| | modalCount = await page.getByTestId("modal-title")?.count(); |
| | } |
| |
|
| | |
| | await page.getByTestId("blank-flow").click(); |
| | await page.waitForSelector('[data-testid="sidebar-search-input"]', { |
| | timeout: 1000, |
| | }); |
| |
|
| | |
| | await page.keyboard.press("/"); |
| |
|
| | |
| | await expect(page.getByTestId("sidebar-search-input")).toBeFocused({ |
| | timeout: 1000, |
| | }); |
| | await expect(page.getByTestId("inputsChat Input")).not.toBeVisible(); |
| |
|
| | |
| | await page.keyboard.type("chat"); |
| |
|
| | await expect(page.getByTestId("inputsChat Input")).toBeVisible({ |
| | timeout: 1000, |
| | }); |
| |
|
| | |
| | await expect(page.getByTestId("inputsChat Input")).toBeVisible(); |
| |
|
| | |
| | await page.keyboard.press("Tab"); |
| | await page.keyboard.press("Tab"); |
| |
|
| | |
| | await expect(page.getByTestId("inputsChat Input")).toBeVisible(); |
| | await expect(page.getByTestId("outputsChat Output")).toBeVisible(); |
| |
|
| | |
| | await page.keyboard.press("Space"); |
| |
|
| | |
| | const addedComponent = await page.locator(".react-flow__node").first(); |
| | await expect(addedComponent).toBeVisible(); |
| |
|
| | |
| | await page.getByTestId("sidebar-search-input").clear(); |
| | await expect(page.getByTestId("inputsChat Input")).not.toBeVisible(); |
| |
|
| | |
| | await page.keyboard.press("/"); |
| | await page.keyboard.type("prompt"); |
| |
|
| | |
| | await expect(page.getByTestId("promptsPrompt")).toBeVisible(); |
| |
|
| | await page.keyboard.press("Tab"); |
| | await page.keyboard.press("Tab"); |
| | await page.keyboard.press("Enter"); |
| |
|
| | |
| | const nodeCount = await page.locator(".react-flow__node").count(); |
| | expect(nodeCount).toBe(2); |
| |
|
| | |
| | await page.keyboard.press("/"); |
| | await page.getByTestId("sidebar-search-input").clear(); |
| | await expect(page.getByTestId("sidebar-search-input")).toHaveValue(""); |
| | await expect(page.getByTestId("inputsChat Input")).not.toBeVisible(); |
| |
|
| | await expect(page.getByTestId("sidebar-search-input")).toBeFocused(); |
| | await page.keyboard.press("Escape"); |
| | await expect(page.getByTestId("sidebar-search-input")).not.toBeFocused(); |
| | await expect(page.getByTestId("inputsChat Input")).not.toBeVisible(); |
| | }, |
| | ); |
| |
|