@@ -82,6 +82,11 @@ test("adds and corrects a real local image while retaining the previous preview"
|
||||
"aria-valuetext",
|
||||
/^1% from left/u,
|
||||
);
|
||||
await page.getByLabel("Corner 2 X (%)").fill("98.5");
|
||||
await expect(page.getByRole("slider", { name: "Corner 2" })).toHaveAttribute(
|
||||
"aria-valuetext",
|
||||
/^99% from left/u,
|
||||
);
|
||||
const download = page.waitForEvent("download");
|
||||
await page.getByRole("button", { name: "Download PNG" }).click();
|
||||
expect((await download).suggestedFilename()).toBe("page-scan.png");
|
||||
@@ -156,6 +161,13 @@ test("runs the bundled OCR engine without an external request", async ({
|
||||
timeout: 90_000,
|
||||
});
|
||||
await expect(page.getByLabel("Recognized text")).toContainText(/LOCAL|SCAN/u);
|
||||
await expect(page.getByLabel(/positioned OCR words/u)).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Download hOCR geometry" }),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
page.getByRole("button", { name: "Download OCR TSV" }),
|
||||
).toBeVisible();
|
||||
expect(external).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -191,8 +203,12 @@ test("integrates help, themes, identity, headers and offline reload", async ({
|
||||
);
|
||||
await expect(manifest.json()).resolves.toMatchObject({
|
||||
id: "de.add-ideas.scan-tools",
|
||||
version: "0.1.0",
|
||||
requirements: { workers: true },
|
||||
version: "0.2.0",
|
||||
requirements: { workers: false },
|
||||
capabilities: {
|
||||
required: [],
|
||||
optional: expect.arrayContaining(["workers"]),
|
||||
},
|
||||
privacy: { processing: "local", telemetry: false },
|
||||
});
|
||||
await context.setOffline(true);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("keeps the primary workspace inside a narrow viewport", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.goto("/deep/nested/scan-tools/");
|
||||
await expect(page.locator("main").first()).toBeVisible();
|
||||
await expect(
|
||||
page.locator("main .loading, main .workbench-loading"),
|
||||
).toHaveCount(0);
|
||||
|
||||
const widths = await page.evaluate(() => ({
|
||||
content: document.documentElement.scrollWidth,
|
||||
viewport: document.documentElement.clientWidth,
|
||||
}));
|
||||
expect(widths.viewport).toBeLessThanOrEqual(430);
|
||||
expect(widths.content).toBeLessThanOrEqual(widths.viewport + 1);
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { perspectiveCorrectPixels } from "../../src/scan/render";
|
||||
import { defaultAdjustments } from "../../src/scan/types";
|
||||
|
||||
class TestImageData {
|
||||
data: Uint8ClampedArray;
|
||||
width: number;
|
||||
height: number;
|
||||
constructor(width: number, height: number) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.data = new Uint8ClampedArray(width * height * 4);
|
||||
}
|
||||
}
|
||||
|
||||
describe("scan render core", () => {
|
||||
afterEach(() => vi.unstubAllGlobals());
|
||||
|
||||
it("maps an identity quad without changing corner colours", () => {
|
||||
vi.stubGlobal("ImageData", TestImageData);
|
||||
const source = new TestImageData(2, 2) as unknown as ImageData;
|
||||
source.data.set([
|
||||
255, 0, 0, 255, 0, 255, 0, 255, 0, 0, 255, 255, 255, 255, 255, 255,
|
||||
]);
|
||||
const result = perspectiveCorrectPixels(source, 2, 2, defaultAdjustments());
|
||||
expect([...result.data]).toEqual([...source.data]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user