Skip to content

Commit

Permalink
fix: update tests FE (langflow-ai#2493)
Browse files Browse the repository at this point in the history
* bugfix: update tests FE

* ✅ (tests): add end-to-end tests for deleting components and flows
✅ (tsconfig.json): update tsconfig to include new deleteFlows.spec.ts test file

* ♻️ (dropdownComponent.spec.ts): remove redundant test cases for showendpoint_url to streamline test suite

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
(cherry picked from commit 871271e)
  • Loading branch information
Cristhianzl authored and nicoloboschi committed Jul 3, 2024
1 parent 0e81c72 commit 5015565
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 63 deletions.
55 changes: 55 additions & 0 deletions src/frontend/tests/end-to-end/deleteComponents.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { test } from "@playwright/test";

test("should add API-KEY", async ({ page }) => {
await page.goto("/");
await page.waitForTimeout(1000);

await page.getByTestId("button-store").click();
await page.waitForTimeout(1000);

await page.getByTestId("api-key-button-store").click();
await page
.getByPlaceholder("Insert your API Key")
.fill("testtesttesttesttesttest");

await page.getByTestId("api-key-save-button-store").click();

await page.waitForTimeout(2000);
await page.getByText("Success! Your API Key has been saved.").isVisible();

await page
.getByPlaceholder("Insert your API Key")
.fill(process.env.STORE_API_KEY ?? "");
await page.getByTestId("api-key-save-button-store").click();

await page.waitForTimeout(2000);
await page.getByText("Success! Your API Key has been saved.").isVisible();

await page.waitForTimeout(2000);
await page.getByText("API Key Error").isHidden();
});

test("should delete a component", async ({ page }) => {
await page.goto("/");
await page.waitForTimeout(2000);
await page.getByText("Store").nth(0).click();
await page.getByTestId("install-Basic RAG").click();
await page.waitForTimeout(5000);
await page.getByText("My Collection").nth(0).click();
await page.getByText("Components").first().click();
await page.getByText("Basic RAG").first().isVisible();

await page.waitForSelector('[data-testid="checkbox-component"]', {
timeout: 100000,
});

await page.getByTestId("checkbox-component").first().click();

await page.getByTestId("icon-Trash2").click();
await page
.getByText("Are you sure you want to delete the selected component?")
.isVisible();
await page.getByText("Delete").nth(1).click();
await page.waitForTimeout(1000);
await page.getByText("Successfully").first().isVisible();
});
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,3 @@ test("should delete a flow", async ({ page }) => {
await page.waitForTimeout(1000);
await page.getByText("Successfully").first().isVisible();
});

test("should delete a component", async ({ page }) => {
await page.goto("/");
await page.waitForTimeout(2000);
await page.getByText("Store").nth(0).click();
await page.getByTestId("install-Basic RAG").click();
await page.waitForTimeout(5000);
await page.getByText("My Collection").nth(0).click();
await page.getByText("Components").first().click();
await page.getByText("Basic RAG").first().isVisible();

await page.waitForSelector('[data-testid="checkbox-component"]', {
timeout: 100000,
});

await page.getByTestId("checkbox-component").first().click();

await page.getByTestId("icon-Trash2").click();
await page
.getByText("Are you sure you want to delete the selected component?")
.isVisible();
await page.getByText("Delete").nth(1).click();
await page.waitForTimeout(1000);
await page.getByText("Successfully").first().isVisible();
});
32 changes: 0 additions & 32 deletions src/frontend/tests/end-to-end/dropdownComponent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ test("dropDownComponent", async ({ page }) => {
expect(false).toBeTruthy();
}

await page.locator('//*[@id="showcache"]').click();
expect(await page.locator('//*[@id="showcache"]').isChecked()).toBeFalsy();

await page.locator('//*[@id="showcache"]').click();
expect(await page.locator('//*[@id="showcache"]').isChecked()).toBeTruthy();

await page.locator('//*[@id="showcredentials_profile_name"]').click();
expect(
await page.locator('//*[@id="showcredentials_profile_name"]').isChecked(),
Expand All @@ -92,16 +86,6 @@ test("dropDownComponent", async ({ page }) => {
await page.locator('//*[@id="showcredentials_profile_name"]').isChecked(),
).toBeTruthy();

await page.locator('//*[@id="showendpoint_url"]').click();
expect(
await page.locator('//*[@id="showendpoint_url"]').isChecked(),
).toBeFalsy();

await page.locator('//*[@id="showendpoint_url"]').click();
expect(
await page.locator('//*[@id="showendpoint_url"]').isChecked(),
).toBeTruthy();

await page.locator('//*[@id="showregion_name"]').click();
expect(
await page.locator('//*[@id="showregion_name"]').isChecked(),
Expand All @@ -122,12 +106,6 @@ test("dropDownComponent", async ({ page }) => {
await page.locator('//*[@id="showmodel_id"]').isChecked(),
).toBeTruthy();

await page.locator('//*[@id="showcache"]').click();
expect(await page.locator('//*[@id="showcache"]').isChecked()).toBeFalsy();

await page.locator('//*[@id="showcache"]').click();
expect(await page.locator('//*[@id="showcache"]').isChecked()).toBeTruthy();

await page.locator('//*[@id="showcredentials_profile_name"]').click();
expect(
await page.locator('//*[@id="showcredentials_profile_name"]').isChecked(),
Expand All @@ -138,16 +116,6 @@ test("dropDownComponent", async ({ page }) => {
await page.locator('//*[@id="showcredentials_profile_name"]').isChecked(),
).toBeTruthy();

await page.locator('//*[@id="showendpoint_url"]').click();
expect(
await page.locator('//*[@id="showendpoint_url"]').isChecked(),
).toBeFalsy();

await page.locator('//*[@id="showendpoint_url"]').click();
expect(
await page.locator('//*[@id="showendpoint_url"]').isChecked(),
).toBeTruthy();

await page.locator('//*[@id="showregion_name"]').click();
expect(
await page.locator('//*[@id="showregion_name"]').isChecked(),
Expand Down
4 changes: 0 additions & 4 deletions src/frontend/tests/end-to-end/keyPairListComponent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ test("KeypairListComponent", async ({ page }) => {
await page.getByTestId("more-options-modal").click();
await page.getByTestId("edit-button-modal").click();

await page.locator('//*[@id="showcache"]').click();
expect(await page.locator('//*[@id="showcache"]').isChecked()).toBeFalsy();
await page.locator('//*[@id="showcredentials_profile_name"]').click();
expect(
await page.locator('//*[@id="showcredentials_profile_name"]').isChecked(),
Expand All @@ -109,8 +107,6 @@ test("KeypairListComponent", async ({ page }) => {
expect(
await page.locator('//*[@id="showcredentials_profile_name"]').isChecked(),
).toBeTruthy();
await page.locator('//*[@id="showcache"]').click();
expect(await page.locator('//*[@id="showcache"]').isChecked()).toBeTruthy();

await page.locator('//*[@id="editNodekeypair0"]').click();
await page.locator('//*[@id="editNodekeypair0"]').fill("testtesttesttest");
Expand Down
5 changes: 4 additions & 1 deletion src/frontend/tests/end-to-end/store-shard-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ test("should find a searched Component on Store", async ({ page }) => {
await page.waitForTimeout(1000);

await page.getByTestId("button-store").click();
await page.waitForTimeout(1000);

await page.waitForSelector('[data-testid="search-store-input"]', {
timeout: 100000,
});

await page.getByTestId("search-store-input").fill("File Loader");
await page.getByTestId("search-store-button").click();
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"tests/end-to-end/chatInputOutputUser-shard-2.spec.ts",
"tests/end-to-end/codeAreaModalComponent.spec.ts",
"tests/end-to-end/curlApiGeneration.spec.ts",
"tests/end-to-end/deleteComponentFlows.spec.ts",
"tests/end-to-end/deleteFlows.spec.ts",
"tests/end-to-end/dragAndDrop.spec.ts",
"tests/end-to-end/dropdownComponent.spec.ts",
"tests/end-to-end/fileUploadComponent.spec.ts",
Expand Down

0 comments on commit 5015565

Please sign in to comment.