From 6c6127203fa83b9c9e075a4490f9d1cdf6c172c1 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 18 Oct 2023 21:56:53 -0300 Subject: [PATCH] test(saveComponents.spec.ts): add test case to make front work without backend test(saveComponents.spec.ts): add test case to save default component and delete it --- .../tests/onlyFront/saveComponents.spec.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/frontend/tests/onlyFront/saveComponents.spec.ts b/src/frontend/tests/onlyFront/saveComponents.spec.ts index e83dde7bd..a2539090b 100644 --- a/src/frontend/tests/onlyFront/saveComponents.spec.ts +++ b/src/frontend/tests/onlyFront/saveComponents.spec.ts @@ -17,6 +17,7 @@ test.describe("save component tests", () => { /// test("save group component tests", async ({ page }) => { + //make front work withoput backend await page.routeFromHAR("harFiles/langflow.har", { url: "**/api/v1/**", update: false, @@ -211,4 +212,43 @@ test.describe("save component tests", () => { ) ).toBeTruthy(); }); + + test("save default component and delete it", async ({ page }) => { + await page.routeFromHAR("harFiles/langflow.har", { + url: "**/api/v1/**", + update: false, + }); + await page.route("**/api/v1/flows/", async (route) => { + const json = { + id: "e9ac1bdc-429b-475d-ac03-d26f9a2a3210", + }; + await route.fulfill({ json, status: 201 }); + }); + await page.goto("http://localhost:3000/"); + await page.locator("span").filter({ hasText: "My Collection" }).isVisible(); + await page.locator('//*[@id="new-project-btn"]').click(); + await page.waitForTimeout(2000); + + await page.getByPlaceholder("Search").click(); + await page.getByPlaceholder("Search").fill("Chroma"); + + await page + .locator('//*[@id="vectorstoresChroma"]') + .dragTo(page.locator('//*[@id="react-flow-id"]')); + await saveComponent(page, /.*rf__node-Chroma.*/, 1); + await page.getByTestId(/.*rf__node-Chroma.*/).press("Backspace"); + await page.getByPlaceholder("Search").click(); + await page.getByPlaceholder("Search").fill(""); + await page.getByPlaceholder("Search").fill("Chroma"); + await page.locator("#custom_componentsChroma").getByRole("combobox").click({ + button: "right", + }); + await page.getByLabel("Delete").click(); + await page.getByPlaceholder("Search").click(); + await page.getByPlaceholder("Search").fill(" "); + await page.getByPlaceholder("Search").fill("Chroma"); + expect( + await page.locator("#custom_componentsChroma").isVisible() + ).toBeFalsy(); + }); });