onlyoffice-word-preview.spec.ts 1.12 KB
import { test, expect } from "@playwright/test";

/**
 * 缺陷 1008567 - Word 文件预览修复
 *
 * 验收标准:
 * 1. 工作台加载 Word 文件时使用 OnlyOfficeViewer 组件
 * 2. OnlyOfficeViewer 以只读模式打开(permissions.edit = false)
 * 3. 页面不出现 "Can't find end of central directory" 等解析错误
 */
test.describe("Word 文件只读预览 (#1008567)", () => {
  test("工作台包含 OnlyOfficeViewer 挂载点", async ({ page }) => {
    await page.goto("/#/app/workspace");
    await page.waitForLoadState("domcontentloaded");

    // OnlyOfficeViewer 的编辑器容器 id 以 onlyoffice-editor- 开头
    // 此处只验证 workspace 页面正常加载,不报 JS 错误
    const errors: string[] = [];
    page.on("pageerror", (err) => errors.push(err.message));

    await page.waitForTimeout(2000);

    // 不应有 "Can't find end of central directory" 错误(jszip Word 解析失败)
    const hasCentralDirError = errors.some((e) =>
      e.includes("Can't find end of central directory")
    );
    expect(hasCentralDirError, "不应出现 jszip Word 解析错误").toBe(false);
  });
});