lifecycle-chrome.e2e.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. // Web e2e scenarios: lifecycle & chrome — the workspace-aware first-send
  2. // flow over the real wire, reload recovery, and the dark-mode token cascade.
  3. // One tiny recorded turn (text-only) drives the whole spec: the empty-state
  4. // hero materializes a real Workspace + Session on first send (the jsdom
  5. // workspace-flow suite pins the object-layer state machine over the fixture
  6. // client; THIS spec pins the same flow through HTTP RPC + WebSocket + the host
  7. // gateway), reload replays everything from the log (zero further model
  8. // calls), and the theme scenario proves the shipped dark palette actually
  9. // cascades: attribute -> alias token flip -> painted surface change. No
  10. // theme/layout golden: aria snapshots are color-blind (lane scope: the
  11. // browser-e2e-lane Agent Note); the hero's waiting state gets the one golden
  12. // here.
  13. import { readFile } from 'node:fs/promises'
  14. import { fileURLToPath } from 'node:url'
  15. import { join } from 'node:path'
  16. import type { Browser, Page, WebSocketRoute } from 'playwright'
  17. import { chromium } from 'playwright'
  18. import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest'
  19. import type { SessionEvent } from '@deepseek-ai/dsh-session'
  20. import {
  21. acknowledgeReloadConnectionLoss, assertFixtureInventory, captureExpandedTurnProcessAria,
  22. captureStableAria, compareOrRefreshGolden, fixtureUserPrompts,
  23. launchWebScaffold, recordFixture, watchConsole, webSnapshotMode, type WebScaffold,
  24. } from './scaffold.ts'
  25. import {
  26. connectFreshWorkspace, newEnglishPage, saveFailureShot, writeComposerDraft,
  27. } from './support.ts'
  28. const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/lifecycle-chrome', import.meta.url))
  29. const FIXTURE = join(SNAPSHOT_DIR, 'session.jsonl')
  30. const REPLAY_OVERRIDE = join(SNAPSHOT_DIR, 'replay.override.json')
  31. const HERO_EXPECTED = join(SNAPSHOT_DIR, 'hero.expected.md')
  32. const COMMAND_MENU_EXPECTED = join(SNAPSHOT_DIR, 'command-menu.expected.md')
  33. const FUZZY_COMMAND_MENU_EXPECTED = join(SNAPSHOT_DIR, 'command-menu-fuzzy.expected.md')
  34. const PLAN_ACTIVE_EXPECTED = join(SNAPSHOT_DIR, 'plan-active.expected.md')
  35. const CONNECTION_ERROR_EXPECTED = join(SNAPSHOT_DIR, 'connection-error.expected.md')
  36. // Post-reload golden: the same settled conversation rebuilt purely from
  37. // persistence + history — byte-equal rendering is exactly the recovery claim.
  38. const RELOADED_EXPECTED = join(SNAPSHOT_DIR, 'reloaded.expected.md')
  39. const RELOADED_EXPANDED_EXPECTED = join(SNAPSHOT_DIR, 'reloaded-expanded.expected.md')
  40. const MODE = webSnapshotMode()
  41. const PROMPT = 'Reply with the single word LIGHTHOUSE and stop.'
  42. const REPLAY_PACE_MS = 100
  43. describe('web e2e: lifecycle & chrome (workspace flow / reload / dark mode)', () => {
  44. let scaffold: WebScaffold
  45. let browser: Browser
  46. let page: Page
  47. let tripwire: ReturnType<typeof watchConsole>
  48. const sessionEvents: SessionEvent[] = []
  49. beforeAll(async () => {
  50. scaffold = await launchWebScaffold(MODE === 'record'
  51. ? {}
  52. : { replayFixture: FIXTURE, replayOverride: REPLAY_OVERRIDE, paceMs: REPLAY_PACE_MS })
  53. scaffold.ctx.on('session/event', (_session, event: SessionEvent) => { sessionEvents.push(event) })
  54. browser = await chromium.launch()
  55. page = await newEnglishPage(browser)
  56. tripwire = watchConsole(page)
  57. await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
  58. await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
  59. // Fresh world: connect a Workspace so the composer scenarios start live.
  60. await connectFreshWorkspace(page, scaffold.workspaceCwd)
  61. }, 120_000)
  62. afterAll(async () => {
  63. await browser?.close()
  64. await scaffold?.close()
  65. })
  66. it.skipIf(MODE === 'record')('opens the shared slash menu from plus with only Command candidates', async () => {
  67. onTestFailed(() => saveFailureShot(page, 'web-e2e-command-menu-launcher'))
  68. const launcher = page.getByRole('button', { name: 'Commands' })
  69. await launcher.click()
  70. const menu = page.getByRole('listbox', { name: 'Trigger suggestions' })
  71. await menu.waitFor({ timeout: 10_000 })
  72. const snapshot = await captureStableAria(page, '[role="listbox"]', scaffold.workspaceCwd)
  73. await compareOrRefreshGolden(COMMAND_MENU_EXPECTED, snapshot, MODE)
  74. expect(snapshot).toContain('text: Commands')
  75. expect(snapshot).not.toContain('text: Skills')
  76. expect(snapshot).not.toContain('text: Subagents')
  77. const launchedBox = await menu.boundingBox()
  78. await page.locator('[data-composer-input]').first().press('Escape')
  79. await expect.poll(() => menu.count()).toBe(0)
  80. const input = page.locator('[data-composer-input]').first()
  81. await writeComposerDraft(page, input, '/')
  82. await menu.waitFor({ timeout: 10_000 })
  83. const typedBox = await menu.boundingBox()
  84. expect(launchedBox).not.toBeNull()
  85. expect(typedBox).not.toBeNull()
  86. expect(Math.abs(launchedBox!.x - typedBox!.x)).toBeLessThan(1)
  87. expect(Math.abs(
  88. launchedBox!.y + launchedBox!.height - typedBox!.y - typedBox!.height,
  89. )).toBeLessThan(1)
  90. await writeComposerDraft(page, input, '/cpt')
  91. await expect.poll(() => menu.getByRole('option').allTextContents()).toEqual([
  92. 'compactCompact older conversation history',
  93. ])
  94. const fuzzySnapshot = await captureStableAria(page, '[role="listbox"]', scaffold.workspaceCwd)
  95. await compareOrRefreshGolden(FUZZY_COMMAND_MENU_EXPECTED, fuzzySnapshot, MODE)
  96. await writeComposerDraft(page, input, '')
  97. await expect.poll(() => menu.count()).toBe(0)
  98. })
  99. it.skipIf(MODE === 'record')('shows active Plan as the warn-state status action', async () => {
  100. const activeScaffold = await launchWebScaffold()
  101. const activePage = await newEnglishPage(browser)
  102. const activeTripwire = watchConsole(activePage)
  103. try {
  104. await activePage.goto(activeScaffold.authenticatedUrl, { waitUntil: 'load' })
  105. await activePage.waitForSelector('[class*="frame"]', { timeout: 30_000 })
  106. await connectFreshWorkspace(activePage, activeScaffold.workspaceCwd)
  107. const input = activePage.locator('[data-composer-input]').first()
  108. await activePage.getByRole('button', { name: 'Commands' }).click()
  109. const menu = activePage.getByRole('listbox', { name: 'Trigger suggestions' })
  110. await menu.waitFor({ timeout: 10_000 })
  111. await menu.getByRole('option', { name: 'plan Enter or leave plan mode' }).click()
  112. await expect.poll(() => input.textContent()).toBe('/plan ')
  113. await input.press('Enter')
  114. const planButton = activePage.getByRole('button', { name: 'Plan mode on, press to turn off' })
  115. await planButton.waitFor({ timeout: 10_000 })
  116. // The golden encodes an empty composer, and the button arriving does not
  117. // mean the submitted text is gone yet: under load the capture can catch
  118. // a textbox still holding `/plan`.
  119. await expect.poll(() => input.textContent(), { timeout: 10_000 }).toBe('')
  120. const planSnapshot = await captureStableAria(activePage, '[class*="frame"]', activeScaffold.workspaceCwd)
  121. await compareOrRefreshGolden(PLAN_ACTIVE_EXPECTED, planSnapshot, MODE)
  122. const planStyle = await planButton.evaluate((element) => {
  123. const probe = document.createElement('span')
  124. probe.style.color = 'var(--dsw-alias-state-warn-label)'
  125. probe.style.backgroundColor = 'var(--dsw-alias-state-warn-tertiary)'
  126. document.body.append(probe)
  127. const actual = getComputedStyle(element)
  128. const reference = getComputedStyle(probe)
  129. const result = {
  130. color: actual.color,
  131. backgroundColor: actual.backgroundColor,
  132. borderRadius: actual.borderRadius,
  133. fontSize: actual.fontSize,
  134. referenceColor: reference.color,
  135. referenceBackgroundColor: reference.backgroundColor,
  136. }
  137. probe.remove()
  138. return result
  139. })
  140. expect(planStyle.color).toBe(planStyle.referenceColor)
  141. expect(planStyle.backgroundColor).toBe(planStyle.referenceBackgroundColor)
  142. expect(planStyle.borderRadius).toBe('999px')
  143. expect(planStyle.fontSize).toBe('13px')
  144. await planButton.click()
  145. await expect.poll(() => planButton.count()).toBe(0)
  146. expect(activeTripwire.pageErrors).toEqual([])
  147. expect(activeTripwire.warnings).toEqual([])
  148. } catch (error) {
  149. await saveFailureShot(activePage, 'web-e2e-plan-active').catch(() => undefined)
  150. throw error
  151. } finally {
  152. await activePage.close()
  153. await activeScaffold.close()
  154. }
  155. })
  156. it('sends the first prompt from the empty-state hero (all modes)', async () => {
  157. onTestFailed(() => saveFailureShot(page, 'web-e2e-lifecycle-send'))
  158. if (MODE !== 'record') {
  159. expect(fixtureUserPrompts(await readFile(FIXTURE, 'utf8'))).toEqual([PROMPT])
  160. }
  161. // The blank frame renders the hero, not the resident composer: the
  162. // headline plus the guidance placeholder are the empty state's anchors.
  163. await expect.poll(() => page.getByText('Into the Unknown', { exact: false }).count(), { timeout: 15_000 }).toBe(1)
  164. const input = page.locator('[data-composer-input]').first()
  165. await input.waitFor({ timeout: 10_000 })
  166. if (MODE !== 'record') {
  167. await page.getByText('Into the Unknown', { exact: false }).hover()
  168. await expect.poll(() => page.getByRole('tooltip').count()).toBe(0)
  169. // Golden of the hero's stable waiting state (captured before any send;
  170. // the conversation-region goldens belong to the other scenarios).
  171. const snapshot = await captureStableAria(page, '[class*="frame"]', scaffold.workspaceCwd)
  172. await compareOrRefreshGolden(HERO_EXPECTED, snapshot, MODE)
  173. }
  174. const settled = scaffold.whenTurnSettled()
  175. await writeComposerDraft(page, input, PROMPT)
  176. const observeTurn = async () => {
  177. const originalViewport = page.viewportSize() ?? { width: 1680, height: 1000 }
  178. if (MODE !== 'record') await page.setViewportSize({ width: 480, height: 1000 })
  179. try {
  180. await input.press('Enter')
  181. if (MODE !== 'record') {
  182. const liveTail = page.locator('[data-variant="think"][data-state="running"] [data-follow-end]')
  183. await expect.poll(async () => await liveTail.evaluate(element => (
  184. element.scrollWidth > element.clientWidth
  185. && element.scrollLeft >= element.scrollWidth - element.clientWidth - 1
  186. )), { timeout: 10_000, interval: 10 }).toBe(true)
  187. }
  188. return await settled
  189. } finally {
  190. if (MODE !== 'record') await page.setViewportSize(originalViewport)
  191. }
  192. }
  193. const sessionId = await observeTurn()
  194. if (MODE === 'record') {
  195. await recordFixture(scaffold, sessionId, FIXTURE)
  196. }
  197. }, 200_000)
  198. it.skipIf(MODE === 'record')('materialized a real Workspace and Session over the wire', async () => {
  199. onTestFailed(() => saveFailureShot(page, 'web-e2e-lifecycle-materialize'))
  200. // Browser: the sidebar tree now carries the auto-created workspace group
  201. // with its one session, and the opened session is the selected row. The
  202. // compact layout dropped group session counts, so the group row itself is
  203. // the barrier.
  204. await expect.poll(
  205. () => page.locator('[role="treeitem"][aria-expanded]').filter({ hasText: 'workspace' }).count(),
  206. { timeout: 15_000 },
  207. ).toBeGreaterThanOrEqual(1)
  208. await expect.poll(() => page.locator('[role="treeitem"][aria-selected="true"]').count(), { timeout: 10_000 }).toBe(1)
  209. await expect.poll(() => page.getByText('LIGHTHOUSE', { exact: true }).count(), { timeout: 15_000 }).toBeGreaterThanOrEqual(1)
  210. await expect.poll(() => page.getByText('Cache hit 99.5%', { exact: true }).count(), { timeout: 15_000 }).toBe(1)
  211. // Host: the session's durable header cwd is the folder the workspace
  212. // flow created and adopted (<workspaceCwd>/workspace) — the proof the
  213. // send went through workspace materialization rather than a bare
  214. // default-cwd session.
  215. const cwds = scaffold.ctx.sessions.list().map(session => session.header.cwd)
  216. expect(cwds).toEqual([join(scaffold.workspaceCwd, 'workspace')])
  217. const turnEnds = sessionEvents.filter(e => e.type === 'turn/end')
  218. expect(turnEnds).toHaveLength(1)
  219. expect((turnEnds[0] as SessionEvent & { data: { reason: { kind: string } } }).data.reason.kind).toBe('completed')
  220. }, 60_000)
  221. it.skipIf(MODE === 'record')('recovers the whole surface across a reload from the log alone', async () => {
  222. onTestFailed(() => saveFailureShot(page, 'web-e2e-lifecycle-reload'))
  223. const warningStart = tripwire.warnings.length
  224. await page.reload({ waitUntil: 'load' })
  225. await page.waitForSelector('[class*="frame"]', { timeout: 30_000 })
  226. acknowledgeReloadConnectionLoss(tripwire, warningStart)
  227. // Selection persisted (dsh.sessions.current) and history replayed: the
  228. // recorded turn re-renders from a Session Controller page with zero model calls —
  229. // the replay cursor was fully consumed before the reload, so any stray
  230. // request would fail the scenario loudly at close().
  231. await expect.poll(() => page.getByText('LIGHTHOUSE', { exact: true }).count(), { timeout: 15_000 }).toBeGreaterThanOrEqual(1)
  232. await expect.poll(() => page.locator('[role="treeitem"][aria-selected="true"]').count(), { timeout: 10_000 }).toBe(1)
  233. // Golden of the recovered conversation region: rebuilt from the log, it
  234. // must render the same settled transcript the live turn produced.
  235. const snapshot = await captureStableAria(page, '[class*="centerCol"]', scaffold.workspaceCwd)
  236. await compareOrRefreshGolden(RELOADED_EXPECTED, snapshot, MODE)
  237. const expanded = await captureExpandedTurnProcessAria(
  238. page,
  239. '[class*="centerCol"]',
  240. scaffold.workspaceCwd,
  241. )
  242. await compareOrRefreshGolden(RELOADED_EXPANDED_EXPECTED, expanded, MODE)
  243. expect(tripwire.pageErrors).toEqual([])
  244. }, 90_000)
  245. it.skipIf(MODE === 'record')('cascades the dark theme from the body attribute to painted surfaces', async () => {
  246. onTestFailed(() => saveFailureShot(page, 'web-e2e-lifecycle-dark'))
  247. // This scenario pins the ThemeRuntime's DOM contract directly (the
  248. // body[data-ds-dark-theme] attribute -> stylesheet cascade); the REAL
  249. // user gesture above it (Settings -> Appearance cubes) is owned by
  250. // settings-chrome.e2e.ts. Driving the attribute here keeps the cascade
  251. // pinned independently of the settings surface's own lifecycle.
  252. const sample = async (): Promise<{ token: string; sidebarBg: string; bodyBg: string }> =>
  253. await page.evaluate(() => {
  254. const sidebar = document.querySelector('[class*="sidebar"], [class*="rail"]') ?? document.body
  255. return {
  256. token: getComputedStyle(document.body).getPropertyValue('--dsw-alias-bg-base').trim(),
  257. sidebarBg: getComputedStyle(sidebar).backgroundColor,
  258. bodyBg: getComputedStyle(document.body).backgroundColor,
  259. }
  260. })
  261. const light = await sample()
  262. await page.evaluate(() => { document.body.setAttribute('data-ds-dark-theme', '') })
  263. const dark = await sample()
  264. // The alias token itself must flip — the cascade's root fact.
  265. expect(dark.token).not.toBe(light.token)
  266. // And a real painted surface must consume it (not just variables in a
  267. // void): at least one of the sampled backgrounds repaints.
  268. expect(dark.sidebarBg !== light.sidebarBg || dark.bodyBg !== light.bodyBg).toBe(true)
  269. // Removing the attribute restores the light values exactly (the palettes
  270. // live in one stylesheet; activation is attribute-only by design).
  271. await page.evaluate(() => { document.body.removeAttribute('data-ds-dark-theme') })
  272. const restored = await sample()
  273. expect(restored).toEqual(light)
  274. expect(tripwire.pageErrors).toEqual([])
  275. }, 60_000)
  276. it.skipIf(MODE === 'record')('shows automatic and user-requested connection recovery beside Settings', async () => {
  277. const recoveryPage = await newEnglishPage(browser)
  278. const recoveryTripwire = watchConsole(recoveryPage)
  279. const sockets: WebSocketRoute[] = []
  280. let rejectConnections = false
  281. await recoveryPage.routeWebSocket('**/api/remote.mux', (route) => {
  282. sockets.push(route)
  283. if (rejectConnections) {
  284. void route.close({ code: 4001, reason: 'connection recovery test' })
  285. return
  286. }
  287. route.connectToServer()
  288. })
  289. onTestFailed(() => saveFailureShot(recoveryPage, 'web-e2e-connection-recovery'))
  290. try {
  291. await recoveryPage.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
  292. await recoveryPage.waitForSelector('[class*="frame"]', { timeout: 30_000 })
  293. await expect.poll(() => sockets.length).toBe(1)
  294. rejectConnections = true
  295. await recoveryPage.context().setOffline(true)
  296. await expect.poll(() => recoveryPage.evaluate(() => navigator.onLine)).toBe(false)
  297. const offline = recoveryPage.getByRole('button', {
  298. name: 'Disconnected, reconnect now', exact: true,
  299. })
  300. await offline.waitFor({ timeout: 2_000 })
  301. await recoveryPage.waitForTimeout(750)
  302. expect(sockets).toHaveLength(1)
  303. await recoveryPage.context().setOffline(false)
  304. await expect.poll(() => recoveryPage.evaluate(() => navigator.onLine)).toBe(true)
  305. const connecting = recoveryPage.getByRole('button', {
  306. name: 'Connecting, restart now', exact: true,
  307. })
  308. await connecting.waitFor({ timeout: 10_000 })
  309. expect(await connecting.innerText()).toMatch(/^Connecting\.{1,3}$/)
  310. const connectingGeometry = await connectionIndicatorGeometry(connecting)
  311. expect(await connectionIndicatorTextAlignment(connecting)).toBe('left')
  312. await connecting.hover()
  313. expect(await connecting.innerText()).toBe('Reconnect now')
  314. expect(await connectionIndicatorGeometry(connecting)).toEqual(connectingGeometry)
  315. await recoveryPage.mouse.move(0, 0)
  316. await expect.poll(() => sockets.length, { timeout: 40_000 }).toBe(7)
  317. const indicator = recoveryPage.getByRole('button', {
  318. name: 'Disconnected, reconnect now', exact: true,
  319. })
  320. await indicator.waitFor({ timeout: 10_000 })
  321. expect(await connectionIndicatorGeometry(indicator)).toEqual(connectingGeometry)
  322. expect(await connectionIndicatorTextAlignment(indicator)).toBe('left')
  323. const snapshot = await captureStableAria(recoveryPage, '[class*="footArea"]', scaffold.workspaceCwd)
  324. await compareOrRefreshGolden(CONNECTION_ERROR_EXPECTED, snapshot, MODE)
  325. const style = await indicator.evaluate((element) => {
  326. const probe = document.createElement('span')
  327. probe.style.color = 'var(--dsw-alias-state-warn-label)'
  328. probe.style.backgroundColor = 'var(--dsw-alias-state-warn-tertiary)'
  329. document.body.append(probe)
  330. const actual = getComputedStyle(element)
  331. const reference = getComputedStyle(probe)
  332. const result = {
  333. background: actual.backgroundColor,
  334. color: actual.color,
  335. referenceBackground: reference.backgroundColor,
  336. referenceColor: reference.color,
  337. }
  338. probe.remove()
  339. return result
  340. })
  341. expect(style.background).toBe(style.referenceBackground)
  342. expect(style.color).toBe(style.referenceColor)
  343. expect(await indicator.locator('svg').count()).toBe(1)
  344. expect(await indicator.getAttribute('title')).toBeNull()
  345. const idleBackground = await indicator.evaluate(element => getComputedStyle(element).backgroundColor)
  346. await indicator.hover()
  347. expect(await indicator.innerText()).toBe('Reconnect now')
  348. const hoverBackground = await indicator.evaluate(element => getComputedStyle(element).backgroundColor)
  349. expect(hoverBackground).toBe(idleBackground)
  350. await recoveryPage.mouse.down()
  351. await expect.poll(() => indicator.evaluate(element => getComputedStyle(element).backgroundColor))
  352. .not.toBe(hoverBackground)
  353. rejectConnections = false
  354. await recoveryPage.mouse.up()
  355. await expect.poll(() => sockets.length).toBe(8)
  356. const recovered = recoveryPage.getByRole('status')
  357. await recovered.waitFor({ timeout: 10_000 })
  358. expect(await recovered.innerText()).toBe('Connected')
  359. expect(await connectionIndicatorGeometry(recovered)).toEqual(connectingGeometry)
  360. expect(await connectionIndicatorTextAlignment(recovered)).toBe('left')
  361. await recovered.waitFor({ state: 'detached', timeout: 5_000 })
  362. expect(recoveryTripwire.pageErrors).toEqual([])
  363. expect(recoveryTripwire.warnings.filter(warning => /connection lost, retry #[1-6]/i.test(warning)))
  364. .toHaveLength(7)
  365. } finally {
  366. await recoveryPage.close()
  367. }
  368. }, 60_000)
  369. it.skipIf(MODE === 'record')('keeps the fixture inventory closed', async () => {
  370. expect(tripwire.warnings).toEqual([])
  371. await assertFixtureInventory(SNAPSHOT_DIR, [
  372. 'session.jsonl', 'replay.override.json', 'command-menu.expected.md',
  373. 'command-menu-fuzzy.expected.md', 'connection-error.expected.md', 'hero.expected.md', 'plan-active.expected.md',
  374. 'reloaded.expected.md', 'reloaded-expanded.expected.md',
  375. ])
  376. })
  377. })
  378. async function connectionIndicatorGeometry(locator: ReturnType<Page['getByRole']>): Promise<{
  379. readonly outer: readonly number[]
  380. readonly icon: readonly number[]
  381. readonly label: readonly number[]
  382. }> {
  383. return await locator.evaluate((element) => {
  384. const outer = element.getBoundingClientRect()
  385. const icon = element.children.item(0)?.getBoundingClientRect()
  386. const label = element.children.item(1)?.getBoundingClientRect()
  387. if (icon === undefined || label === undefined) throw new Error('connection indicator children missing')
  388. const rounded = (values: readonly number[]): readonly number[] => values.map(value => Math.round(value * 100) / 100)
  389. return {
  390. outer: rounded([outer.x, outer.y, outer.width, outer.height]),
  391. icon: rounded([icon.x - outer.x, icon.y - outer.y, icon.width, icon.height]),
  392. label: rounded([label.x - outer.x, label.y - outer.y, label.width, label.height]),
  393. }
  394. })
  395. }
  396. async function connectionIndicatorTextAlignment(
  397. locator: ReturnType<Page['getByRole']>,
  398. ): Promise<string> {
  399. return await locator.evaluate((element) => {
  400. const label = element.children.item(1)
  401. if (label === null) throw new Error('connection indicator label missing')
  402. return getComputedStyle(label).textAlign
  403. })
  404. }