tests: add decision flow test (#4384)

* ✨ (Vector Store.spec.ts): Update test to skip if required environment variables are not set and improve test flow for Vector Store RAG test.

* ✨ (Vector Store.spec.ts): Update variable name from 'control' to 'Control' for better clarity and consistency
📝 (decisionFlow.spec.ts): Refactor test case to skip if OPENAI_API_KEY is not provided and improve code readability and maintainability by restructuring and commenting out unnecessary code blocks

* 📝 (Vector Store.spec.ts): Comment out unnecessary test.skip blocks and unused code to improve code readability and maintainability.

* refactor: update test to click on "New Flow" instead of "New Project"

* ✨ (store-shard-2.spec.ts): Refactor test to use a reusable function for clicking elements and waiting for visibility to improve code readability and maintainability
🔧 (deleteFlows.spec.ts): Refactor test to use separate functions for waiting for and interacting with elements to improve code readability and maintainability
This commit is contained in:
Cristhian Zanforlin Lousa 2024-11-05 11:55:22 -03:00 • committed by GitHub
commit 1443af2e42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -159,295 +159,296 @@ async function moveElementByX(
} }
test("should create a flow with decision", async ({ page }) => { test("should create a flow with decision", async ({ page }) => {
// test.skip( test.skip(
// !process?.env?.OPENAI_API_KEY, !process?.env?.OPENAI_API_KEY,
// "OPENAI_API_KEY required to run this test", "OPENAI_API_KEY required to run this test",
// ); );
// if (!process.env.CI) { if (!process.env.CI) {
// dotenv.config({ path: path.resolve(__dirname, "../../.env") }); dotenv.config({ path: path.resolve(__dirname, "../../.env") });
// } }
// await page.goto("/"); await page.goto("/");
// await page.waitForSelector('[data-testid="mainpage_title"]', { await page.waitForSelector('[data-testid="mainpage_title"]', {
// timeout: 30000, timeout: 30000,
// }); });
// await page.waitForSelector('[id="new-project-btn"]', { await page.waitForSelector('[id="new-project-btn"]', {
// timeout: 30000, timeout: 30000,
// }); });
// let modalCount = 0; let modalCount = 0;
// try { try {
// const modalTitleElement = await page?.getByTestId("modal-title"); const modalTitleElement = await page?.getByTestId("modal-title");
// if (modalTitleElement) { if (modalTitleElement) {
// modalCount = await modalTitleElement.count(); modalCount = await modalTitleElement.count();
// } }
// } catch (error) { } catch (error) {
// modalCount = 0; modalCount = 0;
// } }
// while (modalCount === 0) { while (modalCount === 0) {
// await page.getByText("New Project", { exact: true }).click(); await page.getByText("New Flow", { exact: true }).click();
// await page.waitForTimeout(3000); await page.waitForTimeout(3000);
// modalCount = await page.getByTestId("modal-title")?.count(); modalCount = await page.getByTestId("modal-title")?.count();
// } }
// await page.waitForSelector('[data-testid="blank-flow"]', { await page.waitForSelector('[data-testid="blank-flow"]', {
// timeout: 30000, timeout: 30000,
// }); });
// await page.getByTestId("blank-flow").click(); await page.getByTestId("blank-flow").click();
// //---------------------------------- CHAT INPUT //---------------------------------- CHAT INPUT
// 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("chat input");
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await page await page
// .getByTestId("inputsChat Input") .getByTestId("inputsChat Input")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// //---------------------------------- CREATE LIST //---------------------------------- CREATE LIST
// await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").click();
// await page.getByTestId("sidebar-search-input").fill("list"); await page.getByTestId("sidebar-search-input").fill("list");
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await page await page
// .getByTestId("helpersCreate List") .getByTestId("helpersCreate List")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// await page.getByTestId("input-list-plus-btn_texts-0").first().click(); await page.getByTestId("input-list-plus-btn_texts-0").first().click();
// await page.getByTestId("input-list-plus-btn_texts-0").first().click(); await page.getByTestId("input-list-plus-btn_texts-0").first().click();
// await page.getByTestId("input-list-plus-btn_texts-0").first().click(); await page.getByTestId("input-list-plus-btn_texts-0").first().click();
// await page await page
// .getByTestId("inputlist_str_texts_0") .getByTestId("inputlist_str_texts_0")
// .first() .first()
// .fill("big news! langflow 1.0 is out"); .fill("big news! langflow 1.0 is out");
// await page await page
// .getByTestId("inputlist_str_texts_1") .getByTestId("inputlist_str_texts_1")
// .first() .first()
// .fill("uhul that movie was awesome"); .fill("uhul that movie was awesome");
// await page.getByTestId("inputlist_str_texts_2").first().fill("love you babe"); await page.getByTestId("inputlist_str_texts_2").first().fill("love you babe");
// await page await page
// .getByTestId("helpersCreate List") .getByTestId("helpersCreate List")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// await page.getByTestId("input-list-plus-btn_texts-0").last().click(); await page.getByTestId("input-list-plus-btn_texts-0").last().click();
// await page.getByTestId("input-list-plus-btn_texts-0").last().click(); await page.getByTestId("input-list-plus-btn_texts-0").last().click();
// await page.getByTestId("input-list-plus-btn_texts-0").last().click(); await page.getByTestId("input-list-plus-btn_texts-0").last().click();
// await page.getByTestId("inputlist_str_texts_0").last().fill("oh my cat died"); await page.getByTestId("inputlist_str_texts_0").last().fill("oh my cat died");
// await page await page
// .getByTestId("inputlist_str_texts_1") .getByTestId("inputlist_str_texts_1")
// .last() .last()
// .fill("No one loves me"); .fill("No one loves me");
// await page.getByTestId("inputlist_str_texts_2").last().fill("not cool.."); await page.getByTestId("inputlist_str_texts_2").last().fill("not cool..");
// //---------------------------------- PARSE DATA //---------------------------------- PARSE DATA
// await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").click();
// await page.getByTestId("sidebar-search-input").fill("parse data"); await page.getByTestId("sidebar-search-input").fill("parse data");
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await page await page
// .getByTestId("helpersParse Data") .getByTestId("helpersParse Data")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// await page await page
// .getByTestId("helpersParse Data") .getByTestId("helpersParse Data")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// //---------------------------------- PASS //---------------------------------- PASS
// await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").click();
// await page.getByTestId("sidebar-search-input").fill("pass"); await page.getByTestId("sidebar-search-input").fill("pass");
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await page await page
// .getByTestId("prototypesPass") .getByTestId("prototypesPass")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await page await page
// .getByTestId("prototypesPass") .getByTestId("prototypesPass")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await page await page
// .getByTestId("prototypesPass") .getByTestId("prototypesPass")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// //---------------------------------- PROMPT //---------------------------------- PROMPT
// await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").click();
// await page.getByTestId("sidebar-search-input").fill("prompt"); await page.getByTestId("sidebar-search-input").fill("prompt");
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await page await page
// .getByTestId("promptsPrompt") .getByTestId("promptsPrompt")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// //---------------------------------- OPENAI //---------------------------------- OPENAI
// await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").click();
// await page.getByTestId("sidebar-search-input").fill("openai"); await page.getByTestId("sidebar-search-input").fill("openai");
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await page await page
// .getByTestId("modelsOpenAI") .getByTestId("modelsOpenAI")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// //---------------------------------- CONDITIONAL ROUTER //---------------------------------- CONDITIONAL ROUTER
// await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").click();
// await page.getByTestId("sidebar-search-input").fill("conditional router"); await page.getByTestId("sidebar-search-input").fill("conditional router");
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await page await page
// .getByTestId("prototypesConditional Router") .getByTestId("prototypesConditional Router")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// //---------------------------------- CHAT OUTPUT //---------------------------------- CHAT OUTPUT
// await page.getByTestId("sidebar-search-input").click(); await page.getByTestId("sidebar-search-input").click();
// await page.getByTestId("sidebar-search-input").fill("chat output"); await page.getByTestId("sidebar-search-input").fill("chat output");
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await page await page
// .getByTestId("outputsChat Output") .getByTestId("outputsChat Output")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await page await page
// .getByTestId("outputsChat Output") .getByTestId("outputsChat Output")
// .dragTo(page.locator('//*[@id="react-flow-id"]')); .dragTo(page.locator('//*[@id="react-flow-id"]'));
// //---------------------------------- //----------------------------------
// await page.getByTestId("fit_view").click(); await page.getByTestId("fit_view").click();
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await moveElementByX(page, "Chat Output", 400, 1); await moveElementByX(page, "Chat Output", 400, 1);
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await moveElementByX(page, "Chat Output", 700, 0); await moveElementByX(page, "Chat Output", 700, 0);
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await moveElementByX(page, "Conditional Router", 1100, 0); 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); await moveElementByX(page, "OpenAI", 980, 0);
// await page.getByTestId("fit_view").click(); await page.getByTestId("fit_view").click();
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await moveElementByX(page, "Prompt", 990, 0); await moveElementByX(page, "Prompt", 990, 0);
// await page.getByTestId("fit_view").click(); await page.getByTestId("fit_view").click();
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await moveElementByX(page, "Pass", 1000, 2); await moveElementByX(page, "Pass", 1000, 2);
// await page.getByTestId("fit_view").click(); await page.getByTestId("fit_view").click();
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await moveElementByXY(page, "Pass", 0, 200, 1); await moveElementByXY(page, "Pass", 0, 200, 1);
// await page.getByTestId("fit_view").click(); await page.getByTestId("fit_view").click();
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await moveElementByXY(page, "Pass", 150, 200, 0); await moveElementByXY(page, "Pass", 150, 200, 0);
// await page.getByTestId("fit_view").click(); await page.getByTestId("fit_view").click();
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await moveElementByXY(page, "Parse Data", 300, 200, 1); await moveElementByXY(page, "Parse Data", 300, 200, 1);
// await page.getByTestId("fit_view").click(); await page.getByTestId("fit_view").click();
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await moveElementByXY(page, "Parse Data", 450, 200, 0); await moveElementByXY(page, "Parse Data", 450, 200, 0);
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await moveElementByXY(page, "Create List", 600, 200, 1); await moveElementByXY(page, "Create List", 600, 200, 1);
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await moveElementByXY(page, "Create List", 800, 200, 0); await moveElementByXY(page, "Create List", 800, 200, 0);
// await page.waitForTimeout(500); await page.waitForTimeout(500);
// await page.getByTestId("fit_view").click(); await page.getByTestId("fit_view").click();
// //---------------------------------- EDIT PROMPT //---------------------------------- EDIT PROMPT
// await page.getByTestId("promptarea_prompt_template").first().click(); await page.getByTestId("promptarea_prompt_template").first().click();
// await page.getByTestId("modal-promptarea_prompt_template").first().fill(` await page.getByTestId("modal-promptarea_prompt_template").first().fill(`
// {Condition} {Condition}
// Answer with either TRUE or FALSE (and nothing else). Answer with either TRUE or FALSE (and nothing else).
// TRUE Examples: TRUE Examples:
// {true_examples} {true_examples}
// FALSE Examples: FALSE Examples:
// {false_examples} {false_examples}
// User: {user_message} User: {user_message}
// AI: AI:
// `); `);
// await page.getByText("Check & Save").last().click(); await page.getByText("Check & Save").last().click();
// //---------------------------------- MAKE CONNECTIONS //---------------------------------- MAKE CONNECTIONS
// await page await page
// .getByTestId("handle-createlist-shownode-data list-right") .getByTestId("handle-createlist-shownode-data list-right")
// .nth(0) .nth(0)
// .click(); .click();
// await page.getByTestId("handle-parsedata-shownode-data-left").nth(0).click(); await page.getByTestId("handle-parsedata-shownode-data-left").nth(0).click();
// await page await page
// .getByTestId("handle-createlist-shownode-data list-right") .getByTestId("handle-createlist-shownode-data list-right")
// .nth(2) .nth(2)
// .click(); .click();
// await page.getByTestId("handle-parsedata-shownode-data-left").nth(1).click(); await page.getByTestId("handle-parsedata-shownode-data-left").nth(1).click();
// await page await page
// .getByTestId("handle-chatinput-shownode-message-right") .getByTestId("handle-chatinput-shownode-message-right")
// .nth(0) .nth(0)
// .click(); .click();
// await page await page
// .getByTestId("handle-pass-shownode-input message-left") .getByTestId("handle-pass-shownode-input message-left")
// .nth(2) .nth(2)
// .click(); .click();
// await page.getByTestId("handle-parsedata-shownode-text-right").nth(0).click(); await page.getByTestId("handle-parsedata-shownode-text-right").nth(0).click();
// await page await page
// .getByTestId("handle-prompt-shownode-true_examples-left") .getByTestId("handle-prompt-shownode-true_examples-left")
// .nth(0) .nth(0)
// .click(); .click();
// await page.getByTestId("handle-parsedata-shownode-text-right").nth(2).click(); await page.getByTestId("handle-parsedata-shownode-text-right").nth(2).click();
// await page await page
// .getByTestId("handle-prompt-shownode-false_examples-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-pass-shownode-output message-right")
// .nth(4) .nth(4)
// .click(); .click();
// await page await page
// .getByTestId("handle-prompt-shownode-user_message-left") .getByTestId("handle-prompt-shownode-user_message-left")
// .nth(0) .nth(0)
// .click(); .click();
// await page await page
// .getByTestId("handle-prompt-shownode-prompt message-right") .getByTestId("handle-prompt-shownode-prompt message-right")
// .first() .first()
// .click(); .click();
// await page await page
// .getByTestId("handle-openaimodel-shownode-input-left") .getByTestId("handle-openaimodel-shownode-input-left")
// .nth(0) .nth(0)
// .click(); .click();
// await page await page
// .getByTestId("handle-openaimodel-shownode-text-right") .getByTestId("handle-openaimodel-shownode-text-right")
// .nth(0) .nth(0)
// .click(); .click();
// await page await page
// .getByTestId("handle-conditionalrouter-shownode-input text-left") .getByTestId("handle-conditionalrouter-shownode-input text-left")
// .nth(0) .nth(0)
// .click(); .click();
// await page.getByTestId("popover-anchor-input-match_text").fill("TRUE"); await page.getByTestId("popover-anchor-input-match_text").fill("TRUE");
// await page.getByTestId("title-Pass").nth(1).click(); await page.getByTestId("title-Pass").nth(1).click();
// await page.getByTestId("edit-button-modal").click(); await page.getByTestId("edit-button-modal").click();
// await page await page
// .getByTestId("popover-anchor-input-input_message-edit") .getByTestId("popover-anchor-input-input_message-edit")
// .nth(0) .nth(0)
// .fill("You're Happy! 🤪"); .fill("You're Happy! 🤪");
// await page.getByTestId("showignored_message").last().click(); await page.getByTestId("showignored_message").last().click();
// await page.getByText("Close").last().click(); await page.getByText("Close").last().click();
// await page.getByTestId("title-Pass").nth(0).click(); await page.getByTestId("title-Pass").nth(0).click();
// await page.getByTestId("edit-button-modal").click(); await page.getByTestId("edit-button-modal").click();
// await page await page
// .getByTestId("popover-anchor-input-input_message-edit") .getByTestId("popover-anchor-input-input_message-edit")
// .nth(0) .nth(0)
// .fill("You're Sad! 🥲"); .fill("You're Sad! 🥲");
// await page.getByTestId("showignored_message").last().click(); await page.getByTestId("showignored_message").last().click();
// await page.getByText("Close").last().click(); await page.getByText("Close").last().click();
// await page await page
// .getByTestId("handle-conditionalrouter-shownode-true route-right") .getByTestId("handle-conditionalrouter-shownode-true route-right")
// .nth(0) .nth(0)
// .click(); .click();
// await page await page
// .getByTestId("handle-pass-shownode-ignored message-left") .getByTestId("handle-pass-shownode-ignored message-left")
// .nth(1) .nth(1)
// .click(); .click();
// await page await page
// .getByTestId("handle-conditionalrouter-shownode-false route-right") .getByTestId("handle-conditionalrouter-shownode-false route-right")
// .nth(0) .nth(0)
// .click(); .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.getByTestId("handle-chatoutput-shownode-text-left").nth(0).click();
// await page await page
// .getByTestId("handle-pass-shownode-output message-right") .getByTestId("handle-pass-shownode-output message-right")
// .nth(0) .nth(0)
// .click(); .click();
// await page.getByTestId("handle-chatoutput-shownode-text-left").nth(1).click(); await page.getByTestId("handle-chatoutput-shownode-text-left").nth(1).click();
// const apiKeyInput = page.getByTestId("popover-anchor-input-api_key"); const apiKeyInput = page.getByTestId("popover-anchor-input-api_key");
// const isApiKeyInputVisible = await apiKeyInput.isVisible(); const isApiKeyInputVisible = await apiKeyInput.isVisible();
// if (isApiKeyInputVisible) { if (isApiKeyInputVisible) {
// await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? ""); await apiKeyInput.fill(process.env.OPENAI_API_KEY ?? "");
// } }
// await page.getByTestId("dropdown_str_model_name").click(); await page.getByTestId("dropdown_str_model_name").click();
// await page.getByTestId("gpt-4o-1-option").click(); await page.getByTestId("gpt-4o-1-option").click();
// await page.getByTestId("fit_view").click(); await page.getByTestId("fit_view").click();
// await page.getByText("Playground", { exact: true }).last().click(); await page.getByText("Playground", { exact: true }).last().click();
// await page.waitForSelector('[data-testid="input-chat-playground"]', { await page.waitForSelector('[data-testid="input-chat-playground"]', {
// timeout: 100000, timeout: 100000,
// }); });
// await page.getByTestId("input-chat-playground").click(); await page.getByTestId("input-chat-playground").click();
// await page await page
// .getByTestId("input-chat-playground") .getByTestId("input-chat-playground")
// .fill("my dog is alive and happy!"); .fill("my dog is alive and happy!");
// await page.waitForSelector('[data-testid="icon-LucideSend"]', { await page.waitForSelector('[data-testid="button-send"]', {
// timeout: 100000, timeout: 100000,
// }); });
// await page.getByTestId("icon-LucideSend").click();
await page.getByTestId("button-send").last().click();
}); });