fix: add code button decoration when throwing custom component in screen (#6823)
* made pasted component be selected * Added bg when is custom component and component is not edited * Added test to check if custom component button is pink * Stop chatinput propagation * fixed tests --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
parent
f748ea9bc8
commit
9ade6977c7
5 changed files with 80 additions and 5 deletions
73
src/frontend/tests/core/features/customComponentAdd.spec.ts
Normal file
73
src/frontend/tests/core/features/customComponentAdd.spec.ts
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
import { expect, test } from "@playwright/test";
|
||||
import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";
|
||||
|
||||
test(
|
||||
"custom component code button should be pink when adding custom component",
|
||||
{ tag: ["@release", "@components"] },
|
||||
|
||||
async ({ page }) => {
|
||||
await awaitBootstrapTest(page);
|
||||
|
||||
await page.waitForSelector('[data-testid="blank-flow"]', {
|
||||
timeout: 3000,
|
||||
});
|
||||
|
||||
await page.getByTestId("blank-flow").click();
|
||||
|
||||
await page.waitForSelector('[data-testid="zoom_out"]', {
|
||||
timeout: 3000,
|
||||
});
|
||||
|
||||
await page.getByTestId("sidebar-custom-component-button").click();
|
||||
|
||||
await expect(page.getByTestId("code-button-modal")).toBeVisible({
|
||||
timeout: 3000,
|
||||
});
|
||||
|
||||
await expect(page.getByTestId("code-button-modal")).toHaveClass(
|
||||
/!bg-accent-pink/,
|
||||
);
|
||||
|
||||
await page.getByTestId("code-button-modal").last().click();
|
||||
|
||||
const waitTimeoutCode = `
|
||||
# from langflow.field_typing import Data
|
||||
from langflow.custom import Component
|
||||
from langflow.io import MessageTextInput, Output
|
||||
from langflow.schema import Data
|
||||
from time import sleep
|
||||
from langflow.schema.message import Message
|
||||
|
||||
class CustomComponent(Component):
|
||||
display_name = "Custom Component"
|
||||
description = "Use as a template to create your own component."
|
||||
documentation: str = "https://docs.langflow.org/components-custom-components"
|
||||
icon = "custom_components"
|
||||
name = "CustomComponent"
|
||||
|
||||
inputs = [
|
||||
MessageTextInput(name="input_value", display_name="Input Value", value="Hello, World!"),
|
||||
]
|
||||
|
||||
outputs = [
|
||||
Output(display_name="Output", name="output", method="build_output"),
|
||||
]
|
||||
|
||||
def build_output(self) -> Message:
|
||||
data = Data(value=self.input_value)
|
||||
self.status = data
|
||||
sleep(60)
|
||||
return data`;
|
||||
|
||||
await page.locator(".ace_content").click();
|
||||
await page.keyboard.press(`ControlOrMeta+A`);
|
||||
await page.locator("textarea").fill(waitTimeoutCode);
|
||||
|
||||
await page.getByText("Check & Save").last().click();
|
||||
|
||||
await expect(page.getByTestId("code-button-modal")).not.toHaveClass(
|
||||
/!bg-accent-pink/,
|
||||
{ timeout: 3000 },
|
||||
);
|
||||
},
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue