langflow/src/frontend/tests/core/unit/nestedComponent.spec.ts
Cristhian Zanforlin Lousa 41ed0bb50b
fix: Improve test accuracy with component generation steps and robust assertions (nightly fix) (#7156)
 (Custom Component Generator.spec.ts): Add test case for filling input with custom component description before sending
 (nestedComponent.spec.ts): Add test case for toggling legacy switch in sidebar options and checking if it is checked after clicking
2025-03-19 07:06:19 -03:00

88 lines
3.4 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { adjustScreenView } from "../../utils/adjust-screen-view";
import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";
test(
"user should be able to use nested component",
{ tag: ["@release", "@workspace"] },
async ({ page }) => {
await awaitBootstrapTest(page);
await page.waitForSelector('[data-testid="blank-flow"]', {
timeout: 30000,
});
await page.getByTestId("blank-flow").click();
await page.getByTestId("sidebar-search-input").click();
await page.getByTestId("sidebar-search-input").fill("alter metadata");
await page.getByTestId("sidebar-options-trigger").click();
await page
.getByTestId("sidebar-legacy-switch")
.isVisible({ timeout: 5000 });
await page.getByTestId("sidebar-legacy-switch").click();
await expect(page.getByTestId("sidebar-legacy-switch")).toBeChecked();
await page.getByTestId("sidebar-options-trigger").click();
await page.waitForTimeout(500);
await page.waitForSelector('[data-testid="processingAlter Metadata"]', {
timeout: 3000,
});
await page
.getByTestId("processingAlter Metadata")
.hover()
.then(async () => {
await page.getByTestId("add-component-button-alter-metadata").click();
});
await adjustScreenView(page);
await page.getByTestId("dict_nesteddict_metadata").first().click();
await page.getByText("{}").last().clear();
await page
.getByRole("textbox")
.last()
.fill(
'{"keytest": "proptest", "keytest1": "proptest1", "keytest2": "proptest2"}',
);
await page.getByTitle("Switch to tree mode (current mode: text)").click();
expect(await page.getByText("keytest", { exact: true }).count()).toBe(1);
expect(await page.getByText("keytest1", { exact: true }).count()).toBe(1);
expect(await page.getByText("keytest2", { exact: true }).count()).toBe(1);
expect(await page.getByText("proptest", { exact: true }).count()).toBe(1);
expect(await page.getByText("proptest1", { exact: true }).count()).toBe(1);
expect(await page.getByText("proptest2", { exact: true }).count()).toBe(1);
await page.getByText("Save").last().click();
await page.getByTestId("div-generic-node").click();
await page.getByTestId("more-options-modal").click();
await page.getByTestId("advanced-button-modal").click();
await page.getByTestId("edit_dict_nesteddict_edit_metadata").last().click();
await page.getByTitle("Switch to tree mode (current mode: text)").click();
await page.waitForSelector(".jse-bracket", {
timeout: 3000,
});
expect(await page.getByText("keytest", { exact: true }).count()).toBe(1);
expect(await page.getByText("keytest1", { exact: true }).count()).toBe(1);
expect(await page.getByText("keytest2", { exact: true }).count()).toBe(1);
expect(await page.getByText("proptest", { exact: true }).count()).toBe(1);
expect(await page.getByText("proptest1", { exact: true }).count()).toBe(1);
expect(await page.getByText("proptest2", { exact: true }).count()).toBe(1);
await page
.getByText("proptest", { exact: true })
.last()
.click({ button: "right" });
await page.getByText("Remove").last().click();
expect(await page.getByText("keytest", { exact: true }).count()).toBe(0);
expect(await page.getByText("proptest", { exact: true }).count()).toBe(0);
},
);