From 26be90d66fa3ac9fe26ffd8cb19443b72f4e4d80 Mon Sep 17 00:00:00 2001 From: unsc9 <438590997@qq.com> Date: Sat, 24 Oct 2026 20:50:07 +0800 Subject: [PATCH] =?UTF-8?q?test(e2e):=20composer=20=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E6=94=B9=E7=94=A8=E5=AE=BF=E4=B8=BB=E7=9A=84=20composer=20slot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 首屏占位符名字(Describe what you want to build)在会话有内容后就消失了, 拿它查 composer 会一直超时。改锚定 [data-slot=conversation.composer.bar]: 这是宿主自己的稳定属性,且天然把插件里同样 contenteditable 的 CodeMirror 排除在外,不用再靠 DOM 顺序猜。 --- tests/e2e/host.ts | 19 +++++++++++++++---- tests/e2e/mount.e2e.ts | 4 ++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/e2e/host.ts b/tests/e2e/host.ts index dd707fe3..c58fa443 100644 --- a/tests/e2e/host.ts +++ b/tests/e2e/host.ts @@ -201,16 +201,27 @@ export async function hostRpc( } /** - * The host composer's editable. Role+name, not `[contenteditable="true"]`: - * the plugin's own CodeMirror surface is also contenteditable (and stays in - * the DOM, merely hidden, in preview mode), so a bare attribute match is - * DOM-order dependent. + * The host composer's editable. Role+name: the placeholder label only exists + * on the empty composer, so this is for the first-message path — once the + * session has content the accessible name changes. * @param page - the lane's page. */ export function composerLocator(page: Page) { return page.getByRole('textbox', { name: /^(Describe what you want to build|描述你想要构建)/ }) } +/** + * The composer's editable once the session already has content — the + * placeholder name is gone by then. Anchored on the host's composer slot + * rather than a bare `[contenteditable]` match: the plugin's own CodeMirror + * surface is also contenteditable and stays in the DOM (merely hidden) in + * preview mode. + * @param page - the lane's page. + */ +export function composerEditable(page: Page) { + return page.locator('[data-slot="conversation.composer.bar"] [contenteditable="true"]').first() +} + /** * Send one message in the session the shell opened, so the conversation header * (and the native right Sidebar's corner control) exists: DSH renders the diff --git a/tests/e2e/mount.e2e.ts b/tests/e2e/mount.e2e.ts index 77fbf77c..ad07a189 100644 --- a/tests/e2e/mount.e2e.ts +++ b/tests/e2e/mount.e2e.ts @@ -31,7 +31,7 @@ import { mkdirSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import { test, expect, type APIRequestContext } from '@playwright/test' -import { PAGE_URL, composerLocator, createHostApi, dismissOnboarding, gotoPage, hostRpc, sendFirstMessage, sidebarApi } from './host' +import { PAGE_URL, composerEditable, createHostApi, dismissOnboarding, gotoPage, hostRpc, sendFirstMessage, sidebarApi } from './host' /** Workspace the sidebar renders against (created by the lane's seeding). */ const WORKSPACE_PATH = process.env.DSH_E2E_WORKSPACE ?? join(tmpdir(), 'dsh-e2e-workspace') @@ -605,7 +605,7 @@ test('plugin mounts into the DSH shell and survives a built-in tab sweep', async .first() await expect(chip, 'the selection must land in the composer as a reference chip') .toBeVisible({ timeout: 10_000 }) - const composerText = await composerLocator(page).innerText() + const composerText = await composerEditable(page).innerText() expect(composerText, 'the draft must not carry the quoted body the chip replaced') .not.toContain('```') await assertNoCrash()