Files
jiapu/tests/public-static-pages.test.js
T
fizzleaf 309598bfa6 feat(api): 添加帮助中心反馈系统和VIP服务功能
- 在ApiClient中新增submitFeedback、myFeedback、helpArticles、helpArticleDetail、
  siteArticles、promotions、vipPackages、createVipOrder、vipOrders等方法
- 添加帮助文章和站点资讯的参数验证逻辑
- 更新测试文件添加新的API方法测试用例
- 在HTML页面中添加反馈、帮助和VIP服务相关页面的脚本引用
- 更新加入家谱页面为完整的申请流程界面
- 修改资讯详情页面为站点资讯展示页面
- 更新AxiosRequestUtil中认证处理逻辑
- 添加世系树渲染的HTML生成函数用于页面复用
- 更新文档中的API契约说明和页面规划
2026-07-30 16:04:48 +08:00

87 lines
2.7 KiB
JavaScript

const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const test = require('node:test');
const root = path.resolve(__dirname, '..');
const staticPages = [
'news.html',
'privacy.html',
'children-privacy.html',
'terms.html',
'not-found.html',
'forbidden.html',
'maintenance.html',
'my-tickets.html',
'ticket-detail.html'
];
function read(relativePath) {
return fs.readFileSync(path.join(root, relativePath), 'utf8');
}
function exists(relativePath) {
return fs.existsSync(path.join(root, relativePath));
}
function localHrefs(source) {
return Array.from(source.matchAll(/\shref="([^"]+)"/g))
.map((match) => match[1])
.filter((href) => href && !href.startsWith('#') && !/^(?:https?:|mailto:|tel:)/i.test(href))
.map((href) => href.split('#')[0].split('?')[0]);
}
test('官网静态信息页面均有独立入口', () => {
staticPages.forEach((page) => {
assert.equal(exists(page), true, `${page} 不存在`);
});
});
test('新闻页提供真实 PC 文章分类与详情入口', () => {
if (!exists('news.html')) return;
const source = read('news.html');
assert.match(source, /href="news\.html"/);
assert.match(source, /href="news\.html\?articleType=news"/);
assert.match(source, /href="news\.html\?articleType=notice"/);
assert.match(source, /href="news\.html\?articleType=download"/);
assert.match(source, /data-site-news-list/);
assert.match(source, /src="public\/js\/site-news-pages\.js"/);
});
test('法律页面明确等待法务确认', () => {
['privacy.html', 'children-privacy.html', 'terms.html'].forEach((page) => {
if (!exists(page)) return;
assert.match(read(page), /待法务确认/);
});
});
test('工单功能入口开放真实反馈记录并保留帮助中心跳转', () => {
['submit-ticket.html', 'my-tickets.html', 'ticket-detail.html'].forEach((page) => {
if (!exists(page)) return;
const source = read(page);
assert.doesNotMatch(source, /data-feature-status="pending"|pending-pages\.js/);
assert.match(source, /src="public\/js\/feedback-pages\.js"/);
assert.match(source, /href="help\.html"/);
});
});
test('新增静态页面的本地跳转均有目标文件', () => {
staticPages.forEach((page) => {
if (!exists(page)) return;
localHrefs(read(page)).forEach((href) => {
assert.equal(exists(href), true, `${page} 指向不存在的 ${href}`);
});
});
});
test('首页提供新闻和法律文档入口', () => {
const source = read('index.html');
assert.match(source, /href="news\.html"/);
assert.match(source, /href="privacy\.html"/);
assert.match(source, /href="children-privacy\.html"/);
assert.match(source, /href="terms\.html"/);
});