37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
/**
|
|
* 标准模型清理回归测试
|
|
*
|
|
* 目的:防止素材永久删除时遗漏已软删除 SKU 的文件。
|
|
*/
|
|
|
|
describe('标准模型清理覆盖测试', () => {
|
|
test('collectMaterialFiles 查询标准模型 SKU 时不应过滤 deletedAt', 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 standardModelBlockMatch = content.match(/if \(materialType === '标准模型'\)[\s\S]*?relatedRecords\.assets = whiteBgAssets\.length;/)
|
|
expect(standardModelBlockMatch).not.toBeNull()
|
|
if (!standardModelBlockMatch) {
|
|
throw new Error('未找到标准模型清理代码块')
|
|
}
|
|
|
|
const standardModelBlock = standardModelBlockMatch[0]
|
|
expect(standardModelBlock).toContain('materialId')
|
|
expect(standardModelBlock).not.toContain('deletedAt: null')
|
|
})
|
|
|
|
test('白底图资产清理应同时覆盖旧键与SKU级新键', async () => {
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
const filePath = path.join(__dirname, '../material-cleanup.ts')
|
|
const content = fs.readFileSync(filePath, 'utf-8')
|
|
|
|
expect(content).toContain("assetType: 'standard-model-white-bg-zip'")
|
|
expect(content).toContain("assetType: { startsWith: 'standard-model-white-bg-zip:' }")
|
|
})
|
|
})
|