40 lines
1.6 KiB
TypeScript
40 lines
1.6 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('LEGACY_STANDARD_MODEL_WHITE_BG_ASSET_TYPE')
|
|
expect(content).toContain('LEGACY_STANDARD_MODEL_WHITE_BG_ASSET_TYPE_PREFIX')
|
|
expect(content).toContain('STANDARD_MODEL_WHITE_BG_ASSET_TYPE_PREFIX')
|
|
expect(content).toContain('STANDARD_MODEL_WHITE_BG_VIEW_ASSET_TYPE_PREFIX')
|
|
expect(content).toContain('STANDARD_MODEL_WHITE_BG_OTHER_ASSET_TYPE_PREFIX')
|
|
})
|
|
})
|