等待后端更新接口
This commit is contained in:
@@ -74,7 +74,7 @@ test('站点资讯列表使用响应 ID 生成详情链接并隐藏内部字段'
|
||||
assert.match(html, /<script>/);
|
||||
assert.match(html, /<img src=x>/);
|
||||
assert.doesNotMatch(html, /<script|<img|secret-oss|secret-remark|coverOssId|sortOrder|status|remark/);
|
||||
assert.match(SiteNewsPages.renderArticleList([]), /当前暂无资讯/);
|
||||
assert.equal(SiteNewsPages.renderArticleList([]), '');
|
||||
});
|
||||
|
||||
test('站点资讯详情转义正文、保留换行并只开放安全外链', () => {
|
||||
@@ -159,19 +159,36 @@ test('详情 URL 只读取安全字符串文章 ID', () => {
|
||||
assert.equal(SiteNewsPages.readArticleId(''), '');
|
||||
});
|
||||
|
||||
test('资讯列表和详情将加载、空数据、失败及无权限写入统一状态组件', () => {
|
||||
const source = fs.readFileSync(path.resolve(__dirname, '../public/js/site-news-pages.js'), 'utf8');
|
||||
|
||||
assert.equal(SiteNewsPages.isForbidden({ status: 403 }), true);
|
||||
assert.equal(SiteNewsPages.isForbidden({ status: 401 }), false);
|
||||
assert.equal(SiteNewsPages.isMissingArticleError(new Error('资讯不存在或已下线')), true);
|
||||
assert.match(source, /root\.ProfileUI && root\.ProfileUI\.setApiState/);
|
||||
assert.match(source, /setSiteState\(list, 'loading', '正在读取资讯…'\)/);
|
||||
assert.match(source, /setSiteState\(detail, 'loading', '正在读取资讯详情…'\)/);
|
||||
assert.match(source, /isForbidden\(error\) \? 'forbidden' : 'error'/);
|
||||
assert.match(source, /isForbidden\(error\) \? 'forbidden' : \(isMissingArticleError\(error\) \? 'empty' : 'error'\)/);
|
||||
});
|
||||
|
||||
test('官网资讯列表与详情页加载同一个公开内容 owner 且不暴露业务 ID', () => {
|
||||
assert.match(newsPage, /<body[^>]*data-site-news-page/);
|
||||
assert.match(newsPage, /data-site-news-list/);
|
||||
assert.match(newsPage, /data-site-news-status/);
|
||||
assert.match(newsPage, /data-site-news-status[^>]*role="status"/);
|
||||
assert.match(newsPage, /data-api-state="loading"/);
|
||||
assert.match(newsPage, /news\.html\?articleType=news/);
|
||||
assert.match(newsPage, /news\.html\?articleType=notice/);
|
||||
assert.match(newsPage, /news\.html\?articleType=download/);
|
||||
assert.match(newsPage, /src="public\/js\/site-news-pages\.js"/);
|
||||
assert.match(newsPage, /src="public\/js\/profile-common\.js"/);
|
||||
|
||||
assert.match(detailPage, /<body[^>]*data-site-article-page/);
|
||||
assert.match(detailPage, /<title>资讯详情 - 代代相传<\/title>/);
|
||||
assert.match(detailPage, /data-site-article-detail/);
|
||||
assert.match(detailPage, /data-site-article-status/);
|
||||
assert.match(detailPage, /data-site-article-status[^>]*role="status"/);
|
||||
assert.match(detailPage, /data-api-state="loading"/);
|
||||
assert.match(detailPage, /src="public\/js\/profile-common\.js"/);
|
||||
assert.match(detailPage, /src="public\/js\/site-news-pages\.js"/);
|
||||
assert.doesNotMatch(detailPage, /src="public\/js\/article-pages\.js"/);
|
||||
assert.doesNotMatch(detailPage, /href="article-detail\.html"/);
|
||||
|
||||
Reference in New Issue
Block a user