Skip to content

Commit e7d6a62

Browse files
committed
test: stabilize active chip sync assertion in catalog e2e
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent f100729 commit e7d6a62

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

playwright/e2e/policy-workbench-catalog-controls.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,10 @@ test('active category chip tracks the section with visible cards while scrolling
422422

423423
await expect.poll(async () => {
424424
return page.evaluate(() => {
425-
const topCutoff = 140
426-
const bottomCutoff = window.innerHeight
425+
const stickyNav = document.querySelector('.policy-workbench__category-nav-sticky') as HTMLElement | null
426+
const appContent = document.querySelector('#app-content') as HTMLElement | null
427+
const topCutoff = (stickyNav?.getBoundingClientRect().bottom ?? 140) + 12
428+
const bottomCutoff = appContent?.getBoundingClientRect().bottom ?? window.innerHeight
427429

428430
const sectionWithVisibleCard = Array.from(document.querySelectorAll('.policy-workbench__category-section')).find((section) => {
429431
const cards = Array.from(section.querySelectorAll<HTMLElement>('.policy-workbench__setting-tile, .policy-workbench__settings-row'))
@@ -439,14 +441,17 @@ test('active category chip tracks the section with visible cards while scrolling
439441
return {
440442
expectedSectionTitle,
441443
activeChipLabel,
444+
hasFullyVisibleCard: Boolean(expectedSectionTitle),
442445
isSynced: Boolean(expectedSectionTitle && activeChipLabel && expectedSectionTitle === activeChipLabel),
443446
}
444447
})
445-
}, { timeout: 10000 }).toMatchObject({ isSynced: true })
448+
}, { timeout: 10000 }).toMatchObject({ hasFullyVisibleCard: true, isSynced: true })
446449

447450
const syncResult = await page.evaluate(() => {
448-
const topCutoff = 140
449-
const bottomCutoff = window.innerHeight
451+
const stickyNav = document.querySelector('.policy-workbench__category-nav-sticky') as HTMLElement | null
452+
const appContent = document.querySelector('#app-content') as HTMLElement | null
453+
const topCutoff = (stickyNav?.getBoundingClientRect().bottom ?? 140) + 12
454+
const bottomCutoff = appContent?.getBoundingClientRect().bottom ?? window.innerHeight
450455

451456
const sectionWithVisibleCard = Array.from(document.querySelectorAll('.policy-workbench__category-section')).find((section) => {
452457
const cards = Array.from(section.querySelectorAll<HTMLElement>('.policy-workbench__setting-tile, .policy-workbench__settings-row'))

0 commit comments

Comments
 (0)