diff --git a/tests/e2e.mjs b/tests/e2e.mjs index cd68e18..1da05d9 100644 --- a/tests/e2e.mjs +++ b/tests/e2e.mjs @@ -89,16 +89,17 @@ await page.goto(BASE + '/opensource/', { waitUntil: 'networkidle' }); const osState = await page.evaluate(() => { const html = document.documentElement.outerHTML; return { - thirdParty: ['img.shields.io', 'readme-typing-svg', 'github-readme-stats', 'streak-stats', 'komarev'] + // 5j T2:streak/贡献蛇退役(信息并入热力图区),第三方图仍必须为零 + thirdParty: ['img.shields.io', 'readme-typing-svg', 'github-readme-stats', 'streak-stats', 'komarev', '/github-assets/'] .some((u) => html.includes(u)), typing: !!document.querySelector('[class*=typing]'), - board: document.querySelectorAll('.pf-card').length, - localAssets: [...document.querySelectorAll('img')].filter((i) => i.src.includes('/github-assets/')).length, + streakLine: /天连续|day streak/.test(html), + updated: html.includes('数据更新于'), }; }); -ok('5i·开源页零第三方外链图', !osState.thirdParty); +ok('5i·开源页零第三方外链图(含退役资产)', !osState.thirdParty); ok('5i·打字机动效存在', osState.typing); -ok('5i·数据板渲染', osState.board > 0 && osState.localAssets > 0, `cards=${osState.board} assets=${osState.localAssets}`); +ok('5j·连续贡献同源计算 + 更新时间标注', osState.streakLine && osState.updated); // 1) 明暗切换:按钮 + 状态持久 + t 键 const before = await page.getAttribute('html', 'data-theme'); @@ -193,11 +194,13 @@ const books = await page.evaluate(() => { return { total: all.length, open: all.filter((d) => d.hasAttribute('open')).length }; }); ok('书架 抽书行渲染', books.total >= 1, JSON.stringify(books)); +// 置顶书默认展开(C 设计):点击已展开的行是"收起",未展开的行是"抽开"—— +// 断言口径 = 行数不变、开合状态恰好翻转一次(2026-11-04 修:曾误点已展开的置顶行) +const openBefore = await page.evaluate(() => document.querySelectorAll('.book[open]').length); await page.locator('.book').first().locator('summary').click(); await page.waitForTimeout(250); -ok('书架 点击可抽开', (await page.locator('.book[open] .body').count()) === 1); -await page.locator('.book').first().locator('summary').click(); -await page.waitForTimeout(200); +const openAfter = await page.evaluate(() => document.querySelectorAll('.book[open]').length); +ok('书架 抽书开合翻转', Math.abs(openAfter - openBefore) === 1, `${openBefore}→${openAfter}`); // 4) 命令面板 + 搜索 await page.keyboard.press('Control+k');