feat(edit|extension): 编辑页类目采集开发
This commit is contained in:
@@ -1355,13 +1355,19 @@ describe('商品编辑 M3.0–M3.3 HTTP 集成测试', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('M3.5 按 Ozon 采集层级回填空类目,且绝不覆盖已保存选择', async () => {
|
||||
it('M3.5 按 Ozon 一级类目和类型回填唯一候选,并返回多候选供确认', async () => {
|
||||
const suffix = randomUUID();
|
||||
const root = await seedStoreCategory(
|
||||
`m35-root-${suffix}`,
|
||||
'0',
|
||||
'M3.5 来源',
|
||||
'M3.5 来源',
|
||||
);
|
||||
const captured = await seedStoreCategory(
|
||||
`m35-source-${suffix}`,
|
||||
'source-type',
|
||||
'M3.5 采集叶',
|
||||
'M3.5 来源 › M3.5 采集叶',
|
||||
'M3.5 类型',
|
||||
'M3.5 来源 › M3.5 类型',
|
||||
);
|
||||
const manual = await seedStoreCategory(
|
||||
`m35-manual-${suffix}`,
|
||||
@@ -1369,8 +1375,14 @@ describe('商品编辑 M3.0–M3.3 HTTP 集成测试', () => {
|
||||
'M3.5 手动叶',
|
||||
'M3.5 手动 › M3.5 手动叶',
|
||||
);
|
||||
seededCategoryIds.push(captured.id, manual.id);
|
||||
seededCategoryIds.push(root.id, captured.id, manual.id);
|
||||
await database.workspaceTransaction(workspaceId, async (tx) => {
|
||||
await tx.query(
|
||||
`UPDATE atlas.platform_product_categories
|
||||
SET parent_id = $1, source_payload = '{"type_name":"M3.5 类型"}'::jsonb
|
||||
WHERE id = $2`,
|
||||
[root.id, captured.id],
|
||||
);
|
||||
await tx.query(
|
||||
`UPDATE atlas.collection_items
|
||||
SET source_kind = 'platform', source_platform_id = $1,
|
||||
@@ -1382,7 +1394,9 @@ describe('商品编辑 M3.0–M3.3 HTTP 集成测试', () => {
|
||||
common: {
|
||||
categories: [
|
||||
{ key: 'source-root', name: ' M3.5 来源 ' },
|
||||
{ key: 'source-leaf', name: 'M3.5 采集叶' },
|
||||
],
|
||||
attributes: [
|
||||
{ key: 'ozon:Type_0', name: '类型', value: 'M3.5 类型' },
|
||||
],
|
||||
},
|
||||
}),
|
||||
@@ -1411,6 +1425,37 @@ describe('商品编辑 M3.0–M3.3 HTTP 集成测试', () => {
|
||||
'source_capture',
|
||||
);
|
||||
|
||||
const duplicate = await seedStoreCategory(
|
||||
`m35-duplicate-${suffix}`,
|
||||
'duplicate-type',
|
||||
'M3.5 类型',
|
||||
'M3.5 来源 › 另一分支 › M3.5 类型',
|
||||
);
|
||||
seededCategoryIds.push(duplicate.id);
|
||||
await database.workspaceTransaction(workspaceId, async (tx) => {
|
||||
await tx.query(
|
||||
`UPDATE atlas.platform_product_categories
|
||||
SET parent_id = $1, source_payload = '{"type_name":"M3.5 类型"}'::jsonb
|
||||
WHERE id = $2`,
|
||||
[root.id, duplicate.id],
|
||||
);
|
||||
await tx.query(
|
||||
`UPDATE atlas.product_platform_profiles
|
||||
SET platform_product_category_id = NULL, platform_type_id = NULL,
|
||||
category_source = NULL
|
||||
WHERE id = $1`,
|
||||
[first.profileId],
|
||||
);
|
||||
});
|
||||
const ambiguous = await request(
|
||||
`/api/products/${first.productId}/editor`,
|
||||
{ headers: headers({ 'X-Atlas-Platform-Id': platformId }) },
|
||||
);
|
||||
assert.equal(ambiguous.response.status, 200);
|
||||
assert.equal(ambiguous.body.data.profile.category.id, null);
|
||||
assert.equal(ambiguous.body.data.captured_category_match.status, 'ambiguous');
|
||||
assert.equal(ambiguous.body.data.captured_category_match.candidates.length, 2);
|
||||
|
||||
await database.workspaceTransaction(workspaceId, (tx) =>
|
||||
tx.query(
|
||||
`UPDATE atlas.product_platform_profiles
|
||||
|
||||
Reference in New Issue
Block a user