mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-25 12:10:31 +08:00
Fix Functional Tests (#9619)
* tests * changes * add changeset * chet fixes * fixes * add changeset * changes --------- Co-authored-by: Ali Abid <aliabid94@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co> Co-authored-by: aliabid94 <aabid94@gmail.com>
This commit is contained in:
parent
c163182d1b
commit
1f3ee97d10
6
.changeset/stupid-windows-write.md
Normal file
6
.changeset/stupid-windows-write.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gradio/chatbot": minor
|
||||
"gradio": minor
|
||||
---
|
||||
|
||||
feat:Fix Functional Tests
|
@ -1433,6 +1433,7 @@ class Blocks(BlockContext, BlocksEvents, metaclass=BlocksMeta):
|
||||
root_context.fn_id = max(root_context.fns.keys(), default=-1) + 1
|
||||
Context.root_block.temp_file_sets.extend(self.temp_file_sets)
|
||||
Context.root_block.proxy_urls.update(self.proxy_urls)
|
||||
Context.root_block.extra_startup_events.extend(self.extra_startup_events)
|
||||
|
||||
render_context = get_render_context()
|
||||
if render_context is not None:
|
||||
|
@ -376,6 +376,10 @@ class Examples:
|
||||
outputs=self.outputs, # type: ignore
|
||||
show_api=False,
|
||||
)
|
||||
else:
|
||||
warnings.warn(
|
||||
f"If an Examples object is created outside a Blocks Context, make sure to call `examples.dataset.render()`{'and `examples.create()`' if self.cache_examples else ''} to render the examples in the interface."
|
||||
)
|
||||
|
||||
async def _postprocess_output(self, output) -> list:
|
||||
"""
|
||||
|
@ -71,6 +71,7 @@
|
||||
label="Retry"
|
||||
on:click={() => handle_action("retry")}
|
||||
disabled={generating}
|
||||
label="Retry"
|
||||
/>
|
||||
{/if}
|
||||
{#if show_undo}
|
||||
@ -79,6 +80,7 @@
|
||||
Icon={Undo}
|
||||
on:click={() => handle_action("undo")}
|
||||
disabled={generating}
|
||||
label="Undo"
|
||||
/>
|
||||
{/if}
|
||||
{#if likeable}
|
||||
|
@ -39,8 +39,5 @@ test("shows the results tab when results > 0", async ({ page }) => {
|
||||
.getByRole("textbox")
|
||||
.press("Enter");
|
||||
|
||||
await page.getByText("New row").click();
|
||||
|
||||
await page.waitForTimeout(1000);
|
||||
await page.getByText("Start Practice").dblclick();
|
||||
});
|
||||
|
@ -25,7 +25,7 @@ test("Image events are dispatched correctly. Downloading the file works and has
|
||||
await page.getByLabel("Download").click();
|
||||
const download = await downloadPromise;
|
||||
// PIL converts from .jpg to .jpeg
|
||||
await expect(download.suggestedFilename()).toBe("cheetah1.jpeg");
|
||||
await expect(download.suggestedFilename()).toBe("cheetah1.jpg");
|
||||
|
||||
await page.getByLabel("Remove Image").click();
|
||||
await expect(clear_counter).toHaveValue("1");
|
||||
|
@ -31,16 +31,16 @@ test("test datastructure-based state changes", async ({ page }) => {
|
||||
await expect(page.getByLabel("Output")).toHaveValue(
|
||||
`{1: 1, 2: 2, 3: 3}\n[[1, 2, 3], [1, 2, 3], [1, 2, 3]]\n{1, 2, 3}`
|
||||
);
|
||||
await expect(page.getByLabel("Changes")).toHaveValue("1");
|
||||
await expect(page.getByLabel("Clicks")).toHaveValue("1");
|
||||
await expect(page.getByLabel("Changes").first()).toHaveValue("1");
|
||||
await expect(page.getByLabel("Clicks").first()).toHaveValue("1");
|
||||
|
||||
await page.getByRole("button", { name: "Count to" }).click();
|
||||
await expect(page.getByLabel("Changes")).toHaveValue("1");
|
||||
await expect(page.getByLabel("Clicks")).toHaveValue("2");
|
||||
await expect(page.getByLabel("Changes").first()).toHaveValue("1");
|
||||
await expect(page.getByLabel("Clicks").first()).toHaveValue("2");
|
||||
|
||||
await page.getByRole("button", { name: "Count to" }).click();
|
||||
await expect(page.getByLabel("Changes")).toHaveValue("1");
|
||||
await expect(page.getByLabel("Clicks")).toHaveValue("3");
|
||||
await expect(page.getByLabel("Changes").first()).toHaveValue("1");
|
||||
await expect(page.getByLabel("Clicks").first()).toHaveValue("3");
|
||||
await expect(page.getByLabel("Output")).toHaveValue(
|
||||
`{1: 1, 2: 2, 3: 3}\n[[1, 2, 3], [1, 2, 3], [1, 2, 3]]\n{1, 2, 3}`
|
||||
);
|
||||
@ -49,12 +49,12 @@ test("test datastructure-based state changes", async ({ page }) => {
|
||||
await expect(page.getByLabel("Output")).toHaveValue(
|
||||
`{0: 0}\n[[0, 0, 0], [0, 0, 0], [0, 0, 0]]\n{0}`
|
||||
);
|
||||
await expect(page.getByLabel("Changes")).toHaveValue("2");
|
||||
await expect(page.getByLabel("Clicks")).toHaveValue("4");
|
||||
await expect(page.getByLabel("Changes").first()).toHaveValue("2");
|
||||
await expect(page.getByLabel("Clicks").first()).toHaveValue("4");
|
||||
|
||||
await page.getByRole("button", { name: "Zero All" }).click();
|
||||
await expect(page.getByLabel("Changes")).toHaveValue("2");
|
||||
await expect(page.getByLabel("Clicks")).toHaveValue("5");
|
||||
await expect(page.getByLabel("Changes").first()).toHaveValue("2");
|
||||
await expect(page.getByLabel("Clicks").first()).toHaveValue("5");
|
||||
});
|
||||
|
||||
test("test generators properly trigger state changes", async ({ page }) => {
|
||||
|
@ -2,6 +2,7 @@ import { test, expect } from "@self/tootils";
|
||||
|
||||
test("submit works", async ({ page }) => {
|
||||
await page.getByTestId("textbox").first().focus();
|
||||
await page.getByTestId("textbox").first().fill("test");
|
||||
await page.keyboard.press("Enter");
|
||||
|
||||
await expect(page.getByLabel("Prompt", { exact: true })).toHaveValue("image");
|
||||
|
@ -16,7 +16,7 @@ for (const test_case of cases) {
|
||||
await go_to_testcase(page, test_case);
|
||||
}
|
||||
const submit_button = page.locator(".submit-button");
|
||||
const textbox = page.getByPlaceholder("Type a message...");
|
||||
const textbox = page.getByTestId("textbox").first();
|
||||
|
||||
await textbox.fill("hello");
|
||||
await submit_button.click();
|
||||
@ -39,11 +39,11 @@ for (const test_case of cases) {
|
||||
await expect(expected_text_el_1).toBeVisible();
|
||||
await expect(page.locator(".bot.message")).toHaveCount(2);
|
||||
|
||||
await page.getByLabel("undo button").click();
|
||||
await page.getByLabel("undo").first().click();
|
||||
await expect(page.locator(".bot.message")).toHaveCount(1);
|
||||
await expect(textbox).toHaveValue("hi");
|
||||
|
||||
await page.getByLabel("retry button").click();
|
||||
await page.getByLabel("retry").first().click();
|
||||
const expected_text_el_2 = page.locator(".bot p", {
|
||||
hasText: "Run 3 - You typed: hello"
|
||||
});
|
||||
@ -59,7 +59,7 @@ for (const test_case of cases) {
|
||||
});
|
||||
await expect(expected_text_el_3).toBeVisible();
|
||||
await expect(page.locator(".bot.message")).toHaveCount(2);
|
||||
await page.getByLabel("clear button").click();
|
||||
await page.getByLabel("clear").first().click();
|
||||
await expect(page.locator(".bot.message")).toHaveCount(0);
|
||||
});
|
||||
|
||||
@ -69,7 +69,7 @@ for (const test_case of cases) {
|
||||
if (cases.slice(1).includes(test_case)) {
|
||||
await go_to_testcase(page, test_case);
|
||||
}
|
||||
const textbox = page.getByPlaceholder("Type a message...");
|
||||
const textbox = page.getByTestId("textbox").first();
|
||||
const submit_button = page.locator(".submit-button");
|
||||
await textbox.fill("hi");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user