fix: allow returning from resource tabs

This commit is contained in:
lix-2026
2026-05-20 17:00:17 +08:00
parent bdc05c1d27
commit bbd9dab701
3 changed files with 44 additions and 10 deletions
@@ -117,10 +117,31 @@ async function main() {
const resourceText = await resourceEditor.innerText({ timeout: UI_TIMEOUT_MS });
assert(resourceText.includes("资源正文"), `MD 附件应在资源 tab 中用 tiptap 打开:${resourceText}`);
assert.equal(popups.length, 0, `点击 MD 附件不应打开浏览器新窗口,实际 popup=${popups.length}`);
const pageTab = page.locator('[data-mnote-main-tab="page"]').first();
await pageTab.click({ timeout: UI_TIMEOUT_MS });
await page.waitForFunction(() => {
const pagePanel = document.querySelector("[data-mnote-page-tab-panel]");
const resourceHost = document.querySelector("[data-mnote-resource-tab-host]");
const pageTab = document.querySelector('[data-mnote-main-tab="page"]');
return pagePanel && !pagePanel.hidden
&& resourceHost && resourceHost.hidden
&& pageTab && pageTab.classList.contains("is-active");
}, null, { timeout: UI_TIMEOUT_MS });
const pageText = await page.locator('.document-pane[data-pane-role="primary"] .editor-surface .ProseMirror').first().innerText({
timeout: UI_TIMEOUT_MS,
});
assert(pageText.includes("resource-note.md"), "主页面正文应保持原附件链接");
const resourceTab = page.locator('.mnote-main-tab[data-mnote-tab-kind="markdown"]').first();
await resourceTab.click({ timeout: UI_TIMEOUT_MS });
await page.locator('.mnote-main-tab.is-active[data-mnote-tab-kind="markdown"]').waitFor({
state: "visible",
timeout: UI_TIMEOUT_MS,
});
await resourceEditor.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
console.log(JSON.stringify({ ok: true, root, documentId, popups: popups.length }, null, 2));
} finally {
await context.close().catch(() => undefined);