test: verify imported projects through the virtualized sidebar (#19003)

This commit is contained in:
Neil
2026-09-06 19:14:42 -07:00
committed by GitHub
parent 4be1c01c42
commit b3acef218a
2 changed files with 29 additions and 1 deletions
@@ -0,0 +1,27 @@
import { expect, type Page } from '@stablyai/playwright-test'
export async function expectSidebarProjectVisible(page: Page, projectName: string): Promise<void> {
const sidebar = page.getByRole('listbox', { name: 'Worktrees', exact: true })
const label = sidebar.getByText(projectName, { exact: false }).first()
await sidebar.evaluate((element) => {
element.scrollTop = 0
element.dispatchEvent(new Event('scroll', { bubbles: true }))
})
await expect
.poll(
async () => {
if (await label.isVisible()) {
return true
}
// Virtualized project headers mount only as their scroll range enters the viewport.
await sidebar.evaluate((element) => {
element.scrollTop += Math.max(1, Math.floor(element.clientHeight * 0.8))
element.dispatchEvent(new Event('scroll', { bubbles: true }))
})
return false
},
{ message: `sidebar never rendered project ${projectName}`, intervals: [100] }
)
.toBe(true)
await expect(label).toBeVisible()
}
@@ -1,3 +1,4 @@
import { expectSidebarProjectVisible } from './helpers/sidebar-project-visibility'
import { openSidebarProjectDialog } from './helpers/sidebar-project-dialog'
import { rmSync } from 'node:fs'
import path from 'node:path'
@@ -727,7 +728,7 @@ async function runSelectedRuntimeAddJourney(
...fixture.nestedRepoPaths.map((repoPath) => path.basename(repoPath))
]) {
// Why: duplicate checkout names are disambiguated with a parent path.
await expect(client.page.getByText(projectName, { exact: false }).first()).toBeVisible()
await expectSidebarProjectVisible(client.page, projectName)
}
expect(await client.getDirectSshAttemptTargetIds()).toEqual([])
// Why: revealing the client must not leak into the HUB's window visibility.