完成当前主线 checklist 阶段收口

This commit is contained in:
lix-2026
2026-05-19 12:35:53 +08:00
parent 16f00a5e82
commit ab3f06f4c4
4 changed files with 149 additions and 73 deletions
@@ -103,6 +103,18 @@ async function readObjectShellState(page) {
}));
}
async function readOnlyOfficePageState(page) {
return await page.evaluate(() => ({
currentUrl: window.location.href,
ready: Boolean(window.__MNOTE_ONLYOFFICE_READY__),
editorExists: Boolean(window.__MNOTE_ONLYOFFICE_EDITOR__),
frameCount: document.querySelectorAll("#onlyoffice-frame iframe, #onlyoffice-frame canvas").length,
errorVisible: document.getElementById("onlyoffice-error")?.getAttribute("data-visible") || "",
debug: window.__MNOTE_ONLYOFFICE_DEBUG__ || null,
errorLog: Array.isArray(window.__MNOTE_ONLYOFFICE_ERRLOG__) ? window.__MNOTE_ONLYOFFICE_ERRLOG__.slice() : [],
}));
}
async function readFileTreeProjection(request, workspaceId, rootNodeId) {
return await requestJson(
request,
@@ -194,9 +206,15 @@ async function readFileTreeProjection(request, workspaceId, rootNodeId) {
await page.click(`#sidebar-file-tree-root .tree-row[data-asset-id="${officeAssetId}"] .tree-link`, { timeout: UI_TIMEOUT_MS });
const officePage = await officePopupPromise;
await officePage.waitForLoadState("domcontentloaded", { timeout: UI_TIMEOUT_MS });
await officePage.waitForSelector("[data-mnote-object-editor='onlyoffice']", { timeout: UI_TIMEOUT_MS });
result.afterOfficeOpen = await readObjectShellState(officePage);
assert(result.afterOfficeOpen.currentObjectIdentity.includes(`resource:onlyoffice:${doc.documentId}:${officeAssetId}`), "office 对象壳应暴露 resource identity");
await officePage.waitForURL((url) => url.pathname === "/onlyoffice", { timeout: UI_TIMEOUT_MS });
await officePage.waitForFunction(
() => Boolean(window.__MNOTE_ONLYOFFICE_READY__) || Boolean(window.__MNOTE_ONLYOFFICE_EDITOR__),
{ timeout: UI_TIMEOUT_MS },
);
result.afterOfficeOpen = await readOnlyOfficePageState(officePage);
assert(new URL(result.afterOfficeOpen.currentUrl).pathname === "/onlyoffice", "office 应打开 OnlyOffice 页面");
assert(result.afterOfficeOpen.ready || result.afterOfficeOpen.editorExists, "OnlyOffice 页面应完成初始化或持有编辑器实例");
assert(result.afterOfficeOpen.debug && result.afterOfficeOpen.debug.assetId === officeAssetId, "OnlyOffice 页面应携带当前资源 assetId");
await writeResult({ ...result, ok: true, finalUrl: page.url() });
console.log(`ok ${TASK} ${RESULT_PATH}`);