From 9a57462536f99f86ef42d7c259ca702072e92111 Mon Sep 17 00:00:00 2001 From: oratis Date: Mon, 24 Aug 2026 00:45:48 +0800 Subject: [PATCH] =?UTF-8?q?test(e2e):=20wide-tables=20=E7=9A=84=E7=B2=98?= =?UTF-8?q?=E8=B4=B4=E6=94=B9=E6=88=90=E6=9B=BF=E6=8D=A2=E6=95=B4=E7=AF=87?= =?UTF-8?q?=E2=80=94=E2=80=94=E5=85=89=E6=A0=87=E8=90=BD=E7=82=B9=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E7=9C=8B=E7=89=88=E9=9D=A2=E8=84=B8=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wide-tables.spec.ts 在 main 上就时红时绿(703402d 那次 CI 也红): 量到 685 而不是 720。本地 4 workers 跑 27 次复现 8 次。 根因:pasteMarkdown 点编辑区**中心**放光标,落点取决于版面——字体 加载、mermaid 异步渲染后的高度变化——落进列表项或引用块,表格就嵌 套在里面,量到的是容器宽度(685)而不是正文列(720)。设计 09 §5 那 次"等图渲染完再点"只压住了一种时序,CI 上还有别的。 修法:粘贴前 ⌘A。点击只负责聚焦,光标落在哪都无所谓——整篇被替换, 表格必然是顶层块。改后 4 workers × 4 轮 36 次全绿,全套 e2e 29 条全绿。 Co-Authored-By: Claude Opus 5 --- e2e/wide-tables.spec.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/e2e/wide-tables.spec.ts b/e2e/wide-tables.spec.ts index d3a2ad83..eb2c64b8 100644 --- a/e2e/wide-tables.spec.ts +++ b/e2e/wide-tables.spec.ts @@ -63,10 +63,18 @@ async function tableMetrics(page: Page) { }); } -/** Put `markdown` on the clipboard and paste it at the caret. */ +/** + * Put `markdown` on the clipboard and paste it in place of the whole + * document. Select-all first: a click only *focuses* the editor, and where + * the caret lands depends on layout (font loading, the async diagram) — in + * a list item or blockquote the table measures that container (685px), not + * the prose column (720px). Replacing the document makes the table a + * top-level block regardless. + */ async function pasteMarkdown(page: Page, markdown: string) { await page.evaluate((md) => navigator.clipboard.writeText(md), markdown); await page.locator(".ProseMirror").click(); + await page.keyboard.press("ControlOrMeta+a"); await page.keyboard.press("ControlOrMeta+v"); await expect(page.locator(".milkdown .editor table")).toBeVisible(); } @@ -97,11 +105,10 @@ test.beforeEach(async ({ context, page }) => { "contenteditable", "true", ); - // The welcome document contains a mermaid block, and it renders to SVG - // asynchronously — which changes the document height. `pasteMarkdown` - // clicks the CENTRE of the editor to place the caret, so pasting before - // the diagram settles can drop the table inside a blockquote or list item - // and measure that container instead of the prose column. Wait it out. + // The welcome document contains a mermaid block that renders to SVG + // asynchronously. `pasteMarkdown` replaces the whole document, so the + // caret position no longer matters — but let the diagram settle anyway so + // no in-flight render races the replacement. await expect(page.locator(".milkdown .editor .mk-diagram-wrap svg")).toBeVisible(); });