Custom component 2e2 test (#7394)

* e2e test

* Add requirements
This commit is contained in:
Freddy Boulton 2024-02-12 10:06:22 -08:00 committed by GitHub
parent 17fb116492
commit a4a990ca05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1 @@
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: gradio_pdf_demo"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "from gradio_pdf import PDF\n", "\n", "\n", "demo = gr.Interface(lambda x: x,\n", " PDF(),\n", " gr.File())\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}

View File

@ -0,0 +1,10 @@
import gradio as gr
from gradio_pdf import PDF
demo = gr.Interface(lambda x: x,
PDF(),
gr.File())
if __name__ == "__main__":
demo.launch()

Binary file not shown.

View File

@ -0,0 +1,21 @@
import { test, expect } from "@gradio/tootils";
test("Custom PDF component demo can be loaded and inference function works .", async ({
page
}) => {
await page
.getByRole("button", { name: "Drop PDF - or - Click to Upload" })
.first()
.click();
const uploader = await page.locator("input[type=file]").first();
await uploader.setInputFiles(["./test/files/contract.pdf"]);
await page.getByRole("button", { name: "Submit" }).click();
await expect(page.getByLabel("contract.pdf")).toBeVisible();
const downloadPromise = page.waitForEvent("download");
await page.getByRole("link").nth(0).click();
const download = await downloadPromise;
await expect(download.suggestedFilename()).toBe("contract.pdf");
});

View File

@ -40,7 +40,7 @@ filelock==3.7.1
# via
# huggingface-hub
# transformers
gradio_pdf==0.0.3
gradio_pdf==0.0.5
# via -r requirements.in
h11==0.12.0
# via httpcore