Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions src/frontend/tests/core/features/actionsMainPage-shard-1.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { test } from "../../fixtures";
import { expect, test } from "../../fixtures";
import { adjustScreenView } from "../../utils/adjust-screen-view";
import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";

import { TEXTS } from "../../utils/constants/texts";
test(
"select and delete a flow",
{ tag: ["@release", "@mainpage"] },
async ({ page }) => {
await awaitBootstrapTest(page);

await page.getByTestId("side_nav_options_all-templates").click();
await page.getByRole("heading", { name: "Basic Prompting" }).click();
await page
.getByRole("heading", { name: TEXTS.templateBasicPrompting })
.click();

await page.waitForSelector('[data-testid="sidebar-search-input"]', {
timeout: 100000,
Expand All @@ -26,31 +29,35 @@ test(
timeout: 1000,
});
// click on the delete button
await page.getByText("Delete").last().click();
await page.getByText(TEXTS.delete).last().click();
await page.getByText("This can't be undone.").isVisible({
timeout: 1000,
});

//confirm the deletion in the modal
await page.getByText("Delete").last().click();
await page.getByText(TEXTS.delete).last().click();

await page.getByText("Selected items deleted successfully").isVisible();
await expect(
page.getByText("Selected items deleted successfully"),
).toBeVisible();
},
);

test("search flows", { tag: ["@release", "@mainpage"] }, async ({ page }) => {
await awaitBootstrapTest(page);

await page.getByTestId("side_nav_options_all-templates").click();
await page.getByRole("heading", { name: "Basic Prompting" }).click();
await page
.getByRole("heading", { name: TEXTS.templateBasicPrompting })
.click();

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

await page.getByTestId("icon-ChevronLeft").first().click();

await page.getByText("New Flow").isVisible();
await expect(page.getByText("New Flow")).toBeVisible();
await page.getByTestId("new-project-btn").click();
await page.getByTestId("side_nav_options_all-templates").click();
await page.getByRole("heading", { name: "Memory Chatbot" }).click();
Expand All @@ -70,9 +77,11 @@ test("search flows", { tag: ["@release", "@mainpage"] }, async ({ page }) => {

await page.getByTestId("icon-ChevronLeft").first().click();
await page.getByPlaceholder("Search flows").fill("Memory Chatbot");
await page.getByText("Memory Chatbot", { exact: true }).isVisible();
await expect(page.getByText("Memory Chatbot", { exact: true })).toBeVisible();
await page.getByText("Document Q&A", { exact: true }).isHidden();
await page.getByText("Basic Prompting", { exact: true }).isHidden();
await page
.getByText(TEXTS.templateBasicPrompting, { exact: true })
.isHidden();
});

test(
Expand All @@ -83,11 +92,13 @@ test(

if (await page.getByTestId("components-btn").isVisible()) {
await page.getByTestId("side_nav_options_all-templates").click();
await page.getByRole("heading", { name: "Basic Prompting" }).click();
await page
.getByRole("heading", { name: TEXTS.templateBasicPrompting })
.click();

await adjustScreenView(page, { numberOfZoomOut: 2 });

await page.getByText("Chat Input").first().click();
await page.getByText(TEXTS.componentChatInput).first().click();
await page.waitForSelector('[data-testid="more-options-modal"]', {
timeout: 1000,
});
Expand Down Expand Up @@ -123,15 +134,19 @@ test(

await page.getByTestId("icon-ChevronLeft").first().click();

const exitButton = await page.getByText("Exit", { exact: true }).count();
const exitButton = await page
.getByText(TEXTS.exit, { exact: true })
.count();

if (exitButton > 0) {
await page.getByText("Exit", { exact: true }).click();
await page.getByText(TEXTS.exit, { exact: true }).click();
}

await page.getByTestId("components-btn").click();
await page.getByPlaceholder("Search components").fill("Chat Input");
await page.getByText("Chat Input", { exact: true }).isVisible();
await expect(
page.getByText(TEXTS.componentChatInput, { exact: true }),
).toBeVisible();
await page.getByText("Prompt", { exact: true }).isHidden();
await page.getByText("OpenAI", { exact: true }).isHidden();
}
Expand Down
81 changes: 57 additions & 24 deletions src/frontend/tests/core/features/auto-login-off.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";
import { renameFlow } from "../../utils/rename-flow";
import { zoomOut } from "../../utils/zoom-out";

import { TEXTS } from "../../utils/constants/texts";
test(
"when auto_login is false, admin can CRUD user's and should see just your own flows",
{ tag: ["@release", "@api", "@database", "@mainpage"] },
Expand Down Expand Up @@ -41,16 +42,22 @@ test(

await page.goto("/");

await page.waitForSelector("text=sign in to langflow", { timeout: 30000 });
await page.waitForSelector(`text=${TEXTS.authSignInHeader}`, {
timeout: 30000,
});

await page.getByPlaceholder("Username").fill("langflow");
await page.getByPlaceholder("Password").fill("langflow");
await page
.getByPlaceholder(TEXTS.placeholderUsername)
.fill(TEXTS.authDefaultCredential);
await page
.getByPlaceholder(TEXTS.placeholderPassword)
.fill(TEXTS.authDefaultCredential);

await page.evaluate(() => {
sessionStorage.removeItem("testMockAutoLogin");
});

await page.getByRole("button", { name: "Sign In" }).click();
await page.getByRole("button", { name: TEXTS.signIn }).click();

await page.waitForSelector('[data-testid="mainpage_title"]', {
timeout: 30000,
Expand All @@ -67,7 +74,10 @@ test(
//CRUD an user
await page.getByText("New User", { exact: true }).click();

await page.getByPlaceholder("Username").last().fill(randomName);
await page
.getByPlaceholder(TEXTS.placeholderUsername)
.last()
.fill(randomName);
await page.locator('input[name="password"]').fill(randomPassword);
await page.locator('input[name="confirmpassword"]').fill(randomPassword);

Expand All @@ -77,7 +87,7 @@ test(

await page.locator("#is_active").click();

await page.getByText("Save", { exact: true }).click();
await page.getByText(TEXTS.save, { exact: true }).click();

await page.waitForSelector("text=new user added", { timeout: 30000 });

Expand All @@ -86,7 +96,7 @@ test(
});

await page.getByTestId("icon-Trash2").last().click();
await page.getByText("Delete", { exact: true }).last().click();
await page.getByText(TEXTS.delete, { exact: true }).last().click();

await page.waitForSelector("text=user deleted", { timeout: 30000 });

Expand All @@ -97,7 +107,10 @@ test(

await page.getByText("New User", { exact: true }).click();

await page.getByPlaceholder("Username").last().fill(randomName);
await page
.getByPlaceholder(TEXTS.placeholderUsername)
.last()
.fill(randomName);
await page.locator('input[name="password"]').fill(randomPassword);
await page.locator('input[name="confirmpassword"]').fill(randomPassword);

Expand All @@ -107,22 +120,28 @@ test(

await page.locator("#is_active").click();

await page.getByText("Save", { exact: true }).click();
await page.getByText(TEXTS.save, { exact: true }).click();

await page.waitForSelector("text=new user added", { timeout: 30000 });

const searchResponse = page.waitForResponse(
(response) =>
response.url().includes("/api/v1/users") && response.status() === 200,
);
await page.getByPlaceholder("Username").last().fill(randomName);
await page
.getByPlaceholder(TEXTS.placeholderUsername)
.last()
.fill(randomName);
await searchResponse;

await page.getByTestId("icon-Pencil").last().click();

await page.getByPlaceholder("Username").last().fill(secondRandomName);
await page
.getByPlaceholder(TEXTS.placeholderUsername)
.last()
.fill(secondRandomName);

await page.getByText("Save", { exact: true }).click();
await page.getByText(TEXTS.save, { exact: true }).click();

await page.waitForSelector("text=user edited", { timeout: 30000 });

Expand All @@ -146,7 +165,9 @@ test(
await awaitBootstrapTest(page, { skipGoto: true });

await page.getByTestId("side_nav_options_all-templates").click();
await page.getByRole("heading", { name: "Basic Prompting" }).click();
await page
.getByRole("heading", { name: TEXTS.templateBasicPrompting })
.click();

await adjustScreenView(page, { numberOfZoomOut: 1 });

Expand Down Expand Up @@ -182,18 +203,22 @@ test(
sessionStorage.setItem("testMockAutoLogin", "true");
});

await page.getByText("Logout", { exact: true }).click();
await page.getByText(TEXTS.logout, { exact: true }).click();

await page.waitForSelector("text=sign in to langflow", { timeout: 30000 });
await page.waitForSelector(`text=${TEXTS.authSignInHeader}`, {
timeout: 30000,
});

await page.getByPlaceholder("Username").fill(secondRandomName);
await page.getByPlaceholder("Password").fill(randomPassword);
await page
.getByPlaceholder(TEXTS.placeholderUsername)
.fill(secondRandomName);
await page.getByPlaceholder(TEXTS.placeholderPassword).fill(randomPassword);

await page.waitForSelector("text=Sign in", {
timeout: 1500,
});

await page.getByRole("button", { name: "Sign In" }).click();
await page.getByRole("button", { name: TEXTS.signIn }).click();

await page.evaluate(() => {
sessionStorage.removeItem("testMockAutoLogin");
Expand All @@ -216,7 +241,9 @@ test(
await awaitBootstrapTest(page, { skipGoto: true });

await page.getByTestId("side_nav_options_all-templates").click();
await page.getByRole("heading", { name: "Basic Prompting" }).click();
await page
.getByRole("heading", { name: TEXTS.templateBasicPrompting })
.click();

await adjustScreenView(page, { numberOfZoomOut: 2 });

Expand Down Expand Up @@ -249,18 +276,24 @@ test(
sessionStorage.setItem("testMockAutoLogin", "true");
});

await page.getByText("Logout", { exact: true }).click();
await page.getByText(TEXTS.logout, { exact: true }).click();

await page.waitForSelector("text=sign in to langflow", { timeout: 30000 });
await page.waitForSelector(`text=${TEXTS.authSignInHeader}`, {
timeout: 30000,
});

await page.getByPlaceholder("Username").fill("langflow");
await page.getByPlaceholder("Password").fill("langflow");
await page
.getByPlaceholder(TEXTS.placeholderUsername)
.fill(TEXTS.authDefaultCredential);
await page
.getByPlaceholder(TEXTS.placeholderPassword)
.fill(TEXTS.authDefaultCredential);

await page.evaluate(() => {
sessionStorage.removeItem("testMockAutoLogin");
});

await page.getByRole("button", { name: "Sign In" }).click();
await page.getByRole("button", { name: TEXTS.signIn }).click();

await page.waitForSelector('[data-testid="mainpage_title"]', {
timeout: 30000,
Expand Down
Loading
Loading