import { fireEvent, render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { App } from "../../src/App"; describe("EPUB Tools", () => { it("renders the local workbench and standard shell", async () => { vi.stubGlobal( "fetch", vi.fn(async () => new Response("Not found", { status: 404 })), ); render(); expect( await screen.findByRole("heading", { name: "EPUB Tools" }), ).toBeVisible(); expect( await screen.findByText("Sandboxed reader ยท local files", undefined, { timeout: 4_000, }), ).toBeVisible(); }); it("shows the selected filename and progress before archive work starts", async () => { vi.stubGlobal( "fetch", vi.fn(async () => new Response("Not found", { status: 404 })), ); vi.stubGlobal( "requestAnimationFrame", vi.fn(() => 1), ); render(); const input = await screen.findByLabelText( "Choose publication", undefined, { timeout: 4_000 }, ); fireEvent.change(input, { target: { files: [ new File(["not read yet"], "large-publication.epub", { type: "application/epub+zip", }), ], }, }); const status = await screen.findByRole("status"); expect(status).toHaveTextContent("large-publication.epub"); expect(status).toHaveTextContent("Preparing the local file"); expect( screen.getByRole("progressbar", { name: "EPUB opening progress" }), ).toHaveValue(0); }); });