(GenericNode/index.tsx): add unique id to input element for accessibility and testing purposes

🐛 (input.tsx): add missing data-testid attribute to input element
🐛 (group.spec.ts): fix test case to correctly group and ungroup nodes, update selectors to match changes in UI
This commit is contained in:
cristhianzl 2024-04-01 22:56:50 -03:00
commit aa2c148614
3 changed files with 18 additions and 18 deletions

View file

@ -444,6 +444,7 @@ export default function GenericNode({
onChange={setNodeName}
password={false}
blurOnEnter={true}
id={`input-title-${data.node?.display_name}`}
/>
</div>
) : (

View file

@ -8,6 +8,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
return (
<input
data-testid=""
type={type}
className={cn(
"nopan nodelete nodrag noundo nocopy primary-input",

View file

@ -1,29 +1,27 @@
import { expect, test } from "@playwright/test";
import { test } from "@playwright/test";
test.describe("group node test", () => {
/// <reference lib="dom"/>
test("group and ungroup updating values", async ({ page }) => {
await page.goto("http:localhost:3000/");
await page.goto("/");
await page.locator('//*[@id="new-project-btn"]').click();
await page.getByRole("heading", { name: "Data Ingestion" }).click();
await page
.getByRole("heading", { name: "Basic Prompting" })
.first()
.click();
await page.waitForTimeout(2000);
await page.getByLabel("fit view").click();
await page.keyboard.down("Control");
await page
.getByTestId("title-OpenAIEmbeddings")
.click({ modifiers: ["Control"] });
await page.getByTestId("title-URL").click({ modifiers: ["Control"] });
await page
.getByTestId("title-Recursive Character Text Splitter")
.click({ modifiers: ["Control"] });
await page.keyboard.up("Control");
await page.getByLabel("fit view").first().click();
await page.getByTestId("title-OpenAI").click({ modifiers: ["Control"] });
await page.getByTestId("title-Prompt").click({ modifiers: ["Control"] });
await page.getByTestId("title-OpenAI").click({ modifiers: ["Control"] });
await page.getByRole("button", { name: "Group" }).click();
await page.getByTestId(/input-collection_name_Chroma-.*/).click();
await page.getByTestId(/input-collection_name_Chroma-.*/).fill("test");
await page.getByTestId("title-Group").click();
await page.getByTestId("title-Group").dblclick();
await page.getByTestId("input-title-Group").first().fill("test");
await page.getByTestId("icon-Ungroup").first().click();
await page.keyboard.press("Control+g");
const value = await page.getByTestId("input-collection_name").inputValue();
expect(value).toBe("test");
await page.getByTestId("title-OpenAI").isVisible();
await page.getByTestId("title-Prompt").isVisible();
});
});