Testing Image Gallery Example Updates in Gradio App
This test suite validates image modification and example updating functionality in a Gradio application interface. It focuses on verifying the correct updating of image examples and ensuring proper image source attribute changes during user interactions.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
gradio-app/gradio
js/spa/test/image_mod.spec.ts
import { test, expect } from "@self/tootils";
test("examples_get_updated_correctly", async ({ page }) => {
await page.locator(".gallery-item").first().click();
let image = await page.getByTestId("image").locator("img").first();
await expect(await image.getAttribute("src")).toContain("cheetah1.jpg");
await page.getByRole("button", { name: "Update Examples" }).click();
let example_image;
await expect(async () => {
example_image = await page.locator(".gallery-item").locator("img").first();
await expect(await example_image.getAttribute("src")).toContain("logo.png");
}).toPass();
await example_image.click();
await expect(async () => {
image = await page.getByTestId("image").locator("img").first();
await expect(await image.getAttribute("src")).toContain("logo.png");
}).toPass();
});