feat(layout): OPEN-02a 内缩白浮条落地(px 令牌 + 195 张基线重采)
导航由全宽贴顶条改为内缩白浮条:top 48 / 高 64,左右对齐 container-x 的 gutter。 值走 px 令牌(--header-inset-top / --header-height),避免根字号 16/17/18px 导致 rem 漂移。 契约变化:新增 data-header-state="top|scrolled" 与浮条测试锚点;外壳仍 top-0, chrome-persistence 既有的「滚动后 top===0」断言保持不变,另加浮条 rect(48/64)断言; 移动抽屉起点改 calc(inset + height)。 基线:ADR-0012 预测 180 张,实测 195 张(32 页 × 5 + 主题首页 10 + 页头 5 + 元素级 20), 逐项归因后以 --update-snapshots=changed 写入;独立只读复跑 225 passed / 0 failed / EXIT=0(9.0 分钟)。 门禁:type-check / check:grammar 21/21 / check:motion / check:a11y 全绿,lint 0 error / 88 warning, test:unit 159 套件 / 1883 例,导航三 spec 52 passed / 8 skipped(skip 均既有条件)。 OPEN-02a 关闭;OPEN-02b(滚动收方汉堡)维持不做。
No files matched your search
@@ -202,3 +202,90 @@ test('能力 mega 面板在 1280x720 下不被裁切,或自身可滚', async (
|
||||
await expect(lastLink).toBeVisible({ timeout: 3000 });
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 内缩白浮条(ADR-0012 §4 / `OPEN-02a`)。
|
||||
*
|
||||
* 为什么断言 `getComputedStyle` 而不只读 `getBoundingClientRect`:
|
||||
* 本仓根字号随断点变 16/17/18px,若有人把 `--header-inset-top` 换回 `top-12`(3rem)、
|
||||
* 把高度换回 `h-16`(4rem),类名照样在、type-check 照样过,而实测会变成 48/51/54 与 64/68/72。
|
||||
* computed style 直接读解析后的 px,与视口/滚动无关。
|
||||
*
|
||||
* ⚠ 移动 project(`isMobile: true`)**不做** rect 断言:移动视口模拟下 `position: fixed`
|
||||
* 的 `getBoundingClientRect().top` 会随视觉视口偏移漂移(本轮实测同一用例连跑得到 0 / 48 / 139
|
||||
* 三个值),那是模拟层的量法噪声,不是产品缺陷。桌面 project 才断言「距顶 48 + 左右内缩」。
|
||||
*/
|
||||
test('页头是内缩浮条:padding-top 48px / 高 64px(px 令牌,不是 rem 漂移值)', async ({ page }, testInfo) => {
|
||||
const isMobileProject = testInfo.project.name.includes('mobile');
|
||||
|
||||
await page.goto('/', { waitUntil: 'domcontentloaded' });
|
||||
const wrap = page.locator('header > div').first();
|
||||
const bar = page.getByTestId('header-bar');
|
||||
await expect(bar).toBeVisible({ timeout: 15000 });
|
||||
|
||||
// ① 解析后的 px —— 这条同时钉住「token 被删/被换成 rem 档」两种腐化
|
||||
await expect
|
||||
.poll(() => wrap.evaluate((el) => getComputedStyle(el).paddingTop), { timeout: 15000 })
|
||||
.toBe('48px');
|
||||
await expect
|
||||
.poll(() => bar.evaluate((el) => getComputedStyle(el).height), { timeout: 15000 })
|
||||
.toBe('64px');
|
||||
|
||||
// ② 桌面档:距视口顶 48、自身高 64、左右内缩;滚动后不收起、不位移
|
||||
if (!isMobileProject) {
|
||||
await page.setViewportSize({ width: 1600, height: 900 });
|
||||
|
||||
// ⚠ 必须等入场动画交接(`data-content-ready=1`)后再量:`page-transition.tsx` 的
|
||||
// `will-change: transform` 会劫持 `fixed` 的包含块,此时滚动 600 ⇒ 浮条 top 读到
|
||||
// **48−600 = −552**(本用例首版实测就是这个值)。这与 §5.52 是同一个机理,
|
||||
// 既有两条用例已经在用这个交接标记,这里复用而不是新造锚点。
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => document.documentElement.getAttribute('data-content-ready')), { timeout: 15000 })
|
||||
.toBe('1');
|
||||
expect(
|
||||
await page.evaluate(() => {
|
||||
let n: Element | null = document.querySelector('header');
|
||||
while (n && n !== document.documentElement) {
|
||||
if (getComputedStyle(n).transform !== 'none') return getComputedStyle(n).transform;
|
||||
n = n.parentElement;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
'祖先链上仍有 transform,此时量 fixed 元素读到的是动画帧',
|
||||
).toBeNull();
|
||||
|
||||
const readBar = () =>
|
||||
bar.evaluate((el) => {
|
||||
const r = el.getBoundingClientRect();
|
||||
return {
|
||||
top: Math.round(r.top),
|
||||
height: Math.round(r.height),
|
||||
left: Math.round(r.left),
|
||||
right: Math.round(r.right),
|
||||
};
|
||||
});
|
||||
|
||||
await expect.poll(async () => (await readBar()).top, { timeout: 15000 }).toBe(48);
|
||||
const top = await readBar();
|
||||
expect(top.top, '浮条顶距必须是 48px').toBe(48);
|
||||
expect(top.height, '浮条高度必须是 64px').toBe(64);
|
||||
expect(top.left, '1600 视口下浮条必须内缩(左边界 > 0)').toBeGreaterThan(0);
|
||||
expect(top.right, '1600 视口下浮条必须内缩(右边界 < 视口宽)').toBeLessThan(1600);
|
||||
|
||||
await page.evaluate(() => {
|
||||
document.documentElement.style.scrollBehavior = 'auto';
|
||||
window.scrollTo(0, 600);
|
||||
});
|
||||
await expect.poll(() => page.evaluate(() => Math.round(window.scrollY)), { timeout: 5000 }).toBe(600);
|
||||
|
||||
const scrolled = await readBar();
|
||||
expect(scrolled.top, '滚动后浮条仍应在 48px').toBe(48);
|
||||
expect(scrolled.height, '滚动后浮条高度不变(02b「收成方汉堡」已判定不做)').toBe(64);
|
||||
await expect(page.locator('header'), '滚动后应切到 scrolled 状态').toHaveAttribute('data-header-state', 'scrolled');
|
||||
|
||||
// 外壳仍贴顶 —— chrome-persistence 既有断言的形态不变
|
||||
await expect
|
||||
.poll(() => page.evaluate(() => Math.round(document.querySelector('header')!.getBoundingClientRect().top)), { timeout: 5000 })
|
||||
.toBe(0);
|
||||
}
|
||||
});
|
||||
|
Before Width: | Height: | Size: 731 KiB After Width: | Height: | Size: 731 KiB |
|
Before Width: | Height: | Size: 550 KiB After Width: | Height: | Size: 551 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1005 B After Width: | Height: | Size: 1014 B |
|
Before Width: | Height: | Size: 346 KiB After Width: | Height: | Size: 346 KiB |
|
Before Width: | Height: | Size: 335 KiB After Width: | Height: | Size: 336 KiB |
|
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 154 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
|
Before Width: | Height: | Size: 325 KiB After Width: | Height: | Size: 326 KiB |
|
Before Width: | Height: | Size: 496 KiB After Width: | Height: | Size: 494 KiB |
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 552 KiB After Width: | Height: | Size: 552 KiB |
|
Before Width: | Height: | Size: 591 KiB After Width: | Height: | Size: 592 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 604 KiB After Width: | Height: | Size: 605 KiB |
|
Before Width: | Height: | Size: 629 KiB After Width: | Height: | Size: 629 KiB |
|
Before Width: | Height: | Size: 626 KiB After Width: | Height: | Size: 625 KiB |
|
Before Width: | Height: | Size: 728 KiB After Width: | Height: | Size: 729 KiB |
|
Before Width: | Height: | Size: 542 KiB After Width: | Height: | Size: 543 KiB |
|
Before Width: | Height: | Size: 688 KiB After Width: | Height: | Size: 688 KiB |
|
Before Width: | Height: | Size: 697 KiB After Width: | Height: | Size: 698 KiB |
|
Before Width: | Height: | Size: 752 KiB After Width: | Height: | Size: 753 KiB |
|
Before Width: | Height: | Size: 609 KiB After Width: | Height: | Size: 610 KiB |
|
Before Width: | Height: | Size: 592 KiB After Width: | Height: | Size: 593 KiB |
|
Before Width: | Height: | Size: 595 KiB After Width: | Height: | Size: 595 KiB |
|
Before Width: | Height: | Size: 588 KiB After Width: | Height: | Size: 588 KiB |
|
Before Width: | Height: | Size: 650 KiB After Width: | Height: | Size: 650 KiB |
|
Before Width: | Height: | Size: 768 KiB After Width: | Height: | Size: 768 KiB |
|
Before Width: | Height: | Size: 790 KiB After Width: | Height: | Size: 790 KiB |
|
Before Width: | Height: | Size: 771 KiB After Width: | Height: | Size: 772 KiB |
|
Before Width: | Height: | Size: 781 KiB After Width: | Height: | Size: 782 KiB |
|
Before Width: | Height: | Size: 788 KiB After Width: | Height: | Size: 787 KiB |
|
Before Width: | Height: | Size: 790 KiB After Width: | Height: | Size: 790 KiB |
|
Before Width: | Height: | Size: 522 KiB After Width: | Height: | Size: 523 KiB |
|
Before Width: | Height: | Size: 623 KiB After Width: | Height: | Size: 624 KiB |
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
|
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 2.2 MiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 608 KiB After Width: | Height: | Size: 605 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 12 MiB After Width: | Height: | Size: 12 MiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
|
Before Width: | Height: | Size: 2.9 MiB After Width: | Height: | Size: 3.0 MiB |
|
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 2.7 MiB After Width: | Height: | Size: 2.7 MiB |
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 2.4 MiB After Width: | Height: | Size: 2.4 MiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
|
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 2.2 MiB |
|
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 2.2 MiB |
|
Before Width: | Height: | Size: 2.4 MiB After Width: | Height: | Size: 2.4 MiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
|
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 1.9 MiB After Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 12 MiB After Width: | Height: | Size: 12 MiB |
|
Before Width: | Height: | Size: 12 MiB After Width: | Height: | Size: 12 MiB |
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 932 KiB After Width: | Height: | Size: 935 KiB |
|
Before Width: | Height: | Size: 939 KiB After Width: | Height: | Size: 942 KiB |
|
Before Width: | Height: | Size: 435 KiB After Width: | Height: | Size: 441 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 6.0 MiB After Width: | Height: | Size: 6.0 MiB |
|
Before Width: | Height: | Size: 847 KiB After Width: | Height: | Size: 852 KiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 3.2 MiB After Width: | Height: | Size: 3.2 MiB |
|
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
|
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |