@@ -1,4 +1,4 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { App } from "../../src/App";
|
||||
|
||||
@@ -13,7 +13,41 @@ describe("EPUB Tools", () => {
|
||||
await screen.findByRole("heading", { name: "EPUB Tools" }),
|
||||
).toBeVisible();
|
||||
expect(
|
||||
await screen.findByText("Sandboxed reader · local files"),
|
||||
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(<App />);
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user