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:
Dawood Khan 2024-10-14 12:30:58 -04:00 committed by GitHub
parent d0c1e78977
commit 3407b505c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 19 deletions

View File

@ -0,0 +1,6 @@
---
"@gradio/chatbot": minor
"gradio": minor
---
feat:Chat Interface Functional test Fix + Chat Examples Center

View File

@ -433,6 +433,7 @@
transition: var(--button-transition);
max-width: var(--size-56);
width: 100%;
justify-content: center;
}
.example:hover {

View File

@ -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", {