Release Unicode Tools 0.1.0
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
|
||||
const ORIGIN = "http://127.0.0.1:4173";
|
||||
async function localOnly(page: Page) {
|
||||
const external: string[] = [];
|
||||
await page.route("**/*", async (route) => {
|
||||
const url = new URL(route.request().url());
|
||||
if (url.origin !== ORIGIN) {
|
||||
external.push(url.href);
|
||||
await route.abort();
|
||||
} else await route.continue();
|
||||
});
|
||||
return external;
|
||||
}
|
||||
|
||||
test("runs from a nested path without external requests", async ({ page }) => {
|
||||
const errors: string[] = [];
|
||||
page.on("pageerror", (error) => errors.push(error.message));
|
||||
page.on("console", (message) => {
|
||||
if (message.type() === "error") errors.push(message.text());
|
||||
});
|
||||
const external = await localOnly(page);
|
||||
await page.goto("/deep/nested/unicode/");
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Unicode Tools" }),
|
||||
).toBeVisible();
|
||||
expect(external).toEqual([]);
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
|
||||
test("serves the release identity and hardened headers", async ({
|
||||
request,
|
||||
}) => {
|
||||
const index = await request.get("/deep/nested/unicode/");
|
||||
expect(index.ok()).toBe(true);
|
||||
expect(index.headers()["content-security-policy"]).toContain(
|
||||
"default-src 'self'",
|
||||
);
|
||||
expect(await index.text()).not.toMatch(/\b(?:src|href)=["']\//u);
|
||||
const manifest = await request.get("/deep/nested/unicode/toolbox-app.json");
|
||||
await expect(manifest.json()).resolves.toMatchObject({
|
||||
id: "de.add-ideas.unicode-tools",
|
||||
version: "0.1.0",
|
||||
entry: "./",
|
||||
});
|
||||
});
|
||||
|
||||
test("searches the pinned catalog in a worker and shows character properties", async ({
|
||||
page,
|
||||
}) => {
|
||||
const external = await localOnly(page);
|
||||
await page.goto("/deep/nested/unicode/");
|
||||
await page.getByLabel("Name, alias, character, or U+ code").fill("U+1F600");
|
||||
await page.getByRole("button", { name: "Search", exact: true }).click();
|
||||
const result = page.getByRole("button", { name: /GRINNING FACE/u });
|
||||
await expect(result).toBeVisible({ timeout: 60_000 });
|
||||
await result.click();
|
||||
await expect(page.getByText("Unicode 6.1")).toBeVisible();
|
||||
await expect(page.getByText("Common / Emoticons")).toBeVisible();
|
||||
expect(external).toEqual([]);
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { App } from "../../src/App";
|
||||
|
||||
describe("Unicode Tools", () => {
|
||||
it("renders the local workbench and standard shell", async () => {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn(async () => new Response("Not found", { status: 404 })),
|
||||
);
|
||||
render(<App />);
|
||||
expect(
|
||||
await screen.findByRole("heading", { name: "Unicode Tools" }),
|
||||
).toBeVisible();
|
||||
expect(
|
||||
await screen.findByText("Official data · local search"),
|
||||
).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
codePointLabel,
|
||||
compareNormalization,
|
||||
decodeCodePointList,
|
||||
inspectText,
|
||||
parseCodePointList,
|
||||
} from "../../src/unicode/model";
|
||||
|
||||
describe("Unicode helper integration", () => {
|
||||
it("parses and decodes scalar values", () => {
|
||||
expect(parseCodePointList("U+0041 1F600")).toEqual([0x41, 0x1f600]);
|
||||
expect(decodeCodePointList("41, 1F600")).toBe("A😀");
|
||||
expect(() => parseCodePointList("D800")).toThrow(/scalar value/u);
|
||||
});
|
||||
|
||||
it("inspects code points separately from graphemes", () => {
|
||||
const result = inspectText("e\u0301");
|
||||
expect(result.codePointCount).toBe(2);
|
||||
expect(result.graphemes).toHaveLength(1);
|
||||
expect(result.points[1]?.javascript).toBe("\\u0301");
|
||||
});
|
||||
|
||||
it("compares all normalization forms", () => {
|
||||
const result = compareNormalization("e\u0301");
|
||||
expect(result.forms.find((item) => item.form === "NFC")?.value).toBe("é");
|
||||
expect(codePointLabel(0x1f600)).toBe("U+1F600");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user