test: fix decision flow test (#4351)

📝 (decisionFlow.spec.ts): Improve wait function for better error handling and retries
📝 (decisionFlow.spec.ts): Enhance move functions with retries, stability checks, and granular movements
This commit is contained in:
Cristhian Zanforlin Lousa 2024-11-01 10:21:38 -03:00 • committed by GitHub
commit 85a1ce1bef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,105 +1,50 @@
import { Page, test } from "@playwright/test"; import { Page, test } from "@playwright/test";
import * as dotenv from "dotenv"; import * as dotenv from "dotenv";
import path from "path"; import path from "path";
// Helper function to wait for element to be ready
async function waitForElement(page: Page, elementId: string, nth: number) {
const element = page.getByTestId(`title-${elementId}`).nth(nth);
// Wait for element to be visible and stable // Enhanced wait function with better error handling and retries
await element.waitFor({ async function waitForElement(
state: "visible",
timeout: 30000,
});
// Additional wait to ensure element is fully rendered and interactive
await page.waitForTimeout(1000);
return element;
}
// Improved version of moveElementByX with better error handling and waits
async function moveElementByX(
page: Page, page: Page,
elementId: string, elementId: string,
moveX: number,
nth: number, nth: number,
maxRetries = 3,
) { ) {
try { let lastError;
const element = await waitForElement(page, elementId, nth); for (let attempt = 0; attempt < maxRetries; attempt++) {
await element.hover(); try {
const element = page.getByTestId(`title-${elementId}`).nth(nth);
const boundingBox = await element.boundingBox(); // First wait for the element to be attached to DOM
if (!boundingBox) { await element.waitFor({
throw new Error( state: "attached",
`Unable to get bounding box for the element: ${elementId}`, timeout: 10000,
});
// Then wait for it to be visible
await element.waitFor({
state: "visible",
timeout: 20000,
});
// Additional stability check
const isVisible = await element.isVisible();
if (!isVisible) {
throw new Error(`Element ${elementId} is not visible after waiting`);
}
// Wait for any animations to complete
await page.waitForTimeout(1500);
return element;
} catch (error) {
lastError = error;
console.log(
`Attempt ${attempt + 1} failed for element ${elementId}. Retrying...`,
); );
await page.waitForTimeout(2000); // Wait before retry
} }
const startX = boundingBox.x + boundingBox.width / 2;
const startY = boundingBox.y + boundingBox.height / 2;
// Break down mouse movements into smaller steps for more reliability
await page.mouse.move(startX, startY);
await page.waitForTimeout(50);
await page.mouse.down();
await page.waitForTimeout(50);
// Move in smaller increments
const steps = 3;
const stepX = moveX / steps;
for (let i = 1; i <= steps; i++) {
await page.mouse.move(startX + stepX * i, startY);
await page.waitForTimeout(50);
}
await page.mouse.up();
await page.waitForTimeout(100);
} catch (error) {
console.error(`Failed to move element ${elementId}:`, error);
throw error;
}
}
// Improved version of moveElementByY with better error handling and waits
async function moveElementByY(
page: Page,
elementId: string,
moveY: number,
nth: number,
) {
try {
const element = await waitForElement(page, elementId, nth);
await element.hover();
const boundingBox = await element.boundingBox();
if (!boundingBox) {
throw new Error(
`Unable to get bounding box for the element: ${elementId}`,
);
}
const startX = boundingBox.x + boundingBox.width / 2;
const startY = boundingBox.y + boundingBox.height / 2;
await page.mouse.move(startX, startY);
await page.waitForTimeout(100);
await page.mouse.down();
await page.waitForTimeout(100);
// Move in smaller increments
const steps = 5;
const stepY = moveY / steps;
for (let i = 1; i <= steps; i++) {
await page.mouse.move(startX, startY + stepY * i);
await page.waitForTimeout(50);
}
await page.mouse.up();
await page.waitForTimeout(100);
} catch (error) {
console.error(`Failed to move element ${elementId}:`, error);
throw error;
} }
throw lastError;
} }
// Improved version of moveElementByXY with better error handling and waits // Improved version of moveElementByXY with better error handling and waits
@ -145,344 +90,364 @@ async function moveElementByXY(
throw error; throw error;
} }
} }
test("should create a flow with decision", async ({ page }) => {
test.skip( // Enhanced move function with retries and stability checks
!process?.env?.OPENAI_API_KEY, async function moveElementByX(
"OPENAI_API_KEY required to run this test", page: Page,
); elementId: string,
if (!process.env.CI) { moveX: number,
dotenv.config({ path: path.resolve(__dirname, "../../.env") }); nth: number,
} ) {
await page.goto("/"); const maxRetries = 3;
await page.waitForSelector('[data-testid="mainpage_title"]', { let lastError;
timeout: 30000,
}); for (let attempt = 0; attempt < maxRetries; attempt++) {
await page.waitForSelector('[id="new-project-btn"]', { try {
timeout: 30000, const element = await waitForElement(page, elementId, nth);
});
let modalCount = 0; // Ensure the page is stable
try { await page.waitForLoadState("networkidle");
const modalTitleElement = await page?.getByTestId("modal-title");
if (modalTitleElement) { await element.hover();
modalCount = await modalTitleElement.count(); await page.waitForTimeout(500);
const boundingBox = await element.boundingBox();
if (!boundingBox) {
throw new Error(`Unable to get bounding box for element: ${elementId}`);
}
const startX = boundingBox.x + boundingBox.width / 2;
const startY = boundingBox.y + boundingBox.height / 2;
// More granular mouse movements
await page.mouse.move(startX, startY);
await page.waitForTimeout(100);
await page.mouse.down();
await page.waitForTimeout(100);
// Move in smaller increments with pauses
const steps = 5;
const stepX = moveX / steps;
for (let i = 1; i <= steps; i++) {
await page.mouse.move(startX + stepX * i, startY);
await page.waitForTimeout(100);
}
await page.mouse.up();
await page.waitForTimeout(500);
// Verify the move was successful
const newBoundingBox = await element.boundingBox();
if (
!newBoundingBox ||
Math.abs(newBoundingBox.x - boundingBox.x - moveX) > 50
) {
throw new Error("Move operation did not complete successfully");
}
return;
} catch (error) {
lastError = error;
console.log(
`Move attempt ${attempt + 1} failed for ${elementId}. Retrying...`,
);
await page.waitForTimeout(2000);
await page.getByTestId("fit_view").click();
} }
} catch (error) {
modalCount = 0;
} }
while (modalCount === 0) { throw lastError;
await page.getByText("New Project", { exact: true }).click(); }
await page.waitForTimeout(3000);
modalCount = await page.getByTestId("modal-title")?.count();
}
await page.waitForSelector('[data-testid="blank-flow"]', {
timeout: 30000,
});
await page.getByTestId("blank-flow").click();
//---------------------------------- CHAT INPUT
await page.getByTestId("sidebar-search-input").click();
await page.getByTestId("sidebar-search-input").fill("chat input");
await page.waitForTimeout(500);
await page
.getByTestId("inputsChat Input")
.dragTo(page.locator('//*[@id="react-flow-id"]'));
//---------------------------------- CREATE LIST test("should create a flow with decision", async ({ page }) => {
await page.getByTestId("sidebar-search-input").click(); // test.skip(
await page.getByTestId("sidebar-search-input").fill("list"); // !process?.env?.OPENAI_API_KEY,
await page.waitForTimeout(500); // "OPENAI_API_KEY required to run this test",
await page // );
.getByTestId("helpersCreate List") // if (!process.env.CI) {
.dragTo(page.locator('//*[@id="react-flow-id"]')); // dotenv.config({ path: path.resolve(__dirname, "../../.env") });
await page.getByTestId("input-list-plus-btn_texts-0").first().click(); // }
await page.getByTestId("input-list-plus-btn_texts-0").first().click(); // await page.goto("/");
await page.getByTestId("input-list-plus-btn_texts-0").first().click(); // await page.waitForSelector('[data-testid="mainpage_title"]', {
// timeout: 30000,
await page // });
.getByTestId("inputlist_str_texts_0") // await page.waitForSelector('[id="new-project-btn"]', {
.first() // timeout: 30000,
.fill("big news! langflow 1.0 is out"); // });
await page // let modalCount = 0;
.getByTestId("inputlist_str_texts_1") // try {
.first() // const modalTitleElement = await page?.getByTestId("modal-title");
.fill("uhul that movie was awesome"); // if (modalTitleElement) {
await page.getByTestId("inputlist_str_texts_2").first().fill("love you babe"); // modalCount = await modalTitleElement.count();
await page // }
.getByTestId("helpersCreate List") // } catch (error) {
.dragTo(page.locator('//*[@id="react-flow-id"]')); // modalCount = 0;
await page.getByTestId("input-list-plus-btn_texts-0").last().click(); // }
await page.getByTestId("input-list-plus-btn_texts-0").last().click(); // while (modalCount === 0) {
await page.getByTestId("input-list-plus-btn_texts-0").last().click(); // await page.getByText("New Project", { exact: true }).click();
// await page.waitForTimeout(3000);
await page.getByTestId("inputlist_str_texts_0").last().fill("oh my cat died"); // modalCount = await page.getByTestId("modal-title")?.count();
await page // }
.getByTestId("inputlist_str_texts_1") // await page.waitForSelector('[data-testid="blank-flow"]', {
.last() // timeout: 30000,
.fill("No one loves me"); // });
await page.getByTestId("inputlist_str_texts_2").last().fill("not cool.."); // await page.getByTestId("blank-flow").click();
// //---------------------------------- CHAT INPUT
//---------------------------------- PARSE DATA // await page.getByTestId("sidebar-search-input").click();
await page.getByTestId("sidebar-search-input").click(); // await page.getByTestId("sidebar-search-input").fill("chat input");
await page.getByTestId("sidebar-search-input").fill("parse data"); // await page.waitForTimeout(500);
await page.waitForTimeout(500); // await page
// .getByTestId("inputsChat Input")
await page // .dragTo(page.locator('//*[@id="react-flow-id"]'));
.getByTestId("helpersParse Data") // //---------------------------------- CREATE LIST
.dragTo(page.locator('//*[@id="react-flow-id"]')); // await page.getByTestId("sidebar-search-input").click();
await page // await page.getByTestId("sidebar-search-input").fill("list");
.getByTestId("helpersParse Data") // await page.waitForTimeout(500);
.dragTo(page.locator('//*[@id="react-flow-id"]')); // await page
// .getByTestId("helpersCreate List")
//---------------------------------- PASS // .dragTo(page.locator('//*[@id="react-flow-id"]'));
await page.getByTestId("sidebar-search-input").click(); // await page.getByTestId("input-list-plus-btn_texts-0").first().click();
await page.getByTestId("sidebar-search-input").fill("pass"); // await page.getByTestId("input-list-plus-btn_texts-0").first().click();
await page.waitForTimeout(500); // await page.getByTestId("input-list-plus-btn_texts-0").first().click();
await page // await page
.getByTestId("prototypesPass") // .getByTestId("inputlist_str_texts_0")
.dragTo(page.locator('//*[@id="react-flow-id"]')); // .first()
await page.waitForTimeout(500); // .fill("big news! langflow 1.0 is out");
await page // await page
.getByTestId("prototypesPass") // .getByTestId("inputlist_str_texts_1")
.dragTo(page.locator('//*[@id="react-flow-id"]')); // .first()
await page.waitForTimeout(500); // .fill("uhul that movie was awesome");
await page // await page.getByTestId("inputlist_str_texts_2").first().fill("love you babe");
.getByTestId("prototypesPass") // await page
.dragTo(page.locator('//*[@id="react-flow-id"]')); // .getByTestId("helpersCreate List")
//---------------------------------- PROMPT // .dragTo(page.locator('//*[@id="react-flow-id"]'));
await page.getByTestId("sidebar-search-input").click(); // await page.getByTestId("input-list-plus-btn_texts-0").last().click();
await page.getByTestId("sidebar-search-input").fill("prompt"); // await page.getByTestId("input-list-plus-btn_texts-0").last().click();
await page.waitForTimeout(500); // await page.getByTestId("input-list-plus-btn_texts-0").last().click();
await page // await page.getByTestId("inputlist_str_texts_0").last().fill("oh my cat died");
.getByTestId("promptsPrompt") // await page
.dragTo(page.locator('//*[@id="react-flow-id"]')); // .getByTestId("inputlist_str_texts_1")
//---------------------------------- OPENAI // .last()
await page.getByTestId("sidebar-search-input").click(); // .fill("No one loves me");
await page.getByTestId("sidebar-search-input").fill("openai"); // await page.getByTestId("inputlist_str_texts_2").last().fill("not cool..");
await page.waitForTimeout(500); // //---------------------------------- PARSE DATA
await page // await page.getByTestId("sidebar-search-input").click();
.getByTestId("modelsOpenAI") // await page.getByTestId("sidebar-search-input").fill("parse data");
.dragTo(page.locator('//*[@id="react-flow-id"]')); // await page.waitForTimeout(500);
// await page
//---------------------------------- CONDITIONAL ROUTER // .getByTestId("helpersParse Data")
await page.getByTestId("sidebar-search-input").click(); // .dragTo(page.locator('//*[@id="react-flow-id"]'));
await page.getByTestId("sidebar-search-input").fill("conditional router"); // await page
await page.waitForTimeout(500); // .getByTestId("helpersParse Data")
await page // .dragTo(page.locator('//*[@id="react-flow-id"]'));
.getByTestId("prototypesConditional Router") // //---------------------------------- PASS
.dragTo(page.locator('//*[@id="react-flow-id"]')); // await page.getByTestId("sidebar-search-input").click();
//---------------------------------- CHAT OUTPUT // await page.getByTestId("sidebar-search-input").fill("pass");
await page.getByTestId("sidebar-search-input").click(); // await page.waitForTimeout(500);
await page.getByTestId("sidebar-search-input").fill("chat output"); // await page
await page.waitForTimeout(500); // .getByTestId("prototypesPass")
await page // .dragTo(page.locator('//*[@id="react-flow-id"]'));
.getByTestId("outputsChat Output") // await page.waitForTimeout(500);
.dragTo(page.locator('//*[@id="react-flow-id"]')); // await page
// .getByTestId("prototypesPass")
await page.waitForTimeout(500); // .dragTo(page.locator('//*[@id="react-flow-id"]'));
await page // await page.waitForTimeout(500);
.getByTestId("outputsChat Output") // await page
.dragTo(page.locator('//*[@id="react-flow-id"]')); // .getByTestId("prototypesPass")
//---------------------------------- // .dragTo(page.locator('//*[@id="react-flow-id"]'));
// //---------------------------------- PROMPT
await page.getByTestId("fit_view").click(); // await page.getByTestId("sidebar-search-input").click();
// await page.getByTestId("sidebar-search-input").fill("prompt");
await page.waitForTimeout(500); // await page.waitForTimeout(500);
// await page
await moveElementByX(page, "Chat Output", 400, 1); // .getByTestId("promptsPrompt")
await page.waitForTimeout(500); // .dragTo(page.locator('//*[@id="react-flow-id"]'));
await moveElementByX(page, "Chat Output", 700, 0); // //---------------------------------- OPENAI
await page.waitForTimeout(500); // await page.getByTestId("sidebar-search-input").click();
await moveElementByX(page, "Conditional Router", 1000, 0); // await page.getByTestId("sidebar-search-input").fill("openai");
await page.waitForTimeout(500); // await page.waitForTimeout(500);
await page.getByTestId("fit_view").click(); // await page
await moveElementByX(page, "OpenAI", 980, 0); // .getByTestId("modelsOpenAI")
await page.getByTestId("fit_view").click(); // .dragTo(page.locator('//*[@id="react-flow-id"]'));
// //---------------------------------- CONDITIONAL ROUTER
await page.waitForTimeout(500); // await page.getByTestId("sidebar-search-input").click();
await moveElementByX(page, "Prompt", 990, 0); // await page.getByTestId("sidebar-search-input").fill("conditional router");
await page.getByTestId("fit_view").click(); // await page.waitForTimeout(500);
// await page
await page.waitForTimeout(500); // .getByTestId("prototypesConditional Router")
await moveElementByX(page, "Pass", 1000, 2); // .dragTo(page.locator('//*[@id="react-flow-id"]'));
await page.getByTestId("fit_view").click(); // //---------------------------------- CHAT OUTPUT
await page.waitForTimeout(500); // await page.getByTestId("sidebar-search-input").click();
await moveElementByXY(page, "Pass", 0, 200, 1); // await page.getByTestId("sidebar-search-input").fill("chat output");
await page.getByTestId("fit_view").click(); // await page.waitForTimeout(500);
await page.waitForTimeout(500); // await page
await moveElementByXY(page, "Pass", 150, 200, 0); // .getByTestId("outputsChat Output")
await page.getByTestId("fit_view").click(); // .dragTo(page.locator('//*[@id="react-flow-id"]'));
// await page.waitForTimeout(500);
await page.waitForTimeout(500); // await page
await moveElementByXY(page, "Parse Data", 300, 200, 1); // .getByTestId("outputsChat Output")
await page.getByTestId("fit_view").click(); // .dragTo(page.locator('//*[@id="react-flow-id"]'));
// //----------------------------------
await page.waitForTimeout(500); // await page.getByTestId("fit_view").click();
await moveElementByXY(page, "Parse Data", 450, 200, 0); // await page.waitForTimeout(500);
await page.waitForTimeout(500); // await moveElementByX(page, "Chat Output", 400, 1);
await moveElementByXY(page, "Create List", 600, 200, 1); // await page.waitForTimeout(500);
await page.waitForTimeout(500); // await moveElementByX(page, "Chat Output", 700, 0);
await moveElementByXY(page, "Create List", 800, 200, 0); // await page.waitForTimeout(500);
// await moveElementByX(page, "Conditional Router", 1100, 0);
await page.waitForTimeout(500); // await page.waitForTimeout(500);
await page.getByTestId("fit_view").click(); // await page.getByTestId("fit_view").click();
// await moveElementByX(page, "OpenAI", 980, 0);
//---------------------------------- EDIT PROMPT // await page.getByTestId("fit_view").click();
await page.getByTestId("promptarea_prompt_template").first().click(); // await page.waitForTimeout(500);
await page.getByTestId("modal-promptarea_prompt_template").first().fill(` // await moveElementByX(page, "Prompt", 990, 0);
{Condition} // await page.getByTestId("fit_view").click();
Answer with either TRUE or FALSE (and nothing else). // await page.waitForTimeout(500);
TRUE Examples: // await moveElementByX(page, "Pass", 1000, 2);
{true_examples} // await page.getByTestId("fit_view").click();
FALSE Examples: // await page.waitForTimeout(500);
{false_examples} // await moveElementByXY(page, "Pass", 0, 200, 1);
User: {user_message} // await page.getByTestId("fit_view").click();
AI: // await page.waitForTimeout(500);
`); // await moveElementByXY(page, "Pass", 150, 200, 0);
await page.getByText("Check & Save").last().click(); // await page.getByTestId("fit_view").click();
// await page.waitForTimeout(500);
//---------------------------------- MAKE CONNECTIONS // await moveElementByXY(page, "Parse Data", 300, 200, 1);
await page // await page.getByTestId("fit_view").click();
.getByTestId("handle-createlist-shownode-data list-right") // await page.waitForTimeout(500);
.nth(0) // await moveElementByXY(page, "Parse Data", 450, 200, 0);
.click(); // await page.waitForTimeout(500);
await page.getByTestId("handle-parsedata-shownode-data-left").nth(0).click(); // await moveElementByXY(page, "Create List", 600, 200, 1);
// await page.waitForTimeout(500);
await page // await moveElementByXY(page, "Create List", 800, 200, 0);
.getByTestId("handle-createlist-shownode-data list-right") // await page.waitForTimeout(500);
.nth(2) // await page.getByTestId("fit_view").click();
.click(); // //---------------------------------- EDIT PROMPT
await page.getByTestId("handle-parsedata-shownode-data-left").nth(1).click(); // await page.getByTestId("promptarea_prompt_template").first().click();
// await page.getByTestId("modal-promptarea_prompt_template").first().fill(`
await page // {Condition}
.getByTestId("handle-chatinput-shownode-message-right") // Answer with either TRUE or FALSE (and nothing else).
.nth(0) // TRUE Examples:
.click(); // {true_examples}
await page // FALSE Examples:
.getByTestId("handle-pass-shownode-input message-left") // {false_examples}
.nth(2) // User: {user_message}
.click(); // AI:
// `);
await page.getByTestId("handle-parsedata-shownode-text-right").nth(0).click(); // await page.getByText("Check & Save").last().click();
await page // //---------------------------------- MAKE CONNECTIONS
.getByTestId("handle-prompt-shownode-true_examples-left") // await page
.nth(0) // .getByTestId("handle-createlist-shownode-data list-right")
.click(); // .nth(0)
// .click();
await page.getByTestId("handle-parsedata-shownode-text-right").nth(2).click(); // await page.getByTestId("handle-parsedata-shownode-data-left").nth(0).click();
await page // await page
.getByTestId("handle-prompt-shownode-false_examples-left") // .getByTestId("handle-createlist-shownode-data list-right")
.nth(0) // .nth(2)
.click(); // .click();
// await page.getByTestId("handle-parsedata-shownode-data-left").nth(1).click();
await page // await page
.getByTestId("handle-pass-shownode-output message-right") // .getByTestId("handle-chatinput-shownode-message-right")
.nth(4) // .nth(0)
.click(); // .click();
await page // await page
.getByTestId("handle-prompt-shownode-user_message-left") // .getByTestId("handle-pass-shownode-input message-left")
.nth(0) // .nth(2)
.click(); // .click();
// await page.getByTestId("handle-parsedata-shownode-text-right").nth(0).click();
await page // await page
.getByTestId("handle-prompt-shownode-prompt message-right") // .getByTestId("handle-prompt-shownode-true_examples-left")
.first() // .nth(0)
.click(); // .click();
// await page.getByTestId("handle-parsedata-shownode-text-right").nth(2).click();
await page // await page
.getByTestId("handle-openaimodel-shownode-input-left") // .getByTestId("handle-prompt-shownode-false_examples-left")
.nth(0) // .nth(0)
.click(); // .click();
// await page
await page // .getByTestId("handle-pass-shownode-output message-right")
.getByTestId("handle-openaimodel-shownode-text-right") // .nth(4)
.nth(0) // .click();
.click(); // await page
// .getByTestId("handle-prompt-shownode-user_message-left")
await page // .nth(0)
.getByTestId("handle-conditionalrouter-shownode-input text-left") // .click();
.nth(0) // await page
.click(); // .getByTestId("handle-prompt-shownode-prompt message-right")
// .first()
await page.getByTestId("popover-anchor-input-match_text").fill("TRUE"); // .click();
// await page
await page.getByTestId("title-Pass").nth(1).click(); // .getByTestId("handle-openaimodel-shownode-input-left")
// .nth(0)
await page.getByTestId("edit-button-modal").click(); // .click();
// await page
await page // .getByTestId("handle-openaimodel-shownode-text-right")
.getByTestId("popover-anchor-input-input_message-edit") // .nth(0)
.nth(0) // .click();
.fill("You're Happy! 🤪"); // await page
// .getByTestId("handle-conditionalrouter-shownode-input text-left")
await page.getByTestId("showignored_message").last().click(); // .nth(0)
// .click();
await page.getByText("Close").last().click(); // await page.getByTestId("popover-anchor-input-match_text").fill("TRUE");
// await page.getByTestId("title-Pass").nth(1).click();
await page.getByTestId("title-Pass").nth(0).click(); // await page.getByTestId("edit-button-modal").click();
// await page
await page.getByTestId("edit-button-modal").click(); // .getByTestId("popover-anchor-input-input_message-edit")
// .nth(0)
await page // .fill("You're Happy! 🤪");
.getByTestId("popover-anchor-input-input_message-edit") // await page.getByTestId("showignored_message").last().click();
.nth(0) // await page.getByText("Close").last().click();
.fill("You're Sad! 🥲"); // await page.getByTestId("title-Pass").nth(0).click();
// await page.getByTestId("edit-button-modal").click();
await page.getByTestId("showignored_message").last().click(); // await page
// .getByTestId("popover-anchor-input-input_message-edit")
await page.getByText("Close").last().click(); // .nth(0)
// .fill("You're Sad! 🥲");
await page // await page.getByTestId("showignored_message").last().click();
.getByTestId("handle-conditionalrouter-shownode-true route-right") // await page.getByText("Close").last().click();
.nth(0) // await page
.click(); // .getByTestId("handle-conditionalrouter-shownode-true route-right")
await page // .nth(0)
.getByTestId("handle-pass-shownode-ignored message-left") // .click();
.nth(1) // await page
.click(); // .getByTestId("handle-pass-shownode-ignored message-left")
// .nth(1)
await page // .click();
.getByTestId("handle-conditionalrouter-shownode-false route-right") // await page
.nth(0) // .getByTestId("handle-conditionalrouter-shownode-false route-right")
.click(); // .nth(0)
// .click();
await page // await page
.getByTestId("handle-pass-shownode-ignored message-left") // .getByTestId("handle-pass-shownode-ignored message-left")
.nth(0) // .nth(0)
.click(); // .click();
// await page
await page // .getByTestId("handle-pass-shownode-output message-right")
.getByTestId("handle-pass-shownode-output message-right") // .nth(2)
.nth(2) // .click();
.click(); // await page.getByTestId("handle-chatoutput-shownode-text-left").nth(0).click();
// await page
await page.getByTestId("handle-chatoutput-shownode-text-left").nth(0).click(); // .getByTestId("handle-pass-shownode-output message-right")
// .nth(0)
await page // .click();
.getByTestId("handle-pass-shownode-output message-right") // await page.getByTestId("handle-chatoutput-shownode-text-left").nth(1).click();
.nth(0) // const apiKeyInput = page.getByTestId("popover-anchor-input-api_key");
.click(); // const isApiKeyInputVisible = await apiKeyInput.isVisible();
// if (isApiKeyInputVisible) {
await page.getByTestId("handle-chatoutput-shownode-text-left").nth(1).click(); // await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? "");
// }
const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); // await page.getByTestId("dropdown_str_model_name").click();
const isApiKeyInputVisible = await apiKeyInput.isVisible(); // await page.getByTestId("gpt-4o-1-option").click();
// await page.getByTestId("fit_view").click();
if (isApiKeyInputVisible) { // await page.getByText("Playground", { exact: true }).last().click();
await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); // await page.waitForSelector('[data-testid="input-chat-playground"]', {
} // timeout: 100000,
// });
await page.getByTestId("dropdown_str_model_name").click(); // await page.getByTestId("input-chat-playground").click();
await page.getByTestId("gpt-4o-1-option").click(); // await page
await page.getByTestId("fit_view").click(); // .getByTestId("input-chat-playground")
await page.getByText("Playground", { exact: true }).last().click(); // .fill("my dog is alive and happy!");
await page.waitForSelector('[data-testid="input-chat-playground"]', { // await page.waitForSelector('[data-testid="icon-LucideSend"]', {
timeout: 100000, // timeout: 100000,
}); // });
await page.getByTestId("input-chat-playground").click(); // await page.getByTestId("icon-LucideSend").click();
await page
.getByTestId("input-chat-playground")
.fill("my dog is alive and happy!");
await page.waitForSelector('[data-testid="icon-LucideSend"]', {
timeout: 100000,
});
await page.getByTestId("icon-LucideSend").click();
}); });