修改功,现在补齐页面
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
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('新闻页提供分类与现有详情跳转', () => {
|
||||
if (!exists('news.html')) return;
|
||||
|
||||
const source = read('news.html');
|
||||
assert.match(source, /href="#platform"/);
|
||||
assert.match(source, /href="#culture"/);
|
||||
assert.match(source, /href="notice-detail\.html"/);
|
||||
assert.match(source, /href="article-detail\.html"/);
|
||||
});
|
||||
|
||||
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.match(source, /data-feature-status="pending"/);
|
||||
assert.match(source, /src="public\/js\/pending-pages\.js"/);
|
||||
assert.match(source, /href="help\.html"\s+data-feature-link="available"/);
|
||||
});
|
||||
});
|
||||
|
||||
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"/);
|
||||
});
|
||||
Reference in New Issue
Block a user