Release Office Tools 0.2.0
Verify / verify (push) Canceled after 0s

This commit is contained in:
2026-09-02 07:32:31 +02:00
parent a5524e27e3
commit 08b8f84f7b
50 changed files with 2196 additions and 165 deletions
+36
View File
@@ -0,0 +1,36 @@
import { describe, expect, it } from "vitest";
import {
createStyleResolver,
safeOdfTransform,
} from "../../src/components/odf-viewer-model";
describe("OpenDocument fidelity adapters", () => {
it("inherits default and named styles without exposing raw CSS", () => {
const resolve = createStyleResolver([
{
name: "__default__:paragraph",
isDefault: true,
family: "paragraph",
properties: { "paragraph-properties.fo:color": "#123456" },
},
{
name: "Body",
family: "paragraph",
properties: { "paragraph-properties.fo:text-align": "justify" },
},
]);
expect(resolve(undefined, "paragraph")).toMatchObject({ color: "#123456" });
expect(resolve("Body", "paragraph")).toMatchObject({
color: "#123456",
textAlign: "justify",
});
});
it("converts only a bounded inert drawing-transform subset", () => {
expect(safeOdfTransform("translate(2cm 3cm) rotate(0.5) scale(2)")).toBe(
"translate(2cm, 3cm) rotate(0.5rad) scale(2)",
);
expect(safeOdfTransform("url(https://example.test)")).toBeUndefined();
expect(safeOdfTransform("matrix(1 0 0 1 2 3)")).toBeUndefined();
});
});
+20 -2
View File
@@ -23,15 +23,33 @@ describe("UploadWorkbench", () => {
const user = userEvent.setup();
render(<UploadWorkbench />);
const input = screen.getByLabelText("Open office file");
const file = new File(["local fixture"], "report.docx", {
const bytes = new Uint8Array(13);
bytes.set([0x50, 0x4b, 0x03, 0x04]);
const file = new File([bytes], "report.docx", {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
});
await user.upload(input, file);
const heading = screen.getByRole("region", { name: "report.docx" });
const heading = await screen.findByRole("region", { name: "report.docx" });
expect(heading).toHaveTextContent("report.docx");
expect(heading).toHaveTextContent("13 B");
expect(screen.getByLabelText("Test OOXML viewer")).toBeInTheDocument();
expect(
screen.getByRole("button", { name: "Save exact copy" }),
).toBeVisible();
});
it("explains a renamed legacy compound-binary file", async () => {
const user = userEvent.setup();
render(<UploadWorkbench />);
const file = new File(
[Uint8Array.from([0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1])],
"renamed.docx",
);
await user.upload(screen.getByLabelText("Open office file"), file);
expect(await screen.findByRole("alert")).toHaveTextContent(
"legacy OLE Compound File",
);
});
});