Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

test(plugins): 折叠粘贴 e2e 等会话就绪再粘贴,消除无会话占位态竞态 (#873)

Mao Mr6bafc1e69e0f
diff --git a/test/e2e/plugins/dsh-tauri-experimental.e2e.ts b/test/e2e/plugins/dsh-tauri-experimental.e2e.ts
index c875b52b..216cd6a5 100644
--- a/test/e2e/plugins/dsh-tauri-experimental.e2e.ts
+++ b/test/e2e/plugins/dsh-tauri-experimental.e2e.ts
@@ -112,6 +112,13 @@ describe('宿主路由:方法矩阵', () => {
/** 官方 composer 编辑器根(上游 `ComposerContentEditable` 的 `data-composer-input` 锚点)。 */
const COMPOSER_INPUT = '[data-composer-card] [data-composer-input]'
+/**
+ * 会话就绪的 composer 编辑器根:官方在会话尚未入库时把 `data-phase` 钉在 `inert`
+ * (无会话的「选择工作区」占位态),此时插件按契约不接管粘贴
+ * (`packages/dsh-tauri-experimental/src/client/register/paste-collapse.ts` 要求列表快照的 `current` 在位)。
+ */
+const COMPOSER_READY = `${COMPOSER_INPUT}:not([data-phase="inert"])`
+
/**
* 折叠粘贴后的引用 chip 宿主:官方 `ReferenceChipNode.createDOM` 写的 `data-composer-chip`,
* 其值是本插件注册的引用源名(`packages/dsh-tauri-experimental/src/client/constants/index.ts` 的 `PASTE_CHIP_SOURCE`)。
@@ -151,6 +158,21 @@ async function syntheticPaste(frame: import('playwright').Frame, text: string):
}, { editorSelector: COMPOSER_INPUT, text })
}
+/**
+ * 点侧边栏「新建会话」并等到 composer 会话就绪。
+ *
+ * 新会话由宿主异步入库:编辑器 DOM 在会话在库之前就已挂载,停在官方 `data-phase="inert"`
+ * 的「选择工作区」占位态;此时粘贴既不会折叠也不会落文。就绪信号必须取会话输入面本身
+ * (`data-phase` 由官方 `input?.phase ?? "inert"` 出具),而不是编辑器是否出现。
+ */
+async function openNewSessionComposer(frame: import('playwright').Frame): Promise<void> {
+ await frame.locator(SIDEBAR_NEW_SESSION).first().click()
+ await expect.poll(
+ async () => await frame.locator(COMPOSER_READY).count(),
+ { timeout: 20_000, message: '新建会话后 composer 必须进入会话就绪态(脱离官方 data-phase="inert" 占位态),否则粘贴没有落点' },
+ ).toBe(1)
+}
+
describe('L2 折叠粘贴', () => {
let browser: Browser
@@ -165,11 +187,7 @@ describe('L2 折叠粘贴', () => {
it('验证超过 500 字的粘贴折叠成引用 chip,chip 文案带首行与字数', async () => {
const app = await newDshPage(browser, { ready: HERO_WORKSPACE_CHIP })
try {
- await app.frame.locator(SIDEBAR_NEW_SESSION).first().click()
- await expect.poll(
- async () => await app.frame.locator(COMPOSER_INPUT).count(),
- { timeout: 20_000, message: '新建会话后 composer 编辑器必须挂载,否则本用例没有粘贴落点' },
- ).toBe(1)
+ await openNewSessionComposer(app.frame)
const paste = await syntheticPaste(app.frame, LONG_PASTE)
expect(paste.editorFound, '夹具前置:composer 编辑器必须在位').toBe(true)
@@ -197,11 +215,7 @@ describe('L2 折叠粘贴', () => {
it('验证 500 字以内的粘贴不折叠,原样进入编辑器', async () => {
const app = await newDshPage(browser, { ready: HERO_WORKSPACE_CHIP })
try {
- await app.frame.locator(SIDEBAR_NEW_SESSION).first().click()
- await expect.poll(
- async () => await app.frame.locator(COMPOSER_INPUT).count(),
- { timeout: 20_000, message: '新建会话后 composer 编辑器必须挂载,否则本用例没有粘贴落点' },
- ).toBe(1)
+ await openNewSessionComposer(app.frame)
const paste = await syntheticPaste(app.frame, SHORT_PASTE)
expect(paste.editorFound, '夹具前置:composer 编辑器必须在位').toBe(true)