const assert = require('node:assert/strict'); const fs = require('node:fs'); const path = require('node:path'); const test = require('node:test'); const root = path.join(__dirname, '..'); function read(file) { return fs.readFileSync(path.join(root, file), 'utf8'); } test('内容发布页为全部家谱功能入口透传真实家谱上下文', () => { const page = read('profile-content.html'); assert.doesNotMatch(page, /data-feature-status="pending"|pending-pages\.js|最近内容加载中/); ['profile-article.html', 'profile-album.html', 'profile-video.html', 'profile-merit.html', 'profile-gift.html', 'profile-feed.html', 'profile-growth.html', 'profile-relative.html', 'profile-memo.html'].forEach((href) => { assert.match(page, new RegExp('href="' + href.replace('.', '\\.') + '"[^>]*data-genealogy-context-link'), `${href} 缺少家谱上下文透传`); }); }); test('家谱主页公开谱文、相册、视频、功德和祭祀活动入口并透传上下文', () => { const page = read('profile-family-home.html'); ['profile-article.html', 'profile-album.html', 'profile-video.html', 'profile-merit.html', 'profile-ceremony.html'].forEach((href) => { assert.match(page, new RegExp('href="' + href.replace('.', '\\.') + '"[^>]*data-genealogy-context-link'), `${href} 缺少家谱主页入口`); }); }); test('个人中心功能入口没有把家谱业务页当作无上下文普通链接', () => { const page = read('profile.html'); ['profile-article.html', 'profile-album.html', 'profile-video.html', 'profile-merit.html', 'profile-gift.html'].forEach((href) => { assert.match(page, new RegExp('href="' + href.replace('.', '\\.') + '"[^>]*data-genealogy-context-link'), `${href} 缺少个人中心上下文入口`); }); });