test(sw): count only the visible home menu row in the Figma geometry check
The measured More adds a hidden measure row and a More section, so the geometry check counted 11 sections / 31 tiles / 45 icons instead of 5 / 15 / 30.
This commit is contained in:
1 parent
170a5c23ae
commit
cc9b2834db
1 file changed
+6
-4
@@ -45,14 +45,16 @@ const geometry = await page.evaluate(() => {
|
|||||||
const header = document.querySelector('.hm-sw-header').getBoundingClientRect()
|
const header = document.querySelector('.hm-sw-header').getBoundingClientRect()
|
||||||
const m = document.querySelector('.hm-sw-home-menu').getBoundingClientRect()
|
const m = document.querySelector('.hm-sw-home-menu').getBoundingClientRect()
|
||||||
const r = e => e.getBoundingClientRect()
|
const r = e => e.getBoundingClientRect()
|
||||||
const tiles = [...document.querySelectorAll('.hm-sw-home-menu__item')].map(r)
|
// 2026-10-19: only the visible row; the hidden measure row and the More section also render sections / tiles.
|
||||||
|
const row = [...document.querySelectorAll('.hm-sw-home-menu__sections > .hm-sw-home-menu__section:not(.hm-sw-home-menu__more)')]
|
||||||
|
const tiles = row.flatMap(s => [...s.querySelectorAll('.hm-sw-home-menu__item')]).map(r)
|
||||||
const badge = getComputedStyle(document.querySelector('.hm-sw-home-menu')).getPropertyValue('--hm-sw-home-menu-title-art')
|
const badge = getComputedStyle(document.querySelector('.hm-sw-home-menu')).getPropertyValue('--hm-sw-home-menu-title-art')
|
||||||
const icons = [...document.querySelectorAll('.hm-sw-home-menu__icon img')]
|
const icons = row.flatMap(s => [...s.querySelectorAll('.hm-sw-home-menu__icon img')])
|
||||||
return {
|
return {
|
||||||
left: m.left - header.left, width: m.width, height: m.height, headerHeight: header.height,
|
left: m.left - header.left, width: m.width, height: m.height, headerHeight: header.height,
|
||||||
sections: [...document.querySelectorAll('.hm-sw-home-menu__section')].map(e => Math.round(r(e).width)),
|
sections: row.map(e => Math.round(r(e).width)),
|
||||||
tiles: tiles.length, tileSizes: [...new Set(tiles.map(t => `${Math.round(t.width)}x${Math.round(t.height)}`))],
|
tiles: tiles.length, tileSizes: [...new Set(tiles.map(t => `${Math.round(t.width)}x${Math.round(t.height)}`))],
|
||||||
titles: document.querySelectorAll('.hm-sw-home-menu__title').length,
|
titles: row.filter(s => s.querySelector('.hm-sw-home-menu__title')).length,
|
||||||
badgeInlined: badge.includes('data:image/svg+xml') || badge.includes('.svg'),
|
badgeInlined: badge.includes('data:image/svg+xml') || badge.includes('.svg'),
|
||||||
icons: icons.length, iconsLoaded: icons.filter(i => i.complete && i.naturalWidth > 0).length,
|
icons: icons.length, iconsLoaded: icons.filter(i => i.complete && i.naturalWidth > 0).length,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user