/** * 任务类轻量素材删除清理回归测试 * * 目的:确保任务-页面、任务-其他这类依赖 MaterialAsset 的任务素材 * 也会进入统一清理链路,避免预览图或压缩包残留。 */ describe('任务类轻量素材清理覆盖测试', () => { test('collectMaterialFiles 的任务类型列表应包含任务-页面和任务-其他', async () => { const fs = require('fs') const path = require('path') const filePath = path.join(__dirname, '../material-cleanup.ts') const content = fs.readFileSync(filePath, 'utf-8') const firstTaskTypeDecl = content.match(/const taskMaterialTypes = \[[^\]]+\];/) expect(firstTaskTypeDecl).not.toBeNull() if (!firstTaskTypeDecl) { throw new Error('未找到 collectMaterialFiles 的任务类型列表') } expect(firstTaskTypeDecl[0]).toContain("'任务-页面'") expect(firstTaskTypeDecl[0]).toContain("'任务-其他'") }) test('deleteMaterialRelatedRecords 的任务类型列表应包含任务-页面和任务-其他', async () => { const fs = require('fs') const path = require('path') const filePath = path.join(__dirname, '../material-cleanup.ts') const content = fs.readFileSync(filePath, 'utf-8') const allTaskTypeDecls = content.match(/const taskMaterialTypes = \[[^\]]+\];/g) expect(allTaskTypeDecls).not.toBeNull() if (!allTaskTypeDecls || allTaskTypeDecls.length < 2) { throw new Error('未找到 deleteMaterialRelatedRecords 的任务类型列表') } expect(allTaskTypeDecls[1]).toContain("'任务-页面'") expect(allTaskTypeDecls[1]).toContain("'任务-其他'") }) })