Close workbench P0 resource lifecycle gaps

This commit is contained in:
lix-2026
2026-05-20 20:48:18 +08:00
parent e0b0e70fb8
commit fe13444dbc
14 changed files with 610 additions and 7 deletions
@@ -255,6 +255,22 @@ async function main() {
});
assert.equal(activeAfterOfficeClose.kind, "markdown", `关闭 office tab 后应回到 markdown tab: ${JSON.stringify(activeAfterOfficeClose)}`);
assert(activeAfterOfficeClose.text.includes("resource-note.md"), `markdown tab 标题应包含资源名: ${JSON.stringify(activeAfterOfficeClose)}`);
const markdownActiveState = await page.evaluate(() => {
const url = new URL(window.location.href);
const activeResource = url.searchParams.get("resourceTab") || "";
const activeRow = document.querySelector('#sidebar-file-tree-root .tree-row[data-shell-mode="filetree"][data-active="true"]');
const resourceRows = Array.from(document.querySelectorAll('#sidebar-file-tree-root .tree-row[data-shell-mode="filetree"][data-asset-id]')).map((row) => row.getAttribute("data-asset-id") || "");
return {
activeResource,
activeRowAssetId: activeRow?.getAttribute("data-asset-id") || "",
resourceRows,
selectedRows: Array.from(document.querySelectorAll('#sidebar-file-tree-root .tree-row[data-shell-mode="filetree"][data-selected="true"]')).map((row) => row.getAttribute("data-asset-id") || row.getAttribute("data-row-id") || ""),
};
});
assert(markdownActiveState.activeResource.includes("resource-note.md"), `激活 resource tab 应写入 canonical resourceTab URL 状态: ${JSON.stringify(markdownActiveState)}`);
if (markdownActiveState.resourceRows.includes(asset.id)) {
assert.equal(markdownActiveState.activeRowAssetId, asset.id, `已渲染对应 filetree row 时应标记 data-active: ${JSON.stringify(markdownActiveState)}`);
}
const mdCloseBtn = page.locator('.mnote-main-tab.is-active[data-mnote-tab-kind="markdown"] .mnote-main-tab-close');
await mdCloseBtn.click({ timeout: UI_TIMEOUT_MS });
@@ -270,6 +286,7 @@ async function main() {
assert.equal(activeAfterAllClosed.kind, "page", `关闭所有 resource tab 后应回到 page tab: ${JSON.stringify(activeAfterAllClosed)}`);
assert.equal(activeAfterAllClosed.resourceTabCount, 0, `resource tab 应全部关闭: ${JSON.stringify(activeAfterAllClosed)}`);
assert.equal(activeAfterAllClosed.panelHidden, true, `resource tab host 应隐藏: ${JSON.stringify(activeAfterAllClosed)}`);
assert.equal(new URL(page.url()).searchParams.get("resourceTab"), null, "关闭所有 resource tab 后应清除 resourceTab URL 状态");
console.log(JSON.stringify({ ok: true, root, assetPath, assetId: asset.id, officeAssetId: officeAsset.id }, null, 2));
} finally {