Align resource tabs with workbench review
This commit is contained in:
@@ -243,6 +243,34 @@ async function main() {
|
||||
assert(officePopupUrl.searchParams.get("mode") === "edit", "显式 new-window 应保留 edit 模式");
|
||||
await officePopup.close().catch(() => undefined);
|
||||
|
||||
const officeCloseBtn = page.locator('.mnote-main-tab.is-active[data-mnote-tab-kind="office"] .mnote-main-tab-close');
|
||||
await officeCloseBtn.click({ timeout: UI_TIMEOUT_MS });
|
||||
await page.waitForTimeout(200);
|
||||
const activeAfterOfficeClose = await page.evaluate(() => {
|
||||
const activeTab = document.querySelector(".mnote-main-tab.is-active");
|
||||
return {
|
||||
kind: activeTab?.getAttribute("data-mnote-tab-kind") || "",
|
||||
text: activeTab?.textContent?.trim() || "",
|
||||
};
|
||||
});
|
||||
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 mdCloseBtn = page.locator('.mnote-main-tab.is-active[data-mnote-tab-kind="markdown"] .mnote-main-tab-close');
|
||||
await mdCloseBtn.click({ timeout: UI_TIMEOUT_MS });
|
||||
await page.waitForTimeout(200);
|
||||
const activeAfterAllClosed = await page.evaluate(() => {
|
||||
const activeTab = document.querySelector(".mnote-main-tab.is-active");
|
||||
return {
|
||||
kind: activeTab?.getAttribute("data-mnote-tab-kind") || "",
|
||||
resourceTabCount: document.querySelectorAll('.mnote-main-tab[data-mnote-tab-kind]:not([data-mnote-tab-kind="page"])').length,
|
||||
panelHidden: document.querySelector("[data-mnote-resource-tab-host]")?.hasAttribute("hidden"),
|
||||
};
|
||||
});
|
||||
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)}`);
|
||||
|
||||
console.log(JSON.stringify({ ok: true, root, assetPath, assetId: asset.id, officeAssetId: officeAsset.id }, null, 2));
|
||||
} finally {
|
||||
await context.close().catch(() => undefined);
|
||||
|
||||
Reference in New Issue
Block a user