feat(goods): add editable custom products
This commit is contained in:
@@ -119,6 +119,51 @@ describe('GoodsService', () => {
|
||||
expect(fetched.goodName).toBe(`Goods Test ${stamp} basic`);
|
||||
});
|
||||
|
||||
it('creates, edits, and removes a fully editable custom good', async () => {
|
||||
const created = await service.createCustom({
|
||||
goodName: `Goods Test ${stamp} custom`,
|
||||
goodImage: 'https://example.com/custom.png',
|
||||
goodPrice: '29.90',
|
||||
countryId: Number(countryId),
|
||||
categoryId: Number(categoryId),
|
||||
tagIds: [Number(tagId)],
|
||||
detail: {
|
||||
productCode: `CUSTOM-${stamp}`,
|
||||
materialDescription: 'Cotton',
|
||||
sizeChart: { columns: [], rows: [] },
|
||||
packageSpecs: { rows: [] },
|
||||
},
|
||||
variants: [
|
||||
{ sku: `CUSTOM-SKU-${stamp}`, sizeName: 'S', price: '29.90' },
|
||||
],
|
||||
});
|
||||
|
||||
expect(created.originGood?.source).toBe('CUSTOM');
|
||||
expect(created.originGood?.isCustom).toBe(true);
|
||||
expect(created.originGood?.goodPrice).toBe('29.9');
|
||||
expect(created.variants).toHaveLength(1);
|
||||
|
||||
const updated = await service.updateCustomContent(BigInt(created.id), {
|
||||
goodName: `Goods Test ${stamp} custom edited`,
|
||||
goodPrice: '39.90',
|
||||
detail: { materialDescription: 'Organic cotton' },
|
||||
variants: [
|
||||
{ sku: `CUSTOM-SKU-${stamp}-M`, sizeName: 'M', price: '39.90' },
|
||||
],
|
||||
});
|
||||
expect(updated.goodName).toContain('custom edited');
|
||||
expect(updated.originGood?.goodPrice).toBe('39.9');
|
||||
expect(updated.originDetail?.materialDescription).toBe('Organic cotton');
|
||||
expect(updated.originDetail?.productCode).toBe(`CUSTOM-${stamp}`);
|
||||
expect(updated.variants[0]?.sizeName).toBe('M');
|
||||
|
||||
const customOriginId = BigInt(updated.originGoodId);
|
||||
await service.remove(BigInt(updated.id));
|
||||
await expect(
|
||||
prisma.originGood.findUnique({ where: { id: customOriginId } }),
|
||||
).resolves.toBeNull();
|
||||
});
|
||||
|
||||
it('filters by countryId, tagId, positionId and keyword', async () => {
|
||||
const result = await service.findAll({
|
||||
page: 1,
|
||||
|
||||
Reference in New Issue
Block a user