chore: align local-first control plane and editor fixes
- wire SQLite control-plane access/session paths into Rust web local-folder routes - preserve local Markdown attachment semantics across upload, reload, and secondary-pane resource tabs - refresh design governance docs, Reasonix task templates, and bug records - retire root .mcp.json local MCP config
This commit is contained in:
@@ -53,6 +53,62 @@ async function quickLogin(page) {
|
||||
}
|
||||
}
|
||||
|
||||
async function activatePrimaryPageTab(page) {
|
||||
const pageTab = page.locator('[data-mnote-main-tab="page"][data-pane-role="primary"]').first();
|
||||
if (await pageTab.count()) {
|
||||
await pageTab.click({ timeout: UI_TIMEOUT_MS }).catch(() => undefined);
|
||||
}
|
||||
await page.locator('.document-pane[data-pane-role="primary"] .editor-surface .ProseMirror').first().waitFor({
|
||||
state: "visible",
|
||||
timeout: UI_TIMEOUT_MS,
|
||||
});
|
||||
}
|
||||
|
||||
async function uploadAttachmentViaPrimarySlash(page, fileName, markdown) {
|
||||
await activatePrimaryPageTab(page);
|
||||
const editor = page.locator('.document-pane[data-pane-role="primary"] .editor-surface .ProseMirror').first();
|
||||
await editor.click({ timeout: UI_TIMEOUT_MS });
|
||||
await page.keyboard.press("End").catch(() => undefined);
|
||||
await page.keyboard.type("/");
|
||||
const item = page
|
||||
.locator('.document-pane[data-pane-role="primary"] [data-testid="slash-item-upload-attachment"]')
|
||||
.first();
|
||||
await item.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
|
||||
const [fileChooser] = await Promise.all([
|
||||
page.waitForEvent("filechooser", { timeout: UI_TIMEOUT_MS }),
|
||||
item.click({ timeout: UI_TIMEOUT_MS }),
|
||||
]);
|
||||
await fileChooser.setFiles({
|
||||
name: fileName,
|
||||
mimeType: "text/markdown",
|
||||
buffer: Buffer.from(markdown, "utf8"),
|
||||
});
|
||||
await page.waitForFunction(
|
||||
(name) => {
|
||||
const editor = document.querySelector('.document-pane[data-pane-role="primary"] .editor-surface .ProseMirror');
|
||||
return editor instanceof HTMLElement && (editor.textContent || "").includes(name);
|
||||
},
|
||||
fileName,
|
||||
{ timeout: UI_TIMEOUT_MS },
|
||||
);
|
||||
}
|
||||
|
||||
async function clickPrimaryAttachmentAndExpectTab(page, fileName) {
|
||||
await activatePrimaryPageTab(page);
|
||||
const link = page
|
||||
.locator('.document-pane[data-pane-role="primary"] .editor-surface .ProseMirror a[href*="/api/local-folder/files/open"]', {
|
||||
hasText: fileName,
|
||||
})
|
||||
.first();
|
||||
await link.click({ timeout: UI_TIMEOUT_MS });
|
||||
await page.locator('.mnote-main-tab.is-active[data-pane-role="primary"][data-mnote-tab-kind="markdown"]', {
|
||||
hasText: fileName,
|
||||
}).waitFor({
|
||||
state: "visible",
|
||||
timeout: UI_TIMEOUT_MS,
|
||||
});
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), "mnote-task459-md-attachment-"));
|
||||
const relativePath = "README.md";
|
||||
@@ -100,7 +156,8 @@ async function main() {
|
||||
await link.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
|
||||
await page.waitForFunction(() => {
|
||||
const node = document.querySelector('.document-pane[data-pane-role="primary"] .editor-surface .ProseMirror a[href*="/api/local-folder/files/open"][href*="README%2Fresource-note.md"]');
|
||||
return node && node.classList.contains("mnote-uploaded-attachment-row") && node.getAttribute("data-mnote-attachment-link") === "true";
|
||||
return node instanceof HTMLAnchorElement
|
||||
&& (node.classList.contains("mnote-uploaded-attachment-row") || getComputedStyle(node).display === "inline-flex");
|
||||
}, null, { timeout: UI_TIMEOUT_MS });
|
||||
|
||||
await link.click({ timeout: UI_TIMEOUT_MS });
|
||||
@@ -142,6 +199,13 @@ async function main() {
|
||||
});
|
||||
await resourceEditor.waitFor({ state: "visible", timeout: UI_TIMEOUT_MS });
|
||||
|
||||
await uploadAttachmentViaPrimarySlash(page, "uploaded-one.md", "# Uploaded One\n\n第一个上传附件\n");
|
||||
await clickPrimaryAttachmentAndExpectTab(page, "uploaded-one.md");
|
||||
await uploadAttachmentViaPrimarySlash(page, "uploaded-two.md", "# Uploaded Two\n\n第二个上传附件\n");
|
||||
await clickPrimaryAttachmentAndExpectTab(page, "uploaded-one.md");
|
||||
await clickPrimaryAttachmentAndExpectTab(page, "uploaded-two.md");
|
||||
assert.equal(popups.length, 0, `连续上传两个 MD 附件后点击不应打开浏览器新窗口,实际 popup=${popups.length}`);
|
||||
|
||||
console.log(JSON.stringify({ ok: true, root, documentId, popups: popups.length }, null, 2));
|
||||
} finally {
|
||||
await context.close().catch(() => undefined);
|
||||
|
||||
Reference in New Issue
Block a user