feat: add tool_mode parameter to MessageTextInput in ID Generator Component (#5311)

* feat: add tool_mode parameter to MessageTextInput for enhanced functionality

* fix: update tool mode test to ensure correct functionality and response handling

- Adjusted test to wait for the "Toolset" element to appear before asserting its count.
- Modified code handling to replace "tool_mode=True" with "tool_mode=False" and verified the updated code is different.
- Added response check for the custom component to ensure a successful status (200) after submission.

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
VICTOR CORREA GOMES 2024-12-18 18:54:13 -03:00 committed by GitHub
commit e79b1649a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 14 deletions

View file

@ -21,6 +21,7 @@ class IDGeneratorComponent(Component):
display_name="Value",
info="The generated unique ID.",
refresh_button=True,
tool_mode=True,
),
]

View file

@ -32,7 +32,12 @@ test(
await page.getByTestId("title-ID Generator").click();
await page.keyboard.press("ControlOrMeta+Shift+m");
expect(await page.getByText("Toolset", { exact: true }).count()).toBe(0);
await page.waitForSelector('text="Toolset"', {
timeout: 3000,
});
expect(
await page.getByText("Toolset", { exact: true }).count(),
).toBeGreaterThan(0);
await page.getByTestId("title-ID Generator").click();
@ -43,29 +48,26 @@ test(
await page.getByTestId("code-button-modal").click();
let code = await extractAndCleanCode(page);
code = code!.replace(
"refresh_button=True,",
"refresh_button=True,\n tool_mode=True,",
);
let updatedCode = code!.replace("tool_mode=True", "tool_mode=False");
expect(updatedCode).not.toBe(code);
await page.locator("textarea").last().press(`ControlOrMeta+a`);
await page.keyboard.press("Backspace");
await page.locator("textarea").last().fill(code);
await page.locator("textarea").last().fill(updatedCode);
const customComponentPromise = page.waitForResponse("**/custom_component");
await page.locator('//*[@id="checkAndSaveBtn"]').click();
const customComponentResponse = await customComponentPromise;
// check if the response is 200
expect(customComponentResponse?.status()).toBe(200);
await page.waitForSelector('[data-testid="fit_view"]', {
await page.waitForSelector('[data-testid="title-ID Generator"]', {
timeout: 3000,
});
await page.getByTestId("title-ID Generator").click();
await page.keyboard.press("ControlOrMeta+Shift+m");
await page.waitForSelector('text="Toolset"', {
timeout: 3000,
});
expect(
await page.getByText("Toolset", { exact: true }).count(),
).toBeGreaterThan(0);
expect(await page.getByText("Toolset", { exact: true }).count()).toBe(0);
},
);