import test from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs'; import path from 'node:path'; const MP_ROOT = path.resolve('m:/2026项目/CRMmp/mpuniapp'); const articlesUtsPath = path.join(MP_ROOT, 'pages/owner/card/useCardArticles.uts'); test('1. useCardArticles.uts 文件必须存在且格式完整', () => { assert.ok(fs.existsSync(articlesUtsPath), '必须存在 useCardArticles.uts'); const content = fs.readFileSync(articlesUtsPath, 'utf-8'); assert.ok(content.includes('export function createArticlesState'), '必须导出 createArticlesState'); assert.ok(content.includes('export function extractArticleSummary'), '必须导出 extractArticleSummary'); assert.ok(content.includes('export function validateArticleForm'), '必须导出 validateArticleForm'); assert.ok(content.includes('export async function loadArticles'), '必须导出 loadArticles'); assert.ok(content.includes('export async function saveArticle'), '必须导出 saveArticle'); assert.ok(content.includes('export async function toggleArticlePublish'), '必须导出 toggleArticlePublish'); assert.ok(content.includes('export async function deleteArticle'), '必须导出 deleteArticle'); }); test('2. 摘要提取器必须支持剥离 Markdown 与 HTML 语法', () => { const content = fs.readFileSync(articlesUtsPath, 'utf-8'); assert.ok(content.includes('.replace(/<[^>]+>/g, \'\')'), '必须剥离 HTML 标签'); assert.ok(content.includes('.replace(/!\\[.*?\\]\\(.*?\\)/g, \'\')'), '必须剥离 Markdown 图片'); }); test('3. 文章表单校验逻辑实现规范', () => { const content = fs.readFileSync(articlesUtsPath, 'utf-8'); assert.ok(content.includes("title === ''"), '必须拦截空标题'); assert.ok(content.includes("content === ''"), '必须拦截空正文'); }); test('4. 必须通过 Cool-Admin 标准 CRUD 契约对接后端接口', () => { const content = fs.readFileSync(articlesUtsPath, 'utf-8'); assert.ok(content.includes('fetchCardArticlesPage'), '必须调用 fetchCardArticlesPage'); assert.ok(content.includes('addCardArticle'), '必须调用 addCardArticle'); assert.ok(content.includes('updateCardArticle'), '必须调用 updateCardArticle'); assert.ok(content.includes('deleteCardArticle'), '必须调用 deleteCardArticle'); }); test('5. 国际化与文案键完整覆盖', () => { const content = fs.readFileSync(articlesUtsPath, 'utf-8'); assert.ok(content.includes('resolveArticlesText'), '必须实现文案解析'); assert.ok(content.includes('Insights & Articles'), '必须支持英文标题'); assert.ok(content.includes('文章与商务动态'), '必须支持中文标题'); });