gradio/js/app/test/image_remote_url.spec.ts
Yuichiro Tachibana (Tsuchiya) 522daf787a
Patch async_save_url_to_cache for Lite (#8026)
* Update `async_save_url_to_cache` to work on Wasm

* Refactoring `save_url_to_cache`

* add changeset

* Fix

* Use pyodide.http as a custom transport of httpx

* Use urllib3 as a custom transport of httpx to make sync http requests

* Add an E2E test case to detect the bugs on remote resource caching

* add changeset

* Add image_remote_url E2E test

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
2024-04-17 03:54:34 +09:00

31 lines
1.1 KiB
TypeScript

import { test, expect } from "@gradio/tootils";
test("Image displays remote image correctly", async ({ page }) => {
const example_image = page.locator(
'div.block:has(div.label:has-text("Examples")) img'
);
const input_image = page.locator(
'div.block:has(label:has-text("InputImage")) img'
);
const loopback_image = page.locator(
'div.block:has(label:has-text("Loopback")) img'
);
const remote_output_image = page.locator(
'div.block:has(label:has-text("RemoteImage")) img'
);
const submit_button = page.locator('button:has-text("Submit")');
await expect(example_image).toHaveJSProperty("complete", true);
await expect(example_image).not.toHaveJSProperty("naturalWidth", 0);
await expect(input_image).toHaveJSProperty("complete", true);
await expect(input_image).not.toHaveJSProperty("naturalWidth", 0);
await submit_button.click();
await expect(loopback_image).toHaveJSProperty("complete", true);
await expect(loopback_image).not.toHaveJSProperty("naturalWidth", 0);
await expect(remote_output_image).toHaveJSProperty("complete", true);
await expect(remote_output_image).not.toHaveJSProperty("naturalWidth", 0);
});