41 lines
1.6 KiB
TypeScript
41 lines
1.6 KiB
TypeScript
describe('标准模型软删除同步回归测试', () => {
|
|
test('单条素材软删除时应同步软删除 materialSku', async () => {
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
const filePath = path.join(process.cwd(), 'app/api/materials/route.ts')
|
|
const content = fs.readFileSync(filePath, 'utf-8')
|
|
|
|
expect(content).toContain('prisma.materialSku.updateMany')
|
|
expect(content).toContain('materialId: id')
|
|
expect(content).toContain('data: { deletedAt }')
|
|
})
|
|
|
|
test('批量软删除时应同步软删除 materialSku', async () => {
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
const filePath = path.join(process.cwd(), 'app/api/admin/materials/batch-delete/route.ts')
|
|
const content = fs.readFileSync(filePath, 'utf-8')
|
|
|
|
expect(content).toContain('prisma.materialSku.updateMany')
|
|
expect(content).toContain('materialId: { in: materials.map((m) => m.id) }')
|
|
expect(content).toContain('data: {')
|
|
expect(content).toContain('deletedAt,')
|
|
})
|
|
|
|
test('恢复素材时应恢复 materialSku 并校验活动标准模型 SKU 冲突', async () => {
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
|
|
const filePath = path.join(process.cwd(), 'app/api/materials/restore/route.ts')
|
|
const content = fs.readFileSync(filePath, 'utf-8')
|
|
|
|
expect(content).toContain("material.materialType === '标准模型'")
|
|
expect(content).toContain('恢复失败:以下 SKU 已被其他标准模型占用:')
|
|
expect(content).toContain('prisma.materialSku.updateMany')
|
|
expect(content).toContain('materialType: \'标准模型\'')
|
|
expect(content).toContain('deletedAt: null')
|
|
})
|
|
})
|