mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-12 12:40:29 +08:00
Chat Interface Functional test Fix + Chat Examples Center (#9660)
* test fix * add changeset * test fixc * test fix * Revert "test fix" This reverts commit 9720f675cb3bb0fbfc0904dc5cf982e987dcc8ef. --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
d0c1e78977
commit
3407b505c7
6
.changeset/slick-doodles-dance.md
Normal file
6
.changeset/slick-doodles-dance.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gradio/chatbot": minor
|
||||
"gradio": minor
|
||||
---
|
||||
|
||||
feat:Chat Interface Functional test Fix + Chat Examples Center
|
@ -433,6 +433,7 @@
|
||||
transition: var(--button-transition);
|
||||
max-width: var(--size-56);
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.example:hover {
|
||||
|
@ -3,22 +3,22 @@ import { spawnSync } from "node:child_process";
|
||||
import { launch_app_background, kill_process } from "./utils";
|
||||
import { join } from "path";
|
||||
|
||||
let _process;
|
||||
|
||||
const demo_file = "chat_demo.py";
|
||||
let _process;
|
||||
|
||||
test.beforeAll(() => {
|
||||
const demo = `
|
||||
import gradio as gr
|
||||
|
||||
def greet(msg, history):
|
||||
return "Hello"
|
||||
|
||||
def greet(msg, history):
|
||||
return "Hello"
|
||||
|
||||
demo = gr.ChatInterface(fn=greet)
|
||||
demo = gr.ChatInterface(fn=greet)
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo.launch()
|
||||
`;
|
||||
if __name__ == "__main__":
|
||||
demo.launch()
|
||||
`;
|
||||
// write contents of demo to a local 'run.py' file
|
||||
spawnSync(`echo '${demo}' > ${join(process.cwd(), demo_file)}`, {
|
||||
shell: true,
|
||||
stdio: "pipe",
|
||||
@ -55,16 +55,17 @@ test("gradio dev mode correctly reloads a stateful ChatInterface demo", async ({
|
||||
_process = server_process;
|
||||
console.log("Connected to port", port);
|
||||
const demo = `
|
||||
import gradio as gr
|
||||
import gradio as gr
|
||||
|
||||
def greet(msg, history):
|
||||
return f"You typed: {msg}"
|
||||
def greet(msg, history):
|
||||
return f"You typed: {msg}"
|
||||
|
||||
demo = gr.ChatInterface(fn=greet, textbox=gr.Textbox(label="foo", placeholder="Type a message..."))
|
||||
demo = gr.ChatInterface(fn=greet, textbox=gr.Textbox(label="foo", placeholder="Type a message..."))
|
||||
|
||||
if __name__ == "__main__":
|
||||
demo.launch()
|
||||
`;
|
||||
if __name__ == "__main__":
|
||||
demo.launch()
|
||||
`;
|
||||
// write contents of demo to a local 'run.py' file
|
||||
await page.goto(`http://localhost:${port}`);
|
||||
await page.waitForTimeout(2000);
|
||||
spawnSync(`echo '${demo}' > ${join(process.cwd(), demo_file)}`, {
|
||||
@ -75,12 +76,12 @@ if __name__ == "__main__":
|
||||
PYTHONUNBUFFERED: "true"
|
||||
}
|
||||
});
|
||||
|
||||
await expect(page.getByLabel("foo")).toBeVisible();
|
||||
const textbox = page.getByPlaceholder("Type a message...");
|
||||
const submit_button = page.getByRole("button", { name: "Submit" });
|
||||
const textbox = page.getByTestId("textbox").first();
|
||||
|
||||
await textbox.fill("hello");
|
||||
await submit_button.click();
|
||||
await textbox.press("Enter");
|
||||
|
||||
await expect(textbox).toHaveValue("");
|
||||
const response = page.locator(".bot p", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user