test(visual): 首页缺 data-cms-state 时判红,避免守卫退化成死判据 #60
@@ -112,10 +112,17 @@ async function waitForRevealsSettled(page: Page) {
|
|||||||
/**
|
/**
|
||||||
* 首页把 CMS 读数状态写在 `data-cms-state` 上。退化时页面照常 200、只是整套落到常量版式,
|
* 首页把 CMS 读数状态写在 `data-cms-state` 上。退化时页面照常 200、只是整套落到常量版式,
|
||||||
* 像素比对只会给出一团无从归因的差异 —— 在这里先按名字判一次。
|
* 像素比对只会给出一团无从归因的差异 —— 在这里先按名字判一次。
|
||||||
|
* 首页**必须有**这个标记:标记消失(改坏 prop / 改回旧组件)时不能静默放行,
|
||||||
|
* 否则这条守卫会退化成永不生效的死判据。其它页面不标,跳过。
|
||||||
*/
|
*/
|
||||||
async function assertCmsStateOk(page: Page) {
|
async function assertCmsStateOk(page: Page) {
|
||||||
|
const isHome = new URL(page.url()).pathname === '/';
|
||||||
|
if (!isHome) return;
|
||||||
|
|
||||||
const marker = page.locator('main [data-cms-state]').first();
|
const marker = page.locator('main [data-cms-state]').first();
|
||||||
if ((await marker.count()) === 0) return;
|
if ((await marker.count()) === 0) {
|
||||||
|
throw new Error('首页缺少 data-cms-state 标记:CMS 退化守卫已失效(见 lessons §5.51)');
|
||||||
|
}
|
||||||
const state = await marker.getAttribute('data-cms-state');
|
const state = await marker.getAttribute('data-cms-state');
|
||||||
if (state !== 'ok') {
|
if (state !== 'ok') {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
Reference in new issue
Block a user