forked from langflow-ai/langflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: "Start Here" button not working as expected + fe tests (langflow…
…-ai#3910) * ✅ (general-bugs-shard-3909.spec.ts): add test case to ensure user can create a new flow by clicking on "Start Here" button * ✨ (componentsComponent/index.tsx): Add NewFlowModal component to allow users to create a new flow 📝 (componentsComponent/index.tsx): Update ComponentsComponent to handle opening and closing of NewFlowModal * ✨ (emptyComponent/index.tsx): refactor EmptyComponent to use useIsFetching hook from @tanstack/react-query for loading state and pass handleOpenModal as a prop to improve code readability and maintainability * ✨ (componentsComponent/index.tsx): refactor handleOpenModal function to improve code readability and maintainability
- Loading branch information
1 parent
a4677c7
commit 1d8e0a8
Showing
3 changed files
with
107 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 26 additions & 26 deletions
52
src/frontend/src/pages/MainPage/components/emptyComponent/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
import { useState } from "react"; | ||
import NewFlowModal from "../../../../modals/newFlowModal"; | ||
import { useIsFetching } from "@tanstack/react-query"; | ||
|
||
type EmptyComponentProps = {}; | ||
type EmptyComponentProps = { | ||
handleOpenModal: () => void; | ||
}; | ||
|
||
const EmptyComponent = ({}: EmptyComponentProps) => { | ||
const [openModal, setOpenModal] = useState(false); | ||
const EmptyComponent = ({ handleOpenModal }: EmptyComponentProps) => { | ||
const isLoadingFolders = !!useIsFetching({ | ||
queryKey: ["useGetFolders"], | ||
exact: false, | ||
}); | ||
|
||
return ( | ||
<> | ||
<div className="mt-2 flex w-full items-center justify-center text-center"> | ||
<div className="flex-max-width h-full flex-col"> | ||
<div className="align-center flex w-full justify-center gap-1"> | ||
<span className="text-muted-foreground"> | ||
This folder is empty. New? | ||
</span> | ||
<span className="transition-colors hover:text-muted-foreground"> | ||
<NewFlowModal open={openModal} setOpen={setOpenModal} /> | ||
<button | ||
onClick={() => { | ||
setOpenModal(true); | ||
}} | ||
className="underline" | ||
> | ||
Start Here | ||
</button> | ||
</span> | ||
<span className="animate-pulse">🚀</span> | ||
</div> | ||
<div className="mt-2 flex w-full items-center justify-center text-center"> | ||
<div className="flex-max-width h-full flex-col"> | ||
<div className="align-center flex w-full justify-center gap-1"> | ||
<span className="text-muted-foreground"> | ||
This folder is empty. New? | ||
</span> | ||
<span className="transition-colors hover:text-muted-foreground"> | ||
<button | ||
onClick={handleOpenModal} | ||
disabled={isLoadingFolders} | ||
className="underline" | ||
> | ||
Start Here | ||
</button> | ||
</span> | ||
<span className="animate-pulse">🚀</span> | ||
</div> | ||
</div> | ||
</> | ||
</div> | ||
); | ||
}; | ||
export default EmptyComponent; |
72 changes: 72 additions & 0 deletions
72
src/frontend/tests/extended/regression/general-bugs-shard-3909.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import * as dotenv from "dotenv"; | ||
import path from "path"; | ||
|
||
test("user must be able to create a new flow clicking on Start Here button", async ({ | ||
page, | ||
}) => { | ||
test.skip( | ||
!process?.env?.OPENAI_API_KEY, | ||
"OPENAI_API_KEY required to run this test", | ||
); | ||
|
||
if (!process.env.CI) { | ||
dotenv.config({ path: path.resolve(__dirname, "../../.env") }); | ||
} | ||
|
||
await page.goto("/"); | ||
|
||
await page.waitForTimeout(1000); | ||
|
||
let modalCount = 0; | ||
try { | ||
const modalTitleElement = await page?.getByTestId("modal-title"); | ||
if (modalTitleElement) { | ||
modalCount = await modalTitleElement.count(); | ||
} | ||
} catch (error) { | ||
modalCount = 0; | ||
} | ||
|
||
while (modalCount === 0) { | ||
await page.getByText("New Project", { exact: true }).click(); | ||
await page.waitForTimeout(3000); | ||
modalCount = await page.getByTestId("modal-title")?.count(); | ||
} | ||
|
||
await page.getByText("Close").last().click(); | ||
|
||
await page.getByTestId("add-folder-button").click(); | ||
|
||
await page.getByText("New Folder").last().click(); | ||
|
||
await page.waitForSelector("text=start here", { timeout: 30000 }); | ||
|
||
await page.waitForTimeout(1000); | ||
|
||
expect( | ||
( | ||
await page.waitForSelector("text=start here", { | ||
timeout: 30000, | ||
}) | ||
).isVisible(), | ||
); | ||
|
||
await page.getByText("Start Here", { exact: true }).click(); | ||
|
||
await page.getByRole("heading", { name: "Basic Prompting" }).click(); | ||
await page.waitForSelector("text=playground", { timeout: 30000 }); | ||
await page.waitForSelector("text=api", { timeout: 30000 }); | ||
await page.waitForSelector("text=share", { timeout: 30000 }); | ||
|
||
await page.waitForTimeout(1000); | ||
|
||
expect( | ||
await page.getByTestId("button_run_chat output").isVisible(), | ||
).toBeTruthy(); | ||
expect(await page.getByTestId("button_run_openai").isVisible()).toBeTruthy(); | ||
expect(await page.getByTestId("button_run_prompt").isVisible()).toBeTruthy(); | ||
expect( | ||
await page.getByTestId("button_run_chat input").isVisible(), | ||
).toBeTruthy(); | ||
}); |