workspace.spec.ts 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069
  1. import { expect, test } from '@playwright/test'
  2. const WIDE_DOCX_BASE64 = 'UEsDBAoAAAAIAKwmFF15bjPX6AAAAK0BAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbH1QyU7DMBD9FWuuKHHggBCK0wPLETiUDxjZk8SqN3nc0v49Tlt6QIXjzFv1+tXeO7GjzDYGBbdtB4KCjsaGScHn+rV5AMEFg0EXAyk4EMNq6NeHRCyqNrCCuZT0KCXrmTxyGxOFiowxeyz1zJNMqDc4kbzrunupYygUSlMWDxj6Zxpx64p42df3qUcmxyCeTsQlSwGm5KzGUnG5C+ZXSnNOaKvyyOHZJr6pBJBXExbk74Cz7r0Ok60h8YG5vKGvLPkVs5Em6q2vyvZ/mys94zhaTRf94pZy1MRcF/euvSAebfjpL49zD99QSwMECgAAAAAArCYUXQAAAAAAAAAAAAAAAAYAAABfcmVscy9QSwMECgAAAAgArCYUXZv9N+qtAAAAKQEAAAsAAABfcmVscy8ucmVsc43POw7CMAwG4KtE3mlaBoRQ0y4IqSsqB7ASN61oHkrCo7cnAwNFDIy2f3+W6/ZpZnanECdnBVRFCYysdGqyWsClP232wGJCq3B2lgQsFKFt6jPNmPJKHCcfWTZsFDCm5A+cRzmSwVg4TzZPBhcMplwGzT3KK2ri27Lc8fBpwNpknRIQOlUB6xdP/9huGCZJRydvhmz6ceIrkWUMmpKAhwuKq3e7yCzwpuarF5sXUEsDBAoAAAAAAKwmFF0AAAAAAAAAAAAAAAAFAAAAd29yZC9QSwMECgAAAAgArCYUXalT+9hjAQAABwMAABEAAAB3b3JkL2RvY3VtZW50LnhtbKVSW0/CMBT+K03fpXMBJYRBFAaaYDSKwdeydluTrW3awsBfb7uVDYwmJr6cc75z+c6lHU8PZQH2VGkmeASvewEElCeCMJ5F8H29uBpCoA3mBBeC0wgeqYbTybgaEZHsSsoNsARcj6oI5sbIEUI6yWmJdU9Iym0sFarExkKVoUooIpVIqNaWvyxQGAQ3qMSMQ0e5FeTotHRCOWEmG0YomD/PPoBUdM9oNUbO7aSqZZ1stoVXL8obG1C5oa6DYWB3sq6jtOOTA4bIZ6zwUexMG0rZgRIXRJdES8WIMzOrZ6JoaAd9y4p+daOLStNQJY30xMnmrOT7fKhLPD/GKl6swfrufhWDeL6MfzgF6vr8u9vr4/Lhb+1QsyNqH0LTxHjC7O3Tv0QY9uveubUHw76/n8yesHITCRnB27DOUCzLTYu2whhRtrCgaRfLKSZURbAGqRCmBdnOeNBseBoJnf4Z6v7w5AtQSwECFAAKAAAACACsJhRdeW4z1+gAAACtAQAAEwAAAAAAAAAAAAAAAAAAAAAAW0NvbnRlbnRfVHlwZXNdLnhtbFBLAQIUAAoAAAAAAKwmFF0AAAAAAAAAAAAAAAAGAAAAAAAAAAAAEAAAABkBAABfcmVscy9QSwECFAAKAAAACACsJhRdm/036q0AAAApAQAACwAAAAAAAAAAAAAAAAA9AQAAX3JlbHMvLnJlbHNQSwECFAAKAAAAAACsJhRdAAAAAAAAAAAAAAAABQAAAAAAAAAAABAAAAATAgAAd29yZC9QSwECFAAKAAAACACsJhRdqVP72GMBAAAHAwAAEQAAAAAAAAAAAAAAAAA2AgAAd29yZC9kb2N1bWVudC54bWxQSwUGAAAAAAUABQAgAQAAyAMAAAAA'
  3. const E2E_PASSWORD = 'e2e-password'
  4. test.beforeAll(async ({ request }) => {
  5. const signIn = async (password: string) => {
  6. const initial = await request.get('/api/app/bootstrap')
  7. const initialBody = await initial.json() as { csrfToken: string }
  8. return request.post('/api/app/login', {
  9. headers: { Origin: 'http://127.0.0.1:18801', 'X-CSRF-Token': initialBody.csrfToken },
  10. data: { username: 'admin', password },
  11. })
  12. }
  13. let login = await signIn(E2E_PASSWORD)
  14. if (!login.ok()) login = await signIn('admin')
  15. expect(login.ok()).toBe(true)
  16. const loginBody = await login.json() as { csrfToken: string; user: { mustChangePassword?: boolean } }
  17. if (loginBody.user.mustChangePassword) {
  18. const changed = await request.put('/api/app/account/credentials', {
  19. headers: { Origin: 'http://127.0.0.1:18801', 'X-CSRF-Token': loginBody.csrfToken },
  20. data: { currentPassword: 'admin', newPassword: E2E_PASSWORD, username: 'admin' },
  21. })
  22. expect(changed.ok()).toBe(true)
  23. }
  24. })
  25. test.beforeEach(async ({ page }) => {
  26. await page.goto('/chat')
  27. if (await page.getByRole('heading', { name: '登录夭夭' }).isVisible()) {
  28. await page.getByLabel('账号').fill('admin')
  29. await page.getByLabel('密码').fill(E2E_PASSWORD)
  30. await page.getByRole('button', { name: '登录' }).click()
  31. }
  32. await expect(page.getByRole('navigation')).toBeVisible()
  33. })
  34. test('separates writable Web chats from read-only Hermes history', async ({ page }) => {
  35. const sidebar = page.locator('.desktop-sidebar')
  36. await expect(page.getByRole('button', { name: '新建聊天', exact: true })).toBeVisible()
  37. await expect(sidebar.getByText('Hermes 外部历史', { exact: true })).toHaveCount(0)
  38. await sidebar.getByRole('button', { name: '历史记录', exact: true }).click()
  39. await expect(page).toHaveURL(/\/history/)
  40. await expect(sidebar.getByText('Hermes 外部历史', { exact: true })).toBeVisible()
  41. await expect(sidebar.getByText('夭夭 Web 验收会话', { exact: true })).toHaveCount(0)
  42. await sidebar.getByText('Hermes 外部历史', { exact: true }).click()
  43. await expect(page).toHaveURL(/\/history\/session-history-only/)
  44. await expect(page.locator('.composer-shell')).toHaveCount(0)
  45. await sidebar.getByRole('button', { name: '聊天', exact: true }).click()
  46. await expect(page).toHaveURL(/\/chat/)
  47. await expect(page.getByRole('button', { name: '新建聊天', exact: true })).toBeVisible()
  48. })
  49. test('explains optional upstream credentials without blocking a ready connection', async ({ page }, testInfo) => {
  50. await page.getByRole('button', { name: /^(打开设置中心|设置与模式)$/ }).first().click()
  51. if (await page.getByRole('menuitem', { name: '进入设置', exact: true }).isVisible()) await page.getByRole('menuitem', { name: '进入设置', exact: true }).click()
  52. const dialog = page.getByRole('dialog', { name: '设置中心' })
  53. await dialog.getByRole('button', { name: 'Hermes 连接', exact: true }).click()
  54. await expect(dialog.locator('[aria-label="Hermes 连接状态"]')).toBeVisible()
  55. await expect(dialog.getByText('9119 连接正常', { exact: true })).toBeVisible()
  56. await expect(dialog.getByRole('heading', { name: '服务账号(按需配置)' })).toBeVisible()
  57. await expect(dialog.getByText(/无需配置用户名和密码/)).toBeVisible()
  58. await expect(dialog.locator('input[name="upstream-username"]')).toHaveValue('')
  59. await expect(dialog.locator('input[name="upstream-password"]')).toHaveValue('')
  60. await page.screenshot({ path: testInfo.outputPath('loopback-authorization.png') })
  61. })
  62. test('uses the yaoyao-webui grouped model picker without a mobile full-screen sheet', async ({ page }) => {
  63. await page.goto('/chat/session-demo')
  64. await page.locator('.composer-tool--model').click()
  65. const dialog = page.getByRole('dialog', { name: '选择模型' })
  66. await expect(dialog).toBeVisible()
  67. await expect(dialog.getByPlaceholder('搜索模型名称或 ID')).toBeFocused()
  68. await expect(dialog.locator('.model-dialog__group-header')).toContainText('OpenAI')
  69. await expect(dialog.locator('.model-dialog__item--active')).toContainText('gpt-5.6')
  70. const desktopBox = await dialog.boundingBox()
  71. expect(desktopBox?.width).toBeGreaterThanOrEqual(450)
  72. expect(desktopBox?.width).toBeLessThanOrEqual(480)
  73. await dialog.getByPlaceholder('搜索模型名称或 ID').fill('gpt-5.5')
  74. await expect(dialog.locator('.model-dialog__item')).toHaveCount(1)
  75. await page.keyboard.press('Escape')
  76. await expect(dialog).toBeHidden()
  77. await page.setViewportSize({ width: 390, height: 844 })
  78. await page.locator('.composer-tool--model').click()
  79. const mobileBox = await dialog.boundingBox()
  80. expect(mobileBox?.x).toBeGreaterThanOrEqual(12)
  81. expect(mobileBox?.width).toBeLessThanOrEqual(366)
  82. expect(mobileBox?.height).toBeLessThan(820)
  83. })
  84. test('navigates every 9119 workspace without blank transitions', async ({ page }) => {
  85. const consoleErrors: string[] = []
  86. page.on('console', message => { if (message.type() === 'error') consoleErrors.push(message.text()) })
  87. await expect(page.getByRole('option').first()).toContainText('夭夭 Web 验收会话')
  88. await expect(page.getByRole('option').first()).toContainText('夭夭')
  89. await expect(page.locator('.desktop-sidebar').getByText('已置顶 1', { exact: true })).toBeVisible()
  90. await page.getByRole('button', { name: '团队' }).click()
  91. await expect(page.getByRole('heading', { name: '设计验收' })).toBeVisible()
  92. await expect(page.getByRole('button', { name: '对话', exact: true })).toBeVisible()
  93. await expect(page.getByRole('button', { name: '团队', exact: true })).toHaveCount(0)
  94. await expect(page.getByRole('button', { name: '文件库', exact: true })).toHaveCount(0)
  95. await expect(page.getByRole('button', { name: '产物', exact: true })).toHaveCount(0)
  96. await expect(page.getByRole('button', { name: '新建团队' })).toBeVisible()
  97. await page.mouse.move(1200, 20)
  98. await expect(page.getByRole('button', { name: '新建团队' })).toHaveCSS('background-color', 'rgba(0, 0, 0, 0)')
  99. await expect(page.getByRole('button', { name: '新建团队' })).toHaveCSS('font-weight', '650')
  100. await expect(page.getByRole('button', { name: '管理团队', exact: true })).toBeVisible()
  101. await expect(page.getByRole('button', { name: '发送消息' })).toBeVisible()
  102. await page.goto('/files')
  103. await expect(page.getByRole('heading', { name: '文件库', exact: true }).last()).toBeVisible()
  104. const fileSidebar = page.locator('.desktop-sidebar')
  105. await expect(fileSidebar.getByRole('button', { name: '新建聊天' })).toBeVisible()
  106. await expect(fileSidebar.getByRole('button', { name: '搜索', exact: true })).toHaveCount(0)
  107. const compactControlHeights = await fileSidebar.locator('.sidebar-search-trigger, .sidebar-primary-action button, .sidebar-feature-nav button').evaluateAll(elements => (
  108. elements.map(element => element.getBoundingClientRect().height)
  109. ))
  110. expect(compactControlHeights.length).toBeGreaterThanOrEqual(3)
  111. expect(Math.max(...compactControlHeights)).toBeLessThanOrEqual(36)
  112. await expect(page.getByText('demo-report.pdf')).toBeVisible()
  113. const firstFileCard = page.locator('.library-grid article').first()
  114. const cardGeometry = await firstFileCard.evaluate(element => {
  115. const card = element.getBoundingClientRect()
  116. const preview = element.querySelector('.library-thumb')?.getBoundingClientRect()
  117. return { width: card.width, previewHeight: preview?.height || 0 }
  118. })
  119. expect(cardGeometry.width).toBeGreaterThanOrEqual(220)
  120. expect(cardGeometry.previewHeight).toBe(154)
  121. await page.getByText('demo-report.pdf').click()
  122. await expect(page.getByRole('dialog', { name: /预览 demo-report.pdf/ })).toBeVisible()
  123. await expect(page.locator('.preview-meta')).toHaveCount(0)
  124. const previewDialog = page.getByRole('dialog', { name: /预览 demo-report.pdf/ })
  125. await expect(previewDialog.getByRole('link', { name: '下载' })).toBeVisible()
  126. await expect(previewDialog.getByRole('button', { name: '加入输入框' })).toBeVisible()
  127. await expect(previewDialog.locator('.preview-close')).toBeVisible()
  128. const modalHeight = await page.locator('.preview-modal').evaluate(element => element.getBoundingClientRect().height)
  129. expect(modalHeight).toBeGreaterThan(600)
  130. await previewDialog.locator('.preview-close').click()
  131. await fileSidebar.getByRole('button', { name: '新建聊天' }).click()
  132. await expect(page).toHaveURL(/\/chat\/draft-[^?]+\?profile=yaoyao/)
  133. await page.goto('/artifacts')
  134. await expect(page).toHaveURL(/\/chat$/)
  135. await expect(page.getByRole('button', { name: '产物', exact: true })).toHaveCount(0)
  136. expect(consoleErrors).toEqual([])
  137. })
  138. test('uses the active session or group title in the browser title', async ({ page }) => {
  139. await page.goto('/chat/session-demo?profile=yaoyao')
  140. await expect(page).toHaveTitle('夭夭 Web 验收会话 · 夭夭')
  141. await page.goto('/groups/group-demo')
  142. await expect(page).toHaveTitle('设计与工程协作 · 夭夭')
  143. })
  144. test('uses split search for topics, teams, and archived content', async ({ page }) => {
  145. await page.getByRole('button', { name: '团队' }).click()
  146. await expect(page.getByRole('heading', { name: '设计验收' })).toBeVisible()
  147. await page.locator('.desktop-sidebar').getByRole('button', { name: '搜索', exact: true }).click()
  148. const searchDialog = page.getByRole('dialog', { name: '搜索话题、团队或归档' })
  149. await expect(searchDialog).toBeVisible()
  150. await expect(searchDialog.getByRole('navigation', { name: '搜索范围' })).toContainText('设计与工程协作')
  151. await searchDialog.getByRole('searchbox', { name: '搜索全部' }).fill('发布检查')
  152. const topicResult = searchDialog.getByRole('option', { name: /发布检查/ })
  153. await expect(topicResult).toBeVisible()
  154. await topicResult.click()
  155. await expect(page).toHaveURL(/\/groups\/22222222-2222-4222-8222-222222222222\/88888888-8888-4888-8888-888888888888$/)
  156. await expect(searchDialog).toBeHidden()
  157. })
  158. test('shows member mascot clusters in the list and during creation', async ({ page }) => {
  159. await page.getByRole('button', { name: '团队' }).click()
  160. const topicRow = page.locator('[data-sidebar-id="topic:22222222-2222-4222-8222-222222222222:77777777-7777-4777-8777-777777777777"]')
  161. const roomAvatar = topicRow.getByRole('img', { name: '设计验收团队头像' })
  162. await expect(roomAvatar).toBeVisible()
  163. await expect(roomAvatar.locator('.team-avatar__member')).toHaveCount(3)
  164. const releaseTopicAvatar = page.locator('[data-sidebar-id="topic:22222222-2222-4222-8222-222222222222:88888888-8888-4888-8888-888888888888"]').first().locator('.team-avatar__member')
  165. await expect(releaseTopicAvatar).toHaveCount(3)
  166. await page.getByRole('button', { name: '新建团队' }).click()
  167. const dialog = page.getByRole('dialog', { name: '新建团队' })
  168. await expect(dialog.getByRole('region', { name: '团队预设' })).toBeVisible()
  169. await expect(dialog.getByRole('button', { name: /信息收集团队/ })).toBeDisabled()
  170. await expect(dialog.getByRole('button', { name: /信息收集团队/ })).toContainText('还缺 2 人')
  171. await expect(dialog.getByText('由成员的动态角色自动组成')).toBeVisible()
  172. await expect(dialog.getByRole('button', { name: '成员组合' })).toBeVisible()
  173. await expect(dialog.locator('.team-avatar__member')).toHaveCount(3)
  174. await expect(dialog.getByRole('button', { name: '上传图片' })).toBeVisible()
  175. await dialog.locator('input[type="file"]').setInputFiles('public/brand/AppIcon-1024.png')
  176. await expect(dialog.getByText('使用上传的图片')).toBeVisible()
  177. await expect(dialog.getByRole('img', { name: '团队团队头像' }).locator('img')).toBeVisible()
  178. })
  179. test('updates an existing team avatar from the Web manager', async ({ page }) => {
  180. await page.getByRole('button', { name: '团队' }).click()
  181. await page.getByRole('button', { name: '管理团队', exact: true }).click()
  182. const manager = page.locator('.group-manager')
  183. const preview = manager.getByRole('img', { name: '设计与工程协作团队头像' })
  184. await expect(preview.locator('.team-avatar__member')).toHaveCount(3)
  185. const uploadRequest = page.waitForRequest(request => request.method() === 'PATCH' && request.url().endsWith('/rooms/22222222-2222-4222-8222-222222222222'))
  186. await manager.locator('input[type="file"]').setInputFiles('public/brand/AppIcon-1024.png')
  187. expect((await uploadRequest).postDataJSON().avatar).toMatch(/^data:image\/png;base64,/)
  188. await expect(manager.getByText('使用上传的图片')).toBeVisible()
  189. await expect(preview.locator('img')).toBeVisible()
  190. const dynamicRequest = page.waitForRequest(request => request.method() === 'PATCH' && request.url().endsWith('/rooms/22222222-2222-4222-8222-222222222222'))
  191. await manager.getByRole('button', { name: '成员组合' }).click()
  192. expect((await dynamicRequest).postDataJSON()).toMatchObject({ avatar: '' })
  193. await expect(manager.getByText('由成员的动态角色自动组成')).toBeVisible()
  194. await expect(preview.locator('.team-avatar__member')).toHaveCount(3)
  195. })
  196. test('selects one protocol v5 host independently from no-mention replies', async ({ page }) => {
  197. await page.getByRole('button', { name: '团队' }).click()
  198. await expect(page.locator('.group-host-chip')).toHaveText('管理员 夭夭')
  199. await page.getByRole('button', { name: '新建团队' }).click()
  200. const createDialog = page.getByRole('dialog', { name: '新建团队' })
  201. await createDialog.getByRole('button', { name: /yaoer/ }).click()
  202. await createDialog.getByLabel('管理员').selectOption({ label: '瑶儿' })
  203. await expect(createDialog.getByLabel('所有成员无需 @ 也回复')).toBeChecked()
  204. await createDialog.getByRole('button', { name: '关闭' }).click()
  205. await page.getByRole('button', { name: '管理团队', exact: true }).click()
  206. const manager = page.locator('.group-manager')
  207. await expect(manager.getByLabel('管理员')).toHaveValue('33333333-3333-4333-8333-333333333333')
  208. const promoteRequest = page.waitForRequest(request => request.method() === 'PATCH' && request.url().endsWith('/agents/34343434-3434-4434-8434-343434343434'))
  209. await manager.getByLabel('管理员').selectOption({ label: '瑶儿' })
  210. expect((await promoteRequest).postDataJSON()).toMatchObject({ isHost: true })
  211. await expect(manager.locator('article').filter({ hasText: '瑶儿' }).getByText('管理员', { exact: true })).toBeVisible()
  212. await expect(page.locator('.group-host-chip')).toHaveText('管理员 瑶儿')
  213. const restoreRequest = page.waitForRequest(request => request.method() === 'PATCH' && request.url().endsWith('/agents/33333333-3333-4333-8333-333333333333'))
  214. await manager.getByLabel('管理员').selectOption({ label: '夭夭' })
  215. expect((await restoreRequest).postDataJSON()).toMatchObject({ isHost: true })
  216. await expect(page.locator('.group-host-chip')).toHaveText('管理员 夭夭')
  217. })
  218. test('edits every protocol v5 Agent setting with one inspector close control', async ({ page }) => {
  219. await page.getByRole('button', { name: '团队' }).click()
  220. await expect(page.getByRole('heading', { name: '设计验收' })).toBeVisible()
  221. await page.getByRole('button', { name: '管理团队', exact: true }).click()
  222. await expect(page.getByRole('button', { name: '关闭团队管理' })).toHaveCount(1)
  223. await expect(page.getByRole('button', { name: '关闭预览' })).toHaveCount(0)
  224. await expect(page.getByLabel('最多回复轮数')).toHaveValue('-1')
  225. await page.getByRole('button', { name: '设置瑶儿' }).click()
  226. const editor = page.getByRole('dialog', { name: '瑶儿 Agent 设置' })
  227. await expect(page.locator('.group-manager .agent-editor')).toHaveCount(0)
  228. await expect(editor.getByLabel('群内名称')).toHaveValue('瑶儿')
  229. await expect(editor.getByLabel('职责说明')).toHaveValue('评审 Agent')
  230. await expect(editor.getByLabel('模型')).toHaveValue(JSON.stringify(['openai', 'gpt-5.6']))
  231. await expect(editor.getByLabel('推理强度')).toHaveValue('medium')
  232. await expect(editor.getByLabel('快速模式')).toHaveValue('false')
  233. await editor.getByLabel('群内名称').fill('所有人')
  234. const rejectedResponse = page.waitForResponse(response => response.request().method() === 'PATCH' && /\/api\/app\/groups\/rooms\/[^/]+\/agents\/[^/]+$/.test(new URL(response.url()).pathname))
  235. await editor.getByRole('button', { name: '保存 Agent 设置' }).click()
  236. expect((await rejectedResponse).status()).toBe(409)
  237. await expect(editor.getByRole('alert')).toContainText('成员名称不能使用“所有人”')
  238. await editor.getByRole('button', { name: '关闭 Agent 设置' }).click()
  239. await page.getByRole('button', { name: '设置瑶儿' }).click()
  240. await expect(editor.getByLabel('群内名称')).toHaveValue('所有人')
  241. await editor.getByLabel('群内名称').fill('瑶儿')
  242. await editor.getByLabel('模型').selectOption(JSON.stringify(['openai', 'gpt-5.5']))
  243. await editor.getByLabel('推理强度').selectOption('xhigh')
  244. await editor.getByLabel('快速模式').selectOption('true')
  245. await editor.getByLabel('无需 @ 也回复').check()
  246. const updateRequest = page.waitForRequest(request => request.method() === 'PATCH' && /\/api\/app\/groups\/rooms\/[^/]+\/agents\/[^/]+$/.test(new URL(request.url()).pathname))
  247. await editor.getByRole('button', { name: '保存 Agent 设置' }).click()
  248. expect((await updateRequest).postDataJSON()).toMatchObject({
  249. model: 'gpt-5.5', provider: 'openai', reasoningEffort: 'xhigh', fastMode: true, replyWithoutMention: true,
  250. })
  251. await expect(editor.getByLabel('模型')).toHaveValue(JSON.stringify(['openai', 'gpt-5.5']))
  252. await editor.getByLabel('模型').selectOption(JSON.stringify(['openai', 'gpt-5.6']))
  253. await editor.getByLabel('推理强度').selectOption('medium')
  254. await editor.getByLabel('快速模式').selectOption('false')
  255. await editor.getByLabel('无需 @ 也回复').uncheck()
  256. const restoreResponse = page.waitForResponse(response => response.request().method() === 'PATCH' && /\/api\/app\/groups\/rooms\/[^/]+\/agents\/[^/]+$/.test(new URL(response.url()).pathname))
  257. await editor.getByRole('button', { name: '保存 Agent 设置' }).click()
  258. expect((await restoreResponse).status()).toBe(200)
  259. })
  260. test('pins the named Agent typing status above the group composer', async ({ page }) => {
  261. await page.getByRole('button', { name: '团队' }).click()
  262. const composer = page.locator('.composer-area')
  263. await page.getByRole('textbox', { name: '发消息给团队,输入 @ 提及 Agent' }).fill('@夭夭 检查输入状态')
  264. await page.getByRole('button', { name: '发送消息' }).click()
  265. const typing = composer.getByRole('status', { name: 'Agent 输入状态' })
  266. await page.waitForTimeout(250)
  267. await expect(typing).toHaveCount(0)
  268. await expect(typing).toHaveText('夭夭正在输入…')
  269. await expect(page.locator('.message-stack .thinking-indicator')).toHaveCount(0)
  270. const typingBox = await typing.boundingBox()
  271. const shellBox = await composer.locator('.composer-shell').boundingBox()
  272. expect(typingBox?.y).toBeLessThan(shellBox?.y ?? 0)
  273. await expect(typing).toHaveCount(0, { timeout: 4_000 })
  274. })
  275. test('reconnects the group event stream after an unexpected close', async ({ page }) => {
  276. await page.getByRole('button', { name: '团队' }).click()
  277. await expect(page.getByText('已同步', { exact: true })).toBeVisible()
  278. const before = await (await page.request.get('http://127.0.0.1:19119/__test/group-connections')).json() as { count: number }
  279. await page.request.post('http://127.0.0.1:19119/__test/groups/disconnect')
  280. await expect.poll(async () => {
  281. const value = await (await page.request.get('http://127.0.0.1:19119/__test/group-connections')).json() as { count: number }
  282. return value.count
  283. }, { timeout: 5_000 }).toBeGreaterThan(before.count)
  284. await expect(page.getByText('已同步', { exact: true })).toBeVisible()
  285. })
  286. test('recovers the group page after its initial upstream connection fails', async ({ page }) => {
  287. await page.request.post('http://127.0.0.1:19119/__test/groups/availability', { data: { available: false } })
  288. await page.getByRole('button', { name: '团队' }).click()
  289. await expect(page.getByRole('heading', { name: '团队服务暂不可用' })).toBeVisible()
  290. await page.request.post('http://127.0.0.1:19119/__test/groups/availability', { data: { available: true } })
  291. await expect(page.getByRole('heading', { name: '设计验收' })).toBeVisible({ timeout: 5_000 })
  292. })
  293. test('previews an octet-stream Markdown file from the file library', async ({ page }) => {
  294. await page.route('**/api/app/files**', async route => {
  295. const url = new URL(route.request().url())
  296. if (url.pathname === '/api/app/files') {
  297. await route.fulfill({
  298. status: 200,
  299. contentType: 'application/json',
  300. body: JSON.stringify({
  301. profile: 'yaoyao',
  302. items: [{
  303. id: 'markdown-file',
  304. path: '/tmp/版本说明.md',
  305. name: '版本说明.md',
  306. extension: '.md',
  307. mimeType: 'application/octet-stream',
  308. size: 48,
  309. modifiedAt: Date.now() / 1000,
  310. exists: true,
  311. origins: [{ profile: 'yaoyao', sessionId: 'session-demo', sessionTitle: '夭夭 Web 验收会话' }],
  312. }, {
  313. id: 'empty-markdown-file',
  314. path: '/tmp/空白说明.md',
  315. name: '空白说明.md',
  316. extension: 'md',
  317. mimeType: 'application/octet-stream',
  318. size: 0,
  319. modifiedAt: Date.now() / 1000,
  320. exists: true,
  321. origins: [{ profile: 'yaoyao', sessionId: 'session-demo', sessionTitle: '夭夭 Web 验收会话' }],
  322. }],
  323. nextCursor: null,
  324. total: 2,
  325. }),
  326. })
  327. return
  328. }
  329. if (url.pathname === '/api/app/files/markdown-file/preview') {
  330. await route.fulfill({
  331. status: 200,
  332. contentType: 'application/octet-stream',
  333. body: '# 版本说明\n\n- Markdown 预览已恢复',
  334. })
  335. return
  336. }
  337. if (url.pathname === '/api/app/files/empty-markdown-file/preview') {
  338. await route.fulfill({ status: 200, contentType: 'application/octet-stream', body: '' })
  339. return
  340. }
  341. await route.continue()
  342. })
  343. await page.goto('/files')
  344. await page.getByText('版本说明.md', { exact: true }).click()
  345. const dialog = page.getByRole('dialog', { name: '预览 版本说明.md' })
  346. await expect(dialog.locator('.preview-text h1')).toHaveText('版本说明')
  347. await expect(dialog.getByText('Markdown 预览已恢复', { exact: true })).toBeVisible()
  348. await dialog.locator('.preview-close').click()
  349. await page.getByText('空白说明.md', { exact: true }).click()
  350. const emptyDialog = page.getByRole('dialog', { name: '预览 空白说明.md' })
  351. await expect(emptyDialog.locator('.preview-text')).toBeVisible()
  352. await expect(emptyDialog.locator('.preview-unavailable')).toHaveCount(0)
  353. })
  354. test('keeps DOCX body at 36px inset with zero canvas margin', async ({ page }) => {
  355. await page.setViewportSize({ width: 620, height: 760 })
  356. await page.route('**/api/app/files**', async route => {
  357. const url = new URL(route.request().url())
  358. if (url.pathname === '/api/app/files') {
  359. await route.fulfill({
  360. status: 200,
  361. contentType: 'application/json',
  362. body: JSON.stringify({
  363. profile: 'yaoyao',
  364. items: [{
  365. id: 'wide-docx-file',
  366. path: '/tmp/宽版文档.docx',
  367. name: '宽版文档.docx',
  368. extension: 'docx',
  369. mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  370. size: 1024,
  371. modifiedAt: Date.now() / 1000,
  372. exists: true,
  373. origins: [{ profile: 'yaoyao', sessionId: 'session-demo', sessionTitle: '夭夭 Web 验收会话' }],
  374. }],
  375. nextCursor: null,
  376. total: 1,
  377. }),
  378. })
  379. return
  380. }
  381. if (url.pathname === '/api/app/files/wide-docx-file/preview') {
  382. await route.fulfill({
  383. status: 200,
  384. contentType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  385. body: Buffer.from(WIDE_DOCX_BASE64, 'base64'),
  386. })
  387. return
  388. }
  389. await route.continue()
  390. })
  391. await page.goto('/files')
  392. await page.getByText('宽版文档.docx', { exact: true }).click()
  393. const dialog = page.getByRole('dialog', { name: '预览 宽版文档.docx' })
  394. const office = dialog.locator('.preview-office')
  395. await expect(office.locator('section.docx')).toBeVisible()
  396. const geometry = await office.evaluate(element => {
  397. const wrapper = element.querySelector<HTMLElement>('.docx-wrapper')!
  398. const pageElement = element.querySelector<HTMLElement>('section.docx')!
  399. const article = pageElement.querySelector<HTMLElement>('article')!
  400. const table = article.querySelector<HTMLElement>('table')!
  401. const officeRect = element.getBoundingClientRect()
  402. const pageRect = pageElement.getBoundingClientRect()
  403. const officeStyle = getComputedStyle(element)
  404. const wrapperStyle = getComputedStyle(wrapper)
  405. const articleStyle = getComputedStyle(article)
  406. return {
  407. officeLeft: officeRect.left,
  408. pageLeft: pageRect.left,
  409. pageWidth: pageRect.width,
  410. clientWidth: element.clientWidth,
  411. scrollWidth: element.scrollWidth,
  412. wrapperWidth: wrapper.getBoundingClientRect().width,
  413. articlePaddingTop: Number.parseFloat(articleStyle.paddingTop),
  414. articlePaddingLeft: Number.parseFloat(articleStyle.paddingLeft),
  415. articlePaddingRight: Number.parseFloat(articleStyle.paddingRight),
  416. tableLeft: table.getBoundingClientRect().left,
  417. tableRight: table.getBoundingClientRect().right,
  418. officeBackground: officeStyle.backgroundColor,
  419. wrapperBackground: wrapperStyle.backgroundColor,
  420. wrapperPaddingTop: Number.parseFloat(wrapperStyle.paddingTop),
  421. wrapperPaddingLeft: Number.parseFloat(wrapperStyle.paddingLeft),
  422. wrapperPaddingRight: Number.parseFloat(wrapperStyle.paddingRight),
  423. }
  424. })
  425. expect(geometry.pageWidth).toBeLessThanOrEqual(geometry.clientWidth)
  426. expect(geometry.pageLeft).toBeGreaterThanOrEqual(geometry.officeLeft)
  427. expect(geometry.scrollWidth).toBeLessThanOrEqual(geometry.clientWidth + 1)
  428. expect(Math.abs(geometry.wrapperWidth - geometry.clientWidth)).toBeLessThan(1)
  429. expect(geometry.articlePaddingTop).toBe(36)
  430. expect(geometry.articlePaddingLeft).toBe(36)
  431. expect(geometry.articlePaddingRight).toBe(36)
  432. expect(geometry.tableLeft).toBeGreaterThanOrEqual(geometry.pageLeft - 1)
  433. expect(geometry.tableRight).toBeLessThanOrEqual(geometry.pageLeft + geometry.pageWidth + 1)
  434. expect(geometry.officeBackground).toBe('rgb(255, 255, 255)')
  435. expect(geometry.wrapperBackground).toBe('rgb(255, 255, 255)')
  436. expect(geometry.wrapperPaddingTop).toBe(0)
  437. expect(geometry.wrapperPaddingLeft).toBe(0)
  438. expect(geometry.wrapperPaddingRight).toBe(0)
  439. await page.setViewportSize({ width: 930, height: 760 })
  440. const centered = await office.evaluate(element => {
  441. const pageElement = element.querySelector<HTMLElement>('section.docx')!
  442. const officeRect = element.getBoundingClientRect()
  443. const pageRect = pageElement.getBoundingClientRect()
  444. return {
  445. pageWidth: pageRect.width,
  446. clientWidth: element.clientWidth,
  447. leftGap: pageRect.left - officeRect.left,
  448. rightGap: officeRect.right - pageRect.right,
  449. }
  450. })
  451. expect(centered.pageWidth).toBeLessThan(centered.clientWidth)
  452. expect(centered.leftGap).toBeGreaterThanOrEqual(18)
  453. expect(centered.rightGap).toBeGreaterThanOrEqual(18)
  454. expect(Math.abs(centered.leftGap - centered.rightGap)).toBeLessThanOrEqual(12)
  455. })
  456. test('keeps pins first and loads the next session page at the list bottom', async ({ page }) => {
  457. const sidebar = page.locator('.desktop-sidebar')
  458. const items = sidebar.locator('.sidebar-list [role="option"]')
  459. await expect(items).toHaveCount(100)
  460. await expect(items.first()).toContainText('夭夭 Web 验收会话')
  461. await expect(sidebar.getByRole('button', { name: '继续加载会话' })).toBeVisible()
  462. const list = sidebar.locator('.sidebar-list')
  463. await list.evaluate(element => {
  464. element.scrollTop = element.scrollHeight
  465. element.dispatchEvent(new Event('scroll'))
  466. })
  467. await expect(items).toHaveCount(103)
  468. await expect(sidebar.getByRole('button', { name: '继续加载会话' })).toHaveCount(0)
  469. })
  470. test('switches the composer model to the selected historical session model', async ({ page }) => {
  471. await page.goto('/chat/session-demo?profile=yaoyao')
  472. await expect(page.locator('.composer-tool--model')).toContainText('gpt-5.6')
  473. await page.getByRole('option', { name: /第二个会话/ }).click()
  474. await expect(page.locator('.composer-tool--model')).toContainText('gpt-5.5')
  475. })
  476. test('restores a routed conversation even when unread-count refresh fails', async ({ page }) => {
  477. await page.route('**/api/app/sessions/unread*', async route => {
  478. await route.fulfill({ status: 503, contentType: 'application/json', body: JSON.stringify({ error: 'unread unavailable' }) })
  479. })
  480. await page.goto('/chat/session-demo')
  481. await expect(page.getByText('已整理完成。下面是', { exact: false })).toBeVisible()
  482. await page.reload()
  483. await expect(page.getByText('已整理完成。下面是', { exact: false })).toBeVisible()
  484. })
  485. test('opens a conversation even when marking it read is unsupported', async ({ page }) => {
  486. const pageErrors: string[] = []
  487. page.on('pageerror', error => pageErrors.push(error.message))
  488. await page.route('**/api/app/sessions/unread/*', async route => {
  489. await route.fulfill({ status: 405, contentType: 'application/json', body: JSON.stringify({ error: 'Method Not Allowed' }) })
  490. })
  491. await page.getByRole('option').filter({ hasText: '第二个会话' }).click()
  492. await expect(page).toHaveURL(/\/chat\/session-second\?profile=yaoyao/)
  493. await expect(page.getByText('已整理完成。下面是', { exact: false })).toBeVisible()
  494. expect(pageErrors).toEqual([])
  495. })
  496. test('syncs the blue fast-mode shortcut with the iOS-compatible session config', async ({ page }) => {
  497. await page.request.post('http://127.0.0.1:19119/__test/rpc-requests/reset')
  498. await page.goto('/chat/session-demo')
  499. const fast = page.getByRole('button', { name: '快速模式:已关闭' })
  500. await expect(fast).toHaveAttribute('aria-pressed', 'false')
  501. await fast.click()
  502. const enabled = page.getByRole('button', { name: '快速模式:已开启' })
  503. await expect(enabled).toHaveAttribute('aria-pressed', 'true')
  504. await expect(enabled).toHaveCSS('color', 'rgb(22, 119, 255)')
  505. await page.getByRole('textbox', { name: '输入消息,Enter 发送,Shift + Enter 换行' }).fill('使用快速模式')
  506. await page.getByRole('button', { name: '发送消息' }).click()
  507. await expect(page.getByText('这是来自假 Gateway 的流式回复。', { exact: true })).toBeVisible()
  508. const payload = await (await page.request.get('http://127.0.0.1:19119/__test/rpc-requests')).json() as { requests: Array<{ method: string; params: Record<string, unknown> }> }
  509. const fastConfigIndex = payload.requests.findIndex(request => request.method === 'config.set' && request.params.key === 'fast')
  510. const promptIndex = payload.requests.findIndex(request => request.method === 'prompt.submit')
  511. expect(fastConfigIndex).toBeGreaterThanOrEqual(0)
  512. expect(promptIndex).toBeGreaterThan(fastConfigIndex)
  513. expect(payload.requests[fastConfigIndex]?.params).toMatchObject({ key: 'fast', value: 'fast', scope: 'session' })
  514. await enabled.click()
  515. await expect(page.getByRole('button', { name: '快速模式:已关闭' })).toHaveAttribute('aria-pressed', 'false')
  516. await expect.poll(async () => {
  517. const next = await (await page.request.get('http://127.0.0.1:19119/__test/rpc-requests')).json() as typeof payload
  518. return next.requests.filter(request => request.method === 'config.set' && request.params.key === 'fast').at(-1)?.params.value
  519. }).toBe('normal')
  520. })
  521. test('reconciles an iOS fast-mode selection from the resumed 9119 session', async ({ page }) => {
  522. await page.request.post('http://127.0.0.1:19119/__test/rpc-requests/reset')
  523. await page.goto('/chat/session-yaoer?profile=yaoer')
  524. await expect(page.getByRole('button', { name: '快速模式:已关闭' })).toBeVisible()
  525. await page.getByRole('textbox', { name: '输入消息,Enter 发送,Shift + Enter 换行' }).fill('读取 iOS 快速模式')
  526. await page.getByRole('button', { name: '发送消息' }).click()
  527. await expect(page.getByRole('button', { name: '快速模式:已开启' })).toHaveCSS('color', 'rgb(22, 119, 255)')
  528. const payload = await (await page.request.get('http://127.0.0.1:19119/__test/rpc-requests')).json() as { requests: Array<{ method: string; params: Record<string, unknown> }> }
  529. expect(payload.requests.some(request => request.method === 'session.resume' && request.params.session_id === 'session-yaoer')).toBe(true)
  530. expect(payload.requests.some(request => request.method === 'config.set' && request.params.key === 'fast')).toBe(false)
  531. })
  532. test('keeps the show-thinking preference across sessions of the same Agent', async ({ page }) => {
  533. await page.goto('/chat/session-demo')
  534. await expect(page.locator('.turn-trace')).toHaveCount(1)
  535. await page.locator('.composer-tool[aria-label="设置"]').click()
  536. const setting = page.getByRole('switch', { name: /显示思考/ })
  537. await expect(setting).toHaveAttribute('aria-checked', 'true')
  538. await setting.click()
  539. await expect(page.locator('.turn-trace')).toHaveCount(0)
  540. await page.getByRole('option').filter({ hasText: '第二个会话' }).click()
  541. await expect(page.locator('.turn-trace')).toHaveCount(0)
  542. await page.locator('.composer-tool[aria-label="设置"]').click()
  543. await page.getByRole('switch', { name: /显示思考/ }).click()
  544. await expect(page.locator('.turn-trace')).toHaveCount(1)
  545. })
  546. test('restores a legacy session link under its owning Agent profile', async ({ page }) => {
  547. await page.goto('/chat/session-yaoer')
  548. await expect(page.getByText('瑶儿历史消息', { exact: true })).toBeVisible()
  549. await expect(page).toHaveURL(/\/chat\/session-yaoer\?profile=yaoer/)
  550. await page.reload()
  551. await expect(page.getByText('瑶儿历史消息', { exact: true })).toBeVisible()
  552. })
  553. test('renders historical assistant MEDIA as Markdown in chat and group chat', async ({ page }) => {
  554. await page.goto('/chat/session-demo')
  555. const image = page.locator('.markdown img[alt="夭夭 Logo"]')
  556. await expect(image).toBeVisible()
  557. await image.click()
  558. const mediaDialog = page.getByRole('dialog', { name: /预览 AppIcon-1024.png/ })
  559. await expect(mediaDialog).toBeVisible()
  560. await expect(mediaDialog.getByRole('button', { name: '下一张媒体' })).toBeVisible()
  561. await mediaDialog.getByRole('button', { name: '下一张媒体' }).click()
  562. await expect(mediaDialog.locator('img')).toHaveAttribute('src', /variant=2/)
  563. await page.keyboard.press('ArrowLeft')
  564. await expect(mediaDialog.locator('img')).not.toHaveAttribute('src', /variant=2/)
  565. await expect(mediaDialog.getByRole('link', { name: /下载 AppIcon-1024\.png/ })).toBeVisible()
  566. await page.keyboard.press('Escape')
  567. await expect(page.getByRole('dialog', { name: /预览 AppIcon-1024.png/ })).toBeHidden()
  568. await image.click()
  569. const reopenedMediaDialog = page.getByRole('dialog', { name: /预览 AppIcon-1024.png/ })
  570. await reopenedMediaDialog.getByRole('button', { name: '添加到聊天' }).click()
  571. await expect(reopenedMediaDialog).toBeHidden()
  572. await expect(page.locator('.composer-attachments img[alt="AppIcon-1024.png"]')).toBeVisible()
  573. await page.getByRole('button', { name: '团队' }).click()
  574. await expect(page.locator('.markdown img[alt="AppIcon-1024.png"]')).toBeVisible()
  575. })
  576. test('selects existing group topics and creates a new protocol v4 topic on first send', async ({ page }) => {
  577. const roomId = '22222222-2222-4222-8222-222222222222'
  578. const existingTopicId = '88888888-8888-4888-8888-888888888888'
  579. const existingTopicSidebarId = `topic:${roomId}:${existingTopicId}`
  580. await page.getByRole('button', { name: '团队' }).click()
  581. const sidebar = page.locator('.desktop-sidebar')
  582. const existingTopic = sidebar.locator(`[data-sidebar-id="${existingTopicSidebarId}"]`)
  583. await expect(sidebar.getByRole('button', { name: '返回对话' })).toBeVisible()
  584. await expect(sidebar.getByRole('button', { name: '折叠侧边栏' })).toBeVisible()
  585. await expect(sidebar.getByText('话题列表', { exact: true })).toBeVisible()
  586. await expect(sidebar.getByRole('button', { name: '搜索', exact: true })).toBeVisible()
  587. await expect(sidebar.getByRole('button', { name: '新建话题' })).toBeVisible()
  588. await expect(sidebar.getByRole('button', { name: '新建团队' })).toBeVisible()
  589. await expect(sidebar.getByRole('button', { name: '对话', exact: true })).toBeVisible()
  590. await expect(sidebar.locator('.sidebar-footer')).toBeVisible()
  591. await expect(existingTopic).toContainText('发布检查')
  592. await expect(existingTopic).toHaveClass(/sidebar-item--topic/)
  593. const existingTopicRequest = page.waitForRequest(request => {
  594. const url = new URL(request.url())
  595. return request.method() === 'GET'
  596. && url.pathname === `/api/app/groups/rooms/${roomId}/messages`
  597. && url.searchParams.get('topicId') === existingTopicId
  598. })
  599. const existingTopicRead = page.waitForRequest(request => {
  600. const url = new URL(request.url())
  601. return request.method() === 'PATCH'
  602. && url.pathname === `/api/app/groups/rooms/${roomId}/topics/${existingTopicId}/read`
  603. })
  604. await existingTopic.click()
  605. await existingTopicRequest
  606. expect((await existingTopicRead).postDataJSON()).toMatchObject({ throughSeq: 3 })
  607. await expect(page).toHaveURL(new RegExp(`/groups/${roomId}/${existingTopicId}$`))
  608. const timeline = page.locator('.message-stack')
  609. await expect(timeline.getByText('请核对发布话题的独立历史。', { exact: true })).toBeVisible()
  610. await expect(timeline.getByText('大家好,检查一下群聊输入框。', { exact: true })).toHaveCount(0)
  611. await sidebar.getByRole('button', { name: '新建话题' }).click()
  612. const teamPicker = page.getByRole('dialog', { name: '选择团队' })
  613. await expect(teamPicker).toBeVisible()
  614. await teamPicker.locator('.topic-team-picker__choose').filter({ hasText: '设计与工程协作' }).click()
  615. const draftTopic = sidebar.locator('.sidebar-item--topic').filter({ hasText: '新话题' })
  616. await expect(draftTopic).toBeVisible()
  617. const draftSidebarId = await draftTopic.getAttribute('data-sidebar-id')
  618. const newTopicId = draftSidebarId?.split(':').at(-1) || ''
  619. expect(newTopicId).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)
  620. expect(newTopicId).not.toBe(existingTopicId)
  621. await expect(page).toHaveURL(new RegExp(`/groups/${roomId}/${newTopicId}$`))
  622. const content = '新的发布验收话题'
  623. const sendRequestPromise = page.waitForRequest(request => {
  624. const url = new URL(request.url())
  625. return request.method() === 'POST' && url.pathname === `/api/app/groups/rooms/${roomId}/messages`
  626. })
  627. await page.getByRole('textbox', { name: '发消息给团队,输入 @ 提及 Agent' }).fill(content)
  628. await page.getByRole('button', { name: '发送消息' }).click()
  629. const sendRequest = await sendRequestPromise
  630. const sentPayload = sendRequest.postDataJSON() as { topicId: string; content: string; clientMessageId: string }
  631. expect(sentPayload).toMatchObject({ topicId: newTopicId, content })
  632. const createdTopic = sidebar.locator(`[data-sidebar-id="topic:${roomId}:${newTopicId}"]`)
  633. const sentMessage = page.locator(`[data-message-id="${sentPayload.clientMessageId}"]`)
  634. await expect(createdTopic).toContainText(content)
  635. await expect(sentMessage).toContainText(content)
  636. await page.reload()
  637. await expect(createdTopic).toContainText(content)
  638. await expect(sentMessage).toContainText(content)
  639. })
  640. test('renders persisted user file markers as attachment cards', async ({ page }) => {
  641. await page.goto('/chat/session-demo?profile=yaoyao')
  642. const userMessage = page.locator('[data-message-id="message-user-file"]')
  643. await expect(userMessage).toContainText('查看附件')
  644. await expect(userMessage.getByRole('button', { name: /测试报告\.docx/ })).toBeVisible()
  645. await expect(userMessage).not.toContainText('@file:')
  646. await expect(userMessage).not.toContainText('用户附加文件')
  647. })
  648. test('renders persisted user image markers as direct images instead of file cards', async ({ page }) => {
  649. await page.goto('/chat/session-demo?profile=yaoyao')
  650. const userMessage = page.locator('[data-message-id="message-user-image"]')
  651. const imageAttachment = userMessage.locator('.message__attachment--image')
  652. await expect(imageAttachment).toBeVisible()
  653. await expect(imageAttachment.locator('img[alt="测试图片.png"]')).toBeVisible()
  654. await expect(imageAttachment.locator('strong')).toHaveCount(0)
  655. await expect(imageAttachment).toHaveCSS('background-color', 'rgba(0, 0, 0, 0)')
  656. await expect(userMessage).not.toContainText('@image:')
  657. await expect(userMessage).not.toContainText('[screenshot]')
  658. await imageAttachment.click()
  659. await expect(page.getByRole('dialog', { name: '预览 测试图片.png' })).toBeVisible()
  660. })
  661. test('folds tool result rows into their expandable tool call', async ({ page }) => {
  662. await page.goto('/chat/session-demo')
  663. const trace = page.locator('.turn-trace').first()
  664. await expect(trace).not.toHaveAttribute('open', '')
  665. await expect(trace).toHaveCSS('background-color', 'rgba(0, 0, 0, 0)')
  666. await expect(trace.locator('summary')).toContainText('思考与工具')
  667. await expect(trace.locator('summary')).toContainText('2 段思考 · 2 个工具')
  668. await expect(trace.locator('summary > :last-child')).toHaveClass(/turn-trace__caret/)
  669. await trace.locator('summary').click()
  670. await expect(trace).not.toHaveCSS('background-color', 'rgba(0, 0, 0, 0)')
  671. await expect(trace.locator('.turn-trace__reasoning')).toHaveCount(2)
  672. await expect(trace.locator('.tool-trace')).toHaveCount(2)
  673. await expect(trace.locator('.tool-trace > button > :last-child.tool-trace__caret')).toHaveCount(2)
  674. await expect(trace.locator('.tool-trace__details')).toHaveCount(2)
  675. await expect(trace.locator('.tool-trace__details').filter({ hasText: '/tmp/demo-report.pdf' })).toBeVisible()
  676. await expect(trace.locator('.tool-trace__details pre').first()).toHaveCSS('max-height', 'none')
  677. await expect(trace.locator('.tool-trace__details pre').first()).toHaveCSS('overflow-y', 'visible')
  678. const traceContent = trace.locator('.turn-trace__content')
  679. await expect(traceContent).toHaveCSS('overflow-y', 'auto')
  680. await expect(traceContent.locator(':scope > .turn-trace__item')).toHaveCount(4)
  681. const layout = await traceContent.evaluate(element => {
  682. const items = [...element.children] as HTMLElement[]
  683. return {
  684. maxHeight: Number.parseFloat(getComputedStyle(element).maxHeight),
  685. leftOffsets: items.map(item => item.offsetLeft),
  686. }
  687. })
  688. expect(layout.maxHeight).toBeLessThanOrEqual(420)
  689. expect(new Set(layout.leftOffsets).size).toBe(1)
  690. const toolAlignment = await trace.locator('.tool-trace').first().evaluate(element => {
  691. const tool = element as HTMLElement
  692. const button = tool.querySelector<HTMLElement>(':scope > button')
  693. const detail = tool.querySelector<HTMLElement>('.tool-trace__details > section')
  694. return {
  695. toolLeft: tool.getBoundingClientRect().left,
  696. buttonLeft: button?.getBoundingClientRect().left,
  697. detailLeft: detail?.getBoundingClientRect().left,
  698. }
  699. })
  700. expect(toolAlignment.buttonLeft).toBeCloseTo(toolAlignment.toolLeft, 0)
  701. expect(toolAlignment.detailLeft).toBeCloseTo(toolAlignment.toolLeft, 0)
  702. await expect(page.locator('[data-message-id="message-tool-call"]')).toHaveCount(0)
  703. await expect(page.locator('.message--tool')).toHaveCount(0)
  704. })
  705. test('renders subtask completion as a collapsed timeline event', async ({ page }) => {
  706. await page.goto('/chat/session-demo')
  707. await expect(page.getByText('子任务已完成', { exact: true })).toBeVisible()
  708. const delegation = page.locator('.delegation-event').filter({ hasText: '子任务已完成' })
  709. await expect(delegation).toContainText('2 个子任务 · 2 已完成')
  710. await expect(delegation).not.toHaveAttribute('open', '')
  711. })
  712. test('renders background process exits as collapsed system events', async ({ page }) => {
  713. await page.goto('/chat/session-demo')
  714. const event = page.locator('[data-message-id="message-background-process"] .background-process-event')
  715. const detail = event.locator('.markdown')
  716. await expect(event).toContainText('后台子任务已终止 · SIGTERM')
  717. await expect(event).not.toHaveAttribute('open', '')
  718. await expect(detail).toBeHidden()
  719. await event.locator('summary').click()
  720. await expect(detail).toBeVisible()
  721. await expect(detail).toContainText('Command: ./run_mac.sh')
  722. await expect(page.locator('[data-message-id="message-background-process"]')).toHaveClass(/message--system/)
  723. })
  724. test('renders context compaction as a collapsed timeline event', async ({ page }) => {
  725. await page.goto('/chat/session-demo')
  726. const compaction = page.locator('[data-message-id="message-compaction"] .compaction-event')
  727. await expect(compaction).toContainText('上下文已压缩')
  728. await expect(compaction).toContainText('压缩摘要已归档 · 点击查看')
  729. await expect(compaction).not.toHaveAttribute('open', '')
  730. await expect(compaction.getByText('Historical Task Snapshot', { exact: true })).toBeHidden()
  731. await compaction.locator('summary').click()
  732. await expect(compaction.getByText('Historical Task Snapshot', { exact: true })).toBeVisible()
  733. await expect(page.locator('[data-message-id="message-compaction"]')).toHaveClass(/message--system/)
  734. })
  735. test('renders model changes as a collapsed system event', async ({ page }) => {
  736. await page.goto('/chat/session-demo')
  737. const modelEvent = page.locator('.system-event').filter({ hasText: '模型已切换:gpt-5.6-terra' })
  738. await expect(modelEvent.getByText('模型已切换:gpt-5.6-terra', { exact: true })).toBeVisible()
  739. await expect(modelEvent).not.toHaveAttribute('open', '')
  740. })
  741. test('opens a local message file link as a floating preview card', async ({ page }) => {
  742. await page.route('**/Users/samien/Agents/%E6%96%B9%E6%A1%88%E8%8D%89%E7%A8%BF.md', route => route.fulfill({
  743. status: 200,
  744. contentType: 'text/markdown',
  745. body: '# 会话文件\n\n这是会话中的文本文件。',
  746. }))
  747. await page.goto('/chat/session-demo')
  748. const card = page.getByRole('link', { name: '预览文件 方案草稿.md' })
  749. await expect(card).toHaveClass(/file-link-card/)
  750. await card.click()
  751. const dialog = page.getByRole('dialog', { name: '预览 方案草稿.md' })
  752. await expect(dialog).toBeVisible()
  753. await expect(dialog.locator('.preview-text')).toBeVisible()
  754. const textPadding = await dialog.locator('.preview-text').evaluate(element => {
  755. const style = getComputedStyle(element)
  756. return { left: Number.parseFloat(style.paddingLeft), right: Number.parseFloat(style.paddingRight) }
  757. })
  758. expect(textPadding.left).toBeGreaterThanOrEqual(24)
  759. expect(textPadding.right).toBeGreaterThanOrEqual(24)
  760. const stageHeight = await dialog.locator('.preview-stage').evaluate(stage => stage.getBoundingClientRect().height)
  761. expect(stageHeight).toBeGreaterThan(500)
  762. })
  763. test('shows a thinking animation after submit until output starts', async ({ page }) => {
  764. await page.goto('/chat/session-demo?profile=yaoyao')
  765. await page.locator('.composer-textarea').fill('请开始思考')
  766. await page.getByRole('button', { name: '发送消息' }).click()
  767. await expect(page.locator('.thinking-indicator')).toBeVisible()
  768. await expect(page.getByText('这是来自假 Gateway 的流式回复。', { exact: true })).toBeVisible()
  769. await expect(page.locator('.thinking-indicator')).toHaveCount(0)
  770. })
  771. test('uses HTTP commands and SSE for chat and team events without opening client WebSockets', async ({ page }, testInfo) => {
  772. const sockets: string[] = [], paths: string[] = []
  773. page.on('websocket', socket => sockets.push(socket.url()))
  774. page.on('request', request => paths.push(new URL(request.url()).pathname))
  775. await page.goto('/chat/session-demo?profile=yaoyao')
  776. await page.locator('.composer-textarea').fill('验证 HTTP SSE 入口')
  777. await page.getByRole('button', { name: '发送消息' }).click()
  778. await expect(page.getByText('这是来自假 Gateway 的流式回复。', { exact: true })).toBeVisible()
  779. expect(paths.some(path => /^\/api\/realtime\/channels\/[^/]+\/commands$/.test(path))).toBe(true)
  780. expect(paths.some(path => /^\/api\/realtime\/channels\/[^/]+\/events$/.test(path))).toBe(true)
  781. await page.screenshot({ path: testInfo.outputPath('http-sse-chat.png'), fullPage: true })
  782. await page.getByRole('button', { name: '团队', exact: true }).click()
  783. await page.getByRole('option').filter({ hasText: '设计验收' }).click()
  784. await expect(page.getByRole('heading', { name: '设计验收' })).toBeVisible()
  785. expect(sockets).toEqual([])
  786. await page.screenshot({ path: testInfo.outputPath('http-sse-team.png'), fullPage: true })
  787. })
  788. test('keeps streamed text below sealed interim commentary and its tool trace', async ({ page }) => {
  789. await page.goto('/chat/session-demo?profile=yaoyao')
  790. await page.locator('.composer-textarea').fill('验证流式分段')
  791. await page.getByRole('button', { name: '发送消息' }).click()
  792. const interim = page.locator('.message--assistant').filter({ hasText: '我先检查配置。' }).last()
  793. const current = page.locator('.message--assistant').filter({ hasText: '配置检查完成。' }).last()
  794. const trace = page.locator('.turn-trace').last()
  795. await expect(interim).toBeVisible()
  796. await expect(trace).toHaveClass(/turn-trace--running/)
  797. await expect(page.locator('.thinking-indicator')).toBeVisible()
  798. await expect(current).toBeVisible()
  799. const [interimBox, traceBox, currentBox] = await Promise.all([
  800. interim.boundingBox(), trace.boundingBox(), current.boundingBox(),
  801. ])
  802. expect(interimBox?.y).toBeLessThan(traceBox?.y ?? 0)
  803. expect(traceBox?.y).toBeLessThan(currentBox?.y ?? 0)
  804. await expect(trace).toHaveClass(/turn-trace--success/)
  805. await expect(page.getByText('配置检查完成。', { exact: true })).toHaveCount(1)
  806. })
  807. test('keeps the canonical logo and yaoyao-webui composer geometry', async ({ page }) => {
  808. const logo = page.locator('.rail__brand img')
  809. await expect(logo).toHaveAttribute('src', '/brand/AppIcon-1024.png')
  810. const emptyLogo = page.locator('.new-chat-empty__logo')
  811. await expect(emptyLogo).toHaveAttribute('src', '/brand/AppIcon-1024.png')
  812. await expect(page.getByText('聊点什么', { exact: true })).toBeVisible()
  813. await expect(page.locator('.timeline-header')).toHaveClass(/timeline-header--transparent/)
  814. await expect(page.locator('.composer-context')).toContainText('剩余 256.0k')
  815. await page.getByRole('button', { name: '推理强度:默认' }).click()
  816. await expect(page.locator('.composer-popover--reasoning')).toBeVisible()
  817. await page.getByRole('button', { name: '设置', exact: true }).click()
  818. await expect(page.locator('.composer-popover--settings')).toBeVisible()
  819. await expect(page.getByText('语音输入设置', { exact: true })).toBeVisible()
  820. await page.locator('.composer-shell').click()
  821. await page.getByRole('option').first().click()
  822. await expect(page.locator('.timeline')).toHaveCSS('background-color', 'rgb(255, 255, 255)')
  823. await expect(page.locator('.message--assistant .message__avatar')).toHaveCount(0)
  824. await expect(page.locator('.message--assistant .message__meta')).toHaveCount(0)
  825. const assistantMessage = page.locator('.message--assistant-anonymous:not(.message--tool-only)').first()
  826. await page.mouse.move(1200, 20)
  827. await expect(assistantMessage.locator('.message__actions')).toHaveCSS('opacity', '0')
  828. await assistantMessage.hover()
  829. await expect(assistantMessage.locator('.message__actions')).toHaveCSS('opacity', '1')
  830. await expect(page.locator('.message--tool-only .message__actions')).toHaveCount(0)
  831. await expect(page.locator('[data-message-id="message-thinking-tool"]')).toHaveCount(0)
  832. await expect(page.locator('.turn-trace')).toHaveCount(1)
  833. const userMessageMeta = page.locator('.message--user .message__meta')
  834. await expect(userMessageMeta).not.toHaveCount(0)
  835. expect(await userMessageMeta.evaluateAll(elements => elements.every(element => getComputedStyle(element).display === 'none'))).toBe(true)
  836. await expect(page.getByRole('button', { name: '会话操作' })).toBeVisible()
  837. await page.getByRole('button', { name: '会话操作' }).click()
  838. const sessionMenu = page.getByRole('menu', { name: '会话操作' })
  839. await expect(sessionMenu.getByText('会话大纲', { exact: true })).toBeVisible()
  840. await sessionMenu.getByText('会话大纲', { exact: true }).click()
  841. const outline = page.getByRole('navigation', { name: '会话大纲' })
  842. await expect(outline).toBeVisible()
  843. await expect(outline.getByText('请检查今天生成的产物。MEDIA:/brand/AppIcon-1024.png', { exact: true })).toBeVisible()
  844. await expect(outline.getByText('验收摘要', { exact: true })).toBeVisible()
  845. await outline.getByRole('button', { name: '跳转到 验收摘要' }).click()
  846. await expect(page.locator('[data-message-id="message-assistant"]')).toHaveClass(/message--revealed/)
  847. await page.getByRole('button', { name: '关闭会话大纲' }).click()
  848. await expect(outline).toBeHidden()
  849. await page.getByRole('button', { name: '会话操作' }).click()
  850. await expect(sessionMenu.getByText('取消置顶', { exact: true })).toBeVisible()
  851. const unpinIcon = sessionMenu.getByRole('menuitem', { name: '取消置顶' }).locator('.app-icon')
  852. await expect(unpinIcon.locator('path')).toHaveCount(2)
  853. await expect(unpinIcon.locator('path').last()).toHaveAttribute('d', 'M4 4l16 16')
  854. await expect(page.locator('.desktop-sidebar .sidebar-item--single-line').first().locator('.app-icon path')).toHaveAttribute('fill', 'currentColor')
  855. await expect(sessionMenu.getByText('重命名', { exact: true })).toBeVisible()
  856. await expect(sessionMenu.getByText('删除会话', { exact: true })).toBeVisible()
  857. await expect(page.getByText('置顶会话', { exact: true })).toHaveCount(0)
  858. const menuBox = await sessionMenu.evaluate(element => element.getBoundingClientRect().toJSON())
  859. expect(menuBox.width).toBeLessThanOrEqual(220)
  860. expect(menuBox.height).toBeLessThan(165)
  861. await expect(page.locator('.session-action-layer')).toHaveCount(0)
  862. await sessionMenu.getByText('取消置顶', { exact: true }).click()
  863. await expect(page.locator('.desktop-sidebar').getByText('已置顶 1', { exact: true })).toHaveCount(0)
  864. await page.getByRole('button', { name: '会话操作' }).click()
  865. await sessionMenu.getByText('置顶会话', { exact: true }).click()
  866. await expect(page.locator('.desktop-sidebar').getByText('已置顶 1', { exact: true })).toBeVisible()
  867. const compactSession = page.locator('.desktop-sidebar .sidebar-item--single-line').first()
  868. const compactMetrics = await compactSession.evaluate(element => {
  869. const title = element.querySelector('strong')
  870. return {
  871. height: element.getBoundingClientRect().height,
  872. weight: title ? Number(getComputedStyle(title).fontWeight) : 0,
  873. }
  874. })
  875. expect(compactMetrics.height).toBeLessThanOrEqual(31)
  876. expect(compactMetrics.weight).toBeLessThan(500)
  877. await compactSession.click({ button: 'right' })
  878. await expect(sessionMenu).toBeVisible()
  879. await page.keyboard.press('Escape')
  880. const composer = page.locator('.composer-shell')
  881. await expect(composer).toBeVisible()
  882. const geometry = await composer.evaluate(element => {
  883. const rect = element.getBoundingClientRect()
  884. const style = getComputedStyle(element)
  885. return { width: rect.width, minHeight: style.minHeight, radius: style.borderRadius }
  886. })
  887. expect(geometry.width).toBeLessThanOrEqual(760)
  888. expect(geometry.minHeight).toBe('72px')
  889. expect(geometry.radius).toBe('18px')
  890. const send = page.getByRole('button', { name: '发送消息' })
  891. await expect(send).toHaveCSS('width', '34px')
  892. await expect(send).toHaveCSS('height', '34px')
  893. })
  894. test('uses the unified Grok-style sidebar, search trigger, and persistent collapse', async ({ page }) => {
  895. const sidebar = page.locator('.desktop-sidebar')
  896. await expect(sidebar).toBeVisible()
  897. await expect(sidebar).toHaveCSS('width', '264px')
  898. await expect(sidebar.locator('.brand-mark__name')).toHaveCount(0)
  899. await expect(sidebar.locator('.profile-switcher')).toHaveCount(0)
  900. await expect(sidebar.locator('.sidebar-account-switcher')).toHaveCount(1)
  901. await expect(page.getByRole('button', { name: '搜索', exact: true })).toBeVisible()
  902. await expect(page.getByRole('button', { name: '新建聊天', exact: true })).toBeVisible()
  903. await expect(page.getByRole('button', { name: '新建聊天', exact: true })).toHaveCSS('background-color', 'rgba(0, 0, 0, 0)')
  904. await expect(page.getByRole('button', { name: '新建聊天', exact: true })).toHaveCSS('font-weight', '650')
  905. await expect(sidebar.getByText('历史记录', { exact: true })).toBeVisible()
  906. const searchTrigger = page.getByRole('button', { name: '搜索', exact: true })
  907. await searchTrigger.click()
  908. const searchDialog = page.getByRole('dialog', { name: '搜索会话' })
  909. await expect(searchDialog).toBeVisible()
  910. const search = searchDialog.getByPlaceholder('搜索会话')
  911. await expect(search).toBeVisible()
  912. await expect(sidebar.locator('.sidebar-search')).toHaveCount(0)
  913. const originalSessionCount = await sidebar.getByRole('option').count()
  914. await search.fill('验收')
  915. const sessionResult = searchDialog.getByRole('option', { name: /夭夭 Web 验收会话/ })
  916. await expect(sessionResult).toBeVisible()
  917. await expect(sidebar.getByRole('option')).toHaveCount(originalSessionCount)
  918. await sessionResult.click()
  919. await expect(page).toHaveURL(/\/chat\/session-demo\?profile=yaoyao/)
  920. await expect(searchDialog).toBeHidden()
  921. await expect(searchTrigger).toBeVisible()
  922. await expect(searchTrigger).toHaveAttribute('aria-expanded', 'false')
  923. await page.getByRole('button', { name: '折叠侧边栏' }).click()
  924. await expect(sidebar).toHaveCSS('width', '68px')
  925. const collapseBox = await page.getByRole('button', { name: '展开侧边栏' }).boundingBox()
  926. const accountBox = await sidebar.locator('.sidebar-account-switcher__main').boundingBox()
  927. expect(collapseBox?.y).toBeLessThan(accountBox?.y ?? 0)
  928. await expect(sidebar.getByText('历史记录', { exact: true })).toBeHidden()
  929. await expect(page.getByRole('button', { name: '搜索', exact: true })).toBeVisible()
  930. await expect(page.getByRole('button', { name: '新建聊天', exact: true })).toBeVisible()
  931. await page.reload()
  932. await expect(sidebar).toHaveCSS('width', '68px')
  933. await page.getByRole('button', { name: '搜索', exact: true }).click()
  934. await expect(sidebar).toHaveCSS('width', '264px')
  935. await expect(page.getByRole('dialog', { name: '搜索会话' })).toBeVisible()
  936. })
  937. test('uses the mobile composer and keeps the closed drawer inert', async ({ page }) => {
  938. await page.setViewportSize({ width: 390, height: 844 })
  939. await page.reload()
  940. await expect(page.getByRole('navigation')).not.toBeVisible()
  941. const drawer = page.locator('.mobile-drawer')
  942. await expect(drawer).toHaveAttribute('aria-hidden', 'true')
  943. await expect(drawer).toHaveAttribute('inert', '')
  944. await expect(page.locator('.mobile-header .brand-mark__plate')).toBeVisible()
  945. await expect(page.locator('.mobile-header .brand-mark__name')).toHaveCount(0)
  946. await page.getByRole('button', { name: '打开导航' }).click()
  947. await expect(drawer.locator('.brand-mark__plate')).toBeVisible()
  948. await expect(drawer.locator('.brand-mark__name')).toHaveCount(0)
  949. await expect(page.locator('.composer-shell')).toHaveCSS('min-height', '118px')
  950. await expect(page.locator('.composer-textarea')).toHaveCSS('font-size', '16px')
  951. })
  952. test('renders the Kanban snapshot and mobile status control without page overflow', async ({ page }) => {
  953. await page.getByRole('button', { name: '看板', exact: true }).click()
  954. await expect(page).toHaveURL(/\/kanban\/default$/)
  955. await expect(page).toHaveTitle('产品研发 · 夭夭')
  956. await expect(page.getByRole('heading', { name: '产品研发', exact: true })).toBeVisible()
  957. await expect(page.getByRole('article', { name: /完成 Web 看板验收/ })).toBeVisible()
  958. await expect(page.locator('.kanban-column')).toHaveCount(8)
  959. await page.getByRole('article', { name: /完成 Web 看板验收/ }).click()
  960. await expect(page.getByRole('heading', { name: '完成 Web 看板验收', exact: true })).toBeVisible()
  961. await expect(page.getByText('请保留真实浏览器验收证据。', { exact: true })).toBeVisible()
  962. await expect(page.locator('.kanban-task-drawer').getByText('正在执行浏览器验收', { exact: true }).first()).toBeVisible()
  963. await page.getByRole('button', { name: '关闭任务详情' }).click()
  964. await page.setViewportSize({ width: 390, height: 844 })
  965. await page.reload()
  966. await expect(page.getByRole('button', { name: '立即调度', exact: true })).toBeVisible()
  967. const card = page.getByRole('article', { name: /完成 Web 看板验收/ })
  968. await expect(card).toBeVisible()
  969. await expect(card.locator('.kanban-card__mobile-status select')).toBeVisible()
  970. const geometry = await page.evaluate(() => ({
  971. viewport: window.innerWidth,
  972. page: document.documentElement.scrollWidth,
  973. board: document.querySelector('.kanban-columns')?.scrollWidth || 0,
  974. }))
  975. expect(geometry.page).toBe(geometry.viewport)
  976. expect(geometry.board).toBeGreaterThan(geometry.viewport)
  977. })