Skip to content

fix: adjust function that add incremental name on flows that already exists + tests #2645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ export const MenuBar = ({}: {}): JSX.Element => {
<div className="header-menu-bar">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button asChild variant="primary" size="sm">
<Button
asChild
variant="primary"
size="sm"
data-testid="flow-configuration-button"
>
<div className="header-menu-bar-display">
<div className="header-menu-flow-name" data-testid="flow_name">
{currentFlow.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ const SideBarFoldersButtonsComponent = ({
)}
{index > 0 && (
<Button
data-testid="btn-delete-folder"
className="hidden p-0 hover:bg-white group-hover:block hover:dark:bg-[#0c101a00]"
onClick={(e) => {
handleDeleteFolder!(item);
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/src/utils/reactflowUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,9 @@ export function updateEdges(edges: Edge[]) {
}

export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) {
const existingNames = flows.map((item) => item.name);
const flowsWithoutUpdatedFlow = flows.filter((f) => f.id !== flow.id);

const existingNames = flowsWithoutUpdatedFlow.map((item) => item.name);
let newName = flow.name;
let count = 1;

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/tests/end-to-end/folders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test("CRUD folders", async ({ page }) => {
.last()
.hover()
.then(async () => {
await page.getByTestId("icon-trash").last().click();
await page.getByTestId("btn-delete-folder").last().click();
});

await page.getByText("Delete").last().click();
Expand Down
125 changes: 125 additions & 0 deletions src/frontend/tests/end-to-end/generalBugs-shard-4.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { expect, test } from "@playwright/test";
import * as dotenv from "dotenv";
import path from "path";

test("should be able to move flow from folder, rename it and be displayed on correct folder", async ({
page,
}) => {
const randomName = Math.random().toString(36).substring(2);
const secondRandomName = Math.random().toString(36).substring(2);

await page.goto("/");
await page.locator("span").filter({ hasText: "My Collection" }).isVisible();
await page.waitForTimeout(2000);

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(5000);
modalCount = await page.getByTestId("modal-title")?.count();
}

await page.getByRole("heading", { name: "Vector Store RAG" }).click();
await page.waitForSelector('[title="fit view"]', {
timeout: 100000,
});

await page.getByTitle("fit view").click();

await page.getByTestId("flow-configuration-button").click();
await page.getByText("Settings").click();
await page.getByPlaceholder("Flow name").fill(randomName);
await page.getByText("Save").last().click();
await page.getByTestId("icon-ChevronLeft").last().click();

await page.getByTestId("add-folder-button").click();

let countFolders = await page.getByText("New Folder").count();

while (countFolders > 1) {
await page.getByText("New Folder").first().hover();

await page.getByTestId("btn-delete-folder").first().click();
await page.getByText("Delete").last().click();
countFolders--;
await page.waitForTimeout(1000);
}

// Get the bounding boxes of the elements
const sourceElement = await page.getByTestId(`card-${randomName}`).first();
const targetElement = await page.getByText("New Folder").last();

const sourceBox = await sourceElement.boundingBox();
const targetBox = await targetElement.boundingBox();

// Perform the drag and drop
await page.mouse.move(
sourceBox!.x + sourceBox!.width / 2,
sourceBox!.y + sourceBox!.height / 2,
);
await page.mouse.down();
await page.mouse.move(
targetBox!.x + targetBox!.width / 2,
targetBox!.y + targetBox!.height / 2,
);
await page.mouse.up();

await page.waitForTimeout(3000);

await page.getByText("New Folder").last().click();

expect(await page.getByTestId(`card-${randomName}`).first().isVisible());

await page.getByTestId(`card-${randomName}`).first().click();

await page.getByTestId("flow-configuration-button").click();
await page.getByText("Settings").click();
await page.getByPlaceholder("Flow name").fill(secondRandomName);
await page.getByText("Save").last().click();
await page.getByTestId("icon-ChevronLeft").last().click();

await page.waitForTimeout(3000);

await page.getByText("New Folder").last().click();
expect(
await page.getByTestId(`card-${secondRandomName}`).first().isVisible(),
);

// Get the bounding boxes of the elements
const secondSourceElement = await page
.getByTestId(`card-${secondRandomName}`)
.first();
const secondTargetElement = await page.getByText("New Folder").last();

const secondSourceBox = await secondSourceElement.boundingBox();
const secondTargetBox = await secondTargetElement.boundingBox();

// Perform the drag and drop
await page.mouse.move(
secondSourceBox!.x + secondSourceBox!.width / 2,
secondSourceBox!.y + secondSourceBox!.height / 2,
);
await page.mouse.down();
await page.mouse.move(
secondTargetBox!.x + secondTargetBox!.width / 2,
secondTargetBox!.y + secondTargetBox!.height / 2,
);
await page.mouse.up();

await page.waitForTimeout(3000);

await page.getByText("My Projects").last().click();

expect(
await page.getByTestId(`card-${secondRandomName}`).first().isVisible(),
);
});
Loading