feat: restore Wolai workspace navigation and assets
This commit is contained in:
@@ -65,27 +65,24 @@ async function openDocument(page, root, relativePath) {
|
||||
});
|
||||
}
|
||||
|
||||
async function waitForDeletedConflict(page, retainedText) {
|
||||
async function waitForDeletedHomeFallback(page, documentId) {
|
||||
await page.waitForFunction(
|
||||
(needle) => {
|
||||
const root = document.querySelector('[data-testid="mnote-leptos-tiptap-island-editor-root"]');
|
||||
const editorText = document.querySelector('.document-pane[data-pane-role="primary"] .editor-surface .ProseMirror')?.textContent || "";
|
||||
(expectedDocumentId) => {
|
||||
const url = new URL(window.location.href);
|
||||
const panelText = document.querySelector('[data-testid="mnote-editor-conflict-panel"]')?.textContent || "";
|
||||
const snapshot = typeof window.__mnoteDebugDocumentSessions?.snapshot === "function"
|
||||
? window.__mnoteDebugDocumentSessions.snapshot()
|
||||
: null;
|
||||
const envelopeDirtyState = snapshot?.sessions?.[0]?.lastExternalConflictEnvelope?.dirtyState || "";
|
||||
return root?.getAttribute("data-runtime-editor-status") === "external-change-conflict"
|
||||
&& editorText.includes(needle)
|
||||
&& panelText.includes("已被删除")
|
||||
&& envelopeDirtyState === "Deleted";
|
||||
return url.pathname === "/"
|
||||
&& url.searchParams.get("missingPage") === expectedDocumentId
|
||||
&& (url.searchParams.get("routeGuard") === "local_markdown_deleted"
|
||||
|| url.searchParams.get("routeGuard") === "local_markdown_not_found")
|
||||
&& !panelText.includes("文件冲突");
|
||||
},
|
||||
retainedText,
|
||||
documentId,
|
||||
{ timeout: UI_TIMEOUT_MS },
|
||||
);
|
||||
return await page.evaluate(() => ({
|
||||
status: document.querySelector('[data-testid="mnote-leptos-tiptap-island-editor-root"]')?.getAttribute("data-runtime-editor-status") || "",
|
||||
editorText: document.querySelector('.document-pane[data-pane-role="primary"] .editor-surface .ProseMirror')?.textContent || "",
|
||||
url: window.location.href,
|
||||
missingPage: new URL(window.location.href).searchParams.get("missingPage") || "",
|
||||
routeGuard: new URL(window.location.href).searchParams.get("routeGuard") || "",
|
||||
panelText: document.querySelector('[data-testid="mnote-editor-conflict-panel"]')?.textContent || "",
|
||||
sessions: typeof window.__mnoteDebugDocumentSessions?.snapshot === "function"
|
||||
? window.__mnoteDebugDocumentSessions.snapshot()
|
||||
@@ -93,22 +90,24 @@ async function waitForDeletedConflict(page, retainedText) {
|
||||
}));
|
||||
}
|
||||
|
||||
async function waitForExternalMoveConflict(page, retainedText) {
|
||||
async function waitForExternalMoveHomeFallback(page, documentId) {
|
||||
await page.waitForFunction(
|
||||
(needle) => {
|
||||
const root = document.querySelector('[data-testid="mnote-leptos-tiptap-island-editor-root"]');
|
||||
const editorText = document.querySelector('.document-pane[data-pane-role="primary"] .editor-surface .ProseMirror')?.textContent || "";
|
||||
(expectedDocumentId) => {
|
||||
const url = new URL(window.location.href);
|
||||
const panelText = document.querySelector('[data-testid="mnote-editor-conflict-panel"]')?.textContent || "";
|
||||
return root?.getAttribute("data-runtime-editor-status") === "external-change-conflict"
|
||||
&& editorText.includes(needle)
|
||||
&& panelText.includes("文件冲突");
|
||||
return url.pathname === "/"
|
||||
&& url.searchParams.get("missingPage") === expectedDocumentId
|
||||
&& (url.searchParams.get("routeGuard") === "local_markdown_deleted"
|
||||
|| url.searchParams.get("routeGuard") === "local_markdown_not_found")
|
||||
&& !panelText.includes("文件冲突");
|
||||
},
|
||||
retainedText,
|
||||
documentId,
|
||||
{ timeout: UI_TIMEOUT_MS },
|
||||
);
|
||||
return await page.evaluate(() => ({
|
||||
status: document.querySelector('[data-testid="mnote-leptos-tiptap-island-editor-root"]')?.getAttribute("data-runtime-editor-status") || "",
|
||||
editorText: document.querySelector('.document-pane[data-pane-role="primary"] .editor-surface .ProseMirror')?.textContent || "",
|
||||
url: window.location.href,
|
||||
missingPage: new URL(window.location.href).searchParams.get("missingPage") || "",
|
||||
routeGuard: new URL(window.location.href).searchParams.get("routeGuard") || "",
|
||||
panelText: document.querySelector('[data-testid="mnote-editor-conflict-panel"]')?.textContent || "",
|
||||
sessions: typeof window.__mnoteDebugDocumentSessions?.snapshot === "function"
|
||||
? window.__mnoteDebugDocumentSessions.snapshot()
|
||||
@@ -140,11 +139,11 @@ async function main() {
|
||||
await quickLogin(page);
|
||||
await openDocument(page, root, deleteRelativePath);
|
||||
fs.rmSync(path.join(root, deleteRelativePath));
|
||||
const deletedState = await waitForDeletedConflict(page, "保留删除 buffer");
|
||||
const deletedState = await waitForDeletedHomeFallback(page, localMdDocumentId(deleteRelativePath));
|
||||
|
||||
await openDocument(page, root, moveRelativePath);
|
||||
fs.renameSync(path.join(root, moveRelativePath), path.join(root, "Moved.md"));
|
||||
const movedState = await waitForExternalMoveConflict(page, "保留移动 buffer");
|
||||
const movedState = await waitForExternalMoveHomeFallback(page, localMdDocumentId(moveRelativePath));
|
||||
|
||||
console.log(JSON.stringify({
|
||||
ok: true,
|
||||
|
||||
Reference in New Issue
Block a user