test(e2e): composer 定位改用宿主的 composer slot
首屏占位符名字(Describe what you want to build)在会话有内容后就消失了, 拿它查 composer 会一直超时。改锚定 [data-slot=conversation.composer.bar]: 这是宿主自己的稳定属性,且天然把插件里同样 contenteditable 的 CodeMirror 排除在外,不用再靠 DOM 顺序猜。
This commit is contained in:
1 parent
9067e2cac4
commit
26be90d66f
2 files changed
+17
-6
No files matched your search
+15
-4
@@ -201,16 +201,27 @@ export async function hostRpc<T = unknown>(
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user