langflow/src/frontend/tests/core/features/playground.spec.ts
Deon Sanchez 4ab4e736be
feat: Quality of Life improvements for Astra Component (#6953)
* feat: Add helper text for Astra DB embedding generation provider

* feat: Add helper text support for dropdown and parameter components

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* Update astradb.py

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* feat: Add org_id to excluded metadata keys in dropdown component

* fix: Update Astra DB component UI and starter project configuration

- Improved AstraDB component's embedding provider link with better accessibility attributes
- Updated Vector Store RAG starter project JSON with formatted configuration
- Refined UI text and link presentation for better user experience

* Remove providers that arent configured

* feat: Add required field indicator to node parameters

- Implemented visual indicator (*) for required node parameters
- Updated custom parameter title rendering to show required status
- Enhanced UI to provide clearer input requirements

* Revert "Merge branch 'lfoss-683-1' of https://github.com/langflow-ai/langflow into lfoss-683-1"

This reverts commit 2eb0fcb4d3d347de0df1f021f761ea63e882b757, reversing
changes made to 9ea44aca477e8a418ef82722da4b1e0fc2afa2e1.

* [autofix.ci] apply automated fixes

* Add changes back

* Fix some comments

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes

* Update astradb.py

* feat: Add dynamic disabled state for node dialog and int component

* feat: Add dynamic placeholder for node dialog input

* [autofix.ci] apply automated fixes

* feat: Enhance IntComponent with disabled state styling and stepper interactions

* Fix some db creation params

* Update astradb.py

* fix: Resolve node dialog input value handling in TypeScript

* Update astradb.py

* feat: Add required field validation to node dialog submission

* Update astradb.py

* [autofix.ci] apply automated fixes

* Update astradb.py

* Clean up functions and add read only flag

* feat: Add readonly support to IntComponent and improve node dialog validation

* fix: Improve dropdown component disabled and empty options handling

* console.log removed

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* Read only field and cleanup

* Astra DB selector updates

* [autofix.ci] apply automated fixes

* fix: Improve dropdown component disabled state handling

* Fix value of region in create db

* [autofix.ci] apply automated fixes

* Remove database icon from component

* fix: Conditionally render dropdown option icons

* Don't show Nvidia if not available

* [autofix.ci] apply automated fixes

* Exceptions unless pending mean, skip

* feat: Enhance AstraDBVectorStoreComponent with HTML sanitization

- Added DOMPurify for sanitizing HTML input in the convertStringToHTML function.
- Introduced a new sanitizeHTML function to ensure safe rendering of HTML strings.

* fix: Correct field key usage in NodeDialog and refactor disabled class name in IntComponent

- Updated NodeDialogComponent to use fieldKey instead of underscore for better clarity in mapping field values.
- Refactored IntComponent to replace the getDisabledClassName function with a constant for the disabled input class, improving readability.

*  (playground.spec.ts): Refactor drag and drop functionality to use hover and click for better interaction
🔧 (chatInputOutput.spec.ts): Update drag and drop functionality to use target position for more precise placement
🔧 (chatInputOutputUser-shard-1.spec.ts): Simplify connecting elements by replacing hover and mouse actions with click for better user experience

* 🐛 (generalBugs-prompt.spec.ts): fix issue with selecting the last element with getByTestId to ensure correct element is clicked and tested

*  (chatInputOutputUser-shard-1.spec.ts): add 600ms timeout to wait for elements to be interactable before proceeding with the test steps

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Hare <ericrhare@gmail.com>
Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
2025-03-14 22:34:14 +00:00

210 lines
8.2 KiB
TypeScript

import { expect, test } from "@playwright/test";
import * as dotenv from "dotenv";
import path from "path";
import { adjustScreenView } from "../../utils/adjust-screen-view";
import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";
test(
"fresh start playground",
{ tag: ["@release", "@workspace", "@api"] },
async ({ page }) => {
if (!process.env.CI) {
dotenv.config({ path: path.resolve(__dirname, "../../.env") });
}
await awaitBootstrapTest(page);
await page.waitForSelector('[data-testid="blank-flow"]', {
timeout: 30000,
});
await page.getByTestId("blank-flow").click();
await page.getByTestId("sidebar-search-input").click();
await page.getByTestId("sidebar-search-input").fill("chat output");
await page.waitForSelector('[data-testid="outputsChat Output"]', {
timeout: 100000,
});
await page
.getByTestId("outputsChat Output")
.hover()
.then(async () => {
await page.getByTestId("add-component-button-chat-output").click();
});
await page.getByTestId("zoom_out").click();
await page.getByTestId("zoom_out").click();
await page.getByTestId("sidebar-search-input").click();
await page.getByTestId("sidebar-search-input").fill("chat input");
await page.waitForSelector('[data-testid="inputsChat Input"]', {
timeout: 100000,
});
await page
.getByTestId("inputsChat Input")
.dragTo(page.locator('//*[@id="react-flow-id"]'), {
targetPosition: { x: 100, y: 100 },
});
await page.getByTestId("sidebar-search-input").click();
await page.getByTestId("sidebar-search-input").fill("text output");
await page.waitForSelector('[data-testid="outputsText Output"]', {
timeout: 100000,
});
await page
.getByTestId("outputsText Output")
.dragTo(page.locator('//*[@id="react-flow-id"]'), {
targetPosition: { x: 300, y: 300 },
});
await adjustScreenView(page);
await page
.getByTestId("handle-chatinput-noshownode-message-source")
.click();
await page.getByTestId("handle-textoutput-shownode-text-left").click();
await page.getByTestId("handle-textoutput-shownode-message-right").click();
await page.getByTestId("handle-chatoutput-noshownode-text-target").click();
await page.getByText("Playground", { exact: true }).last().click();
await page.waitForSelector('[data-testid="input-chat-playground"]', {
timeout: 100000,
});
//send message
await page.getByTestId("input-chat-playground").click();
await page.getByTestId("input-chat-playground").fill("message 1");
await page.keyboard.press("Enter");
//check message
await page.getByTestId("chat-message-User-message 1").click();
await page
.getByTestId("chat-message-AI-message 1")
.getByText("message")
.click();
//check session
await page.getByText("Default Session").first().click();
await page.getByTestId("chat-message-User-message 1").click();
//check edit message
await page.getByTestId("chat-message-User-message 1").hover();
await page
.locator("div")
.filter({ hasText: /^Usermessage 1$/ })
.getByTestId("icon-Pen")
.click();
await page.getByTestId("textarea").fill("edit_1");
await page.getByTestId("save-button").click();
await page.getByTestId("chat-message-User-edit_1").click();
await page.getByTestId("chat-message-User-edit_1").hover();
// check cancel edit
await page.getByTestId("sender_name_user").hover();
await page.getByTestId("icon-Pen").first().click();
await page.getByTestId("textarea").fill("cancel_edit");
await page.getByTestId("cancel-button").click();
await page.getByTestId("chat-message-User-edit_1").click();
await page.getByTestId("chat-message-User-edit_1").hover();
//check edit bot message
await page
.getByTestId("chat-message-AI-message 1")
.getByText("message")
.click();
await page.getByTestId("chat-message-AI-message 1").hover();
await page.getByTestId("icon-Pen").last().click();
await page.getByTestId("textarea").fill("edit_bot_1");
await page.getByTestId("save-button").click();
await page.getByText("edit_bot_1").click();
// check cancel edit bot
await page.getByTestId("chat-message-AI-edit_bot_1").hover();
await page.getByTestId("icon-Pen").last().click();
await page.getByTestId("textarea").fill("edit_bot_cancel");
await page.getByTestId("cancel-button").click();
await page.getByText("edit_bot_1").click();
await page.getByTestId("chat-message-AI-edit_bot_1").hover();
// check table messages view
await page.getByRole("combobox").click();
await page.getByLabel("Message logs").click();
await page.getByText("Page 1 of 1", { exact: true }).click();
// check rename session
await page.getByRole("combobox").click();
await page.getByLabel("Rename").getByText("Rename").click();
await page.getByRole("textbox").fill("new name");
await page.getByTestId("icon-Check").click();
await page.waitForTimeout(500);
await page.getByTestId("session-selector").getByText("new name").click();
// check cancel rename
await page.getByRole("combobox").click();
await page.getByLabel("Rename").getByText("Rename").click();
await page.getByRole("textbox").fill("cancel name");
await page.getByTestId("session-selector").getByTestId("icon-X").click();
await page.getByTestId("session-selector").getByText("new name").click();
// check cancel rename blur
await page.getByRole("combobox").click();
await page.getByLabel("Rename").getByText("Rename").click();
await page.getByRole("textbox").fill("cancel_blur");
await page.getByText("PlaygroundChat").click();
await page.getByTestId("session-selector").getByText("new name").click();
// check delete session
await page.getByRole("combobox").click();
await page.getByLabel("Delete").click();
await page.getByRole("heading", { name: "New chat" }).click();
// check new session
await page.getByTestId("input-chat-playground").click();
await page
.getByTestId("input-chat-playground")
.fill("session_after_delete");
await page.keyboard.press("Enter");
await page.getByTestId("chat-message-User-session_after_delete").click();
await expect(page.getByTestId("session-selector")).toBeVisible();
// check helpful button
await page.getByTestId("chat-message-AI-session_after_delete").hover();
await page.getByTestId("helpful-button").click();
await page.getByTestId("chat-message-AI-session_after_delete").hover();
await expect(page.getByTestId("icon-ThumbUpIconCustom")).toBeVisible({
timeout: 10000,
});
await page.getByTestId("helpful-button").click();
await page.getByTestId("chat-message-AI-session_after_delete").hover();
await expect(page.getByTestId("icon-ThumbUpIconCustom")).toBeVisible({
timeout: 10000,
visible: false,
});
// check not helpful button
await page.getByTestId("chat-message-AI-session_after_delete").hover();
await page.getByTestId("not-helpful-button").click();
await page.getByTestId("chat-message-AI-session_after_delete").hover();
await expect(page.getByTestId("icon-ThumbDownIconCustom")).toBeVisible({
timeout: 10000,
});
await page.getByTestId("not-helpful-button").click();
await page.getByTestId("chat-message-AI-session_after_delete").hover();
await expect(page.getByTestId("icon-ThumbDownIconCustom")).toBeVisible({
timeout: 10000,
visible: false,
});
// check switch feedback
await page.getByTestId("chat-message-AI-session_after_delete").hover();
await page.getByTestId("helpful-button").click();
await page.getByTestId("chat-message-AI-session_after_delete").hover();
await expect(page.getByTestId("icon-ThumbUpIconCustom")).toBeVisible({
timeout: 10000,
});
await page.getByTestId("not-helpful-button").click();
await page.getByTestId("chat-message-AI-session_after_delete").hover();
await expect(page.getByTestId("icon-ThumbDownIconCustom")).toBeVisible({
timeout: 10000,
});
await expect(page.getByTestId("icon-ThumbUpIconCustom")).toBeVisible({
timeout: 10000,
visible: false,
});
},
);