add draganddrop test

This commit is contained in:
cristhianzl 2024-02-29 17:01:19 -03:00
commit b83a18bcc9
3 changed files with 43 additions and 17 deletions

File diff suppressed because one or more lines are too long

View file

@ -8,7 +8,7 @@ test.describe("drag and drop test", () => {
await page.locator("span").filter({ hasText: "My Collection" }).isVisible(); await page.locator("span").filter({ hasText: "My Collection" }).isVisible();
// Read your file into a buffer. // Read your file into a buffer.
const jsonContent = readFileSync( const jsonContent = readFileSync(
"tests/onlyFront/assets/collection.json", "tests/end-to-end/assets/collection.json",
"utf-8" "utf-8"
); );

View file

@ -5,10 +5,10 @@ test.describe("group node test", () => {
/// <reference lib="dom"/> /// <reference lib="dom"/>
test("group and ungroup updating values", async ({ page }) => { test("group and ungroup updating values", async ({ page }) => {
await page.goto("http:localhost:3000/"); await page.goto("http:localhost:3000/");
await page.locator("span").filter({ hasText: "My Collection" }).isVisible(); await page.locator('//*[@id="new-project-btn"]').click();
// Read your file into a buffer. // Read your file into a buffer.
const jsonContent = readFileSync( const jsonContent = readFileSync(
"tests/onlyFront/assets/collection.json", "tests/end-to-end/assets/flow_group_test.json",
"utf-8" "utf-8"
); );
@ -16,7 +16,7 @@ test.describe("group node test", () => {
const dataTransfer = await page.evaluateHandle((data) => { const dataTransfer = await page.evaluateHandle((data) => {
const dt = new DataTransfer(); const dt = new DataTransfer();
// Convert the buffer to a hex array // Convert the buffer to a hex array
const file = new File([data], "flowtest.json", { const file = new File([data], "flow_group_test.json", {
type: "application/json", type: "application/json",
}); });
dt.items.add(file); dt.items.add(file);
@ -25,24 +25,53 @@ test.describe("group node test", () => {
page.waitForTimeout(2000); page.waitForTimeout(2000);
await page.dispatchEvent( await page.dispatchEvent('//*[@id="react-flow-id"]', "drop", {
'//*[@id="root"]/div/div[1]/div[2]/div[3]/div/div', dataTransfer,
"drop", });
{
dataTransfer, await page.locator('//*[@id="new-project-btn"]').click();
} await page.waitForTimeout(2000);
);
await page.getByPlaceholder("Search").click();
await page.getByPlaceholder("Search").fill("PythonFunctionTool");
await page.waitForTimeout(2000);
await page await page
.getByTestId("edit-flow-button-e9ac1bdc-429b-475d-ac03-d26f9a2a3210-0") .getByTestId("toolsPythonFunctionTool")
.click(); .first()
.dragTo(page.locator('//*[@id="react-flow-id"]'));
await page.getByPlaceholder("Search").click();
await page.getByPlaceholder("Search").fill("ChatOpenAI");
await page.waitForTimeout(2000); await page.waitForTimeout(2000);
await page
.getByTestId("model_specsChatOpenAI")
.first()
.dragTo(page.locator('//*[@id="react-flow-id"]'));
await page.getByPlaceholder("Search").click();
await page.getByPlaceholder("Search").fill("AgentInitializer");
await page.waitForTimeout(2000);
await page
.getByTestId("agentsAgent Initializer")
.first()
.dragTo(page.locator('//*[@id="react-flow-id"]'));
const genericNoda = page.getByTestId("div-generic-node"); const genericNoda = page.getByTestId("div-generic-node");
const elementCount = await genericNoda.count(); const elementCount = await genericNoda.count();
if (elementCount > 0) { if (elementCount > 0) {
expect(true).toBeTruthy(); expect(true).toBeTruthy();
} }
page.locator('//*[@id="react-flow-id"]').click();
await page.getByTestId("title-Agent Initializer").click({
modifiers: ["Control"],
});
await page.getByTestId("title-PythonFunctionTool").click({ await page.getByTestId("title-PythonFunctionTool").click({
modifiers: ["Control"], modifiers: ["Control"],
@ -51,10 +80,6 @@ test.describe("group node test", () => {
modifiers: ["Control"], modifiers: ["Control"],
}); });
await page.getByTestId("title-AgentInitializer").click({
modifiers: ["Control"],
});
await page.getByRole("button", { name: "Group" }).click(); await page.getByRole("button", { name: "Group" }).click();
const textArea = page.getByTestId("div-textarea-description"); const textArea = page.getByTestId("div-textarea-description");