test(news-morning): align specs with global source template

Update worker and draft tests for degraded-page guard and expanded international sections.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
John
2026-09-18 07:28:10 +08:00
parent 31762be5ef
commit e71e397302
2 changed files with 10 additions and 7 deletions
+3 -1
View File
@@ -12,6 +12,8 @@ import {
const SAMPLE_HTML = `<!DOCTYPE html><html><body><h1>📰 每日新闻早报</h1></body></html>`;
const HEALTHY_TODAY_HTML = `${SAMPLE_HTML}${'<div class="card"><h3>条目</h3></div>'.repeat(8)}`;
function createPool() {
const rows = [];
return {
@@ -104,7 +106,7 @@ test('runOnce honors forceGenerateOnce even when today page exists', async () =>
const userId = 'user-news';
const publicDir = path.join(tmpRoot, PUBLISH_ROOT_DIR, userId, PUBLIC_ZONE_DIR);
fs.mkdirSync(publicDir, { recursive: true });
fs.writeFileSync(path.join(publicDir, 'daily-news-0911.html'), SAMPLE_HTML);
fs.writeFileSync(path.join(publicDir, 'daily-news-0911.html'), HEALTHY_TODAY_HTML);
const pool = createPool();
const service = createWechatNewsMorningDraftService(pool, {
+7 -6
View File
@@ -164,8 +164,8 @@ test('news morning draft service persists config and records failed push', async
const preview = await service.preview({ now: Date.parse('2026-09-10T08:00:00+08:00') });
assert.equal(preview.page.slug, 'daily-news-0910');
assert.match(preview.template.spec, /0910|2026-09-10/u);
assert.match(preview.template.spec, /禁止复制/u);
assert.match(preview.template.spec, /0915|global|Google/u);
assert.match(preview.template.spec, /禁止复制|禁止用历史 daily-news/u);
await assert.rejects(
() => service.pushDraft({
@@ -212,10 +212,11 @@ test('buildNewsMorningAutoGenerationTask requires fresh daily search', () => {
assert.match(task.taskSpec, /禁止复制/u);
assert.match(task.taskSpec, /tkmind_search/u);
assert.match(task.taskSpec, /web_search/u);
assert.match(task.taskSpec, /国内热点/u);
assert.match(task.taskSpec, /国际热点/u);
assert.match(task.taskSpec, /热门事件/u);
assert.match(task.taskSpec, /热门旅游城市/u);
assert.match(task.taskSpec, /国内/u);
assert.match(task.taskSpec, /国际/u);
assert.match(task.taskSpec, /Google/u);
assert.match(task.taskSpec, /全球高校/u);
assert.match(task.taskSpec, /全球股市/u);
assert.match(task.taskSpec, /2026-09-15/u);
assert.match(task.taskSpec, /daily-news-0915\.html/u);
assert.doesNotMatch(task.taskSpec, /可以用昨日正文/u);