feat(edit): 编辑页上报ozon 开发

This commit is contained in:
R524809
2026-09-30 15:57:54 +08:00
parent 0a303414d8
commit 45871584b3
48 changed files with 3700 additions and 887 deletions
+115 -2
View File
@@ -2129,7 +2129,7 @@ describe('商品编辑 M3.0–M3.3 HTTP 集成测试', () => {
);
});
it('俄文发布标题为空时发布就绪校验提示必填,填写后移除提示', async () => {
it('俄文标题按通用或逐 SKU 模式校验,并持久保存切换结果', async () => {
await database.workspaceTransaction(workspaceId, async (tx) => {
const store = await tx.query<{ id: string }>(
`SELECT id FROM atlas.stores
@@ -2148,7 +2148,7 @@ describe('商品编辑 M3.0–M3.3 HTTP 集成测试', () => {
[platformId, `editor-title-${randomUUID()}`],
);
});
const created = await createCollectionItem('俄文发布标题校验商品');
const created = await createCollectionItem('俄文标题校验商品');
const entered = await request(
`/api/collection-items/${created.collectionItemId}/editor-contexts`,
{
@@ -2189,6 +2189,119 @@ describe('商品编辑 M3.0–M3.3 HTTP 集成测试', () => {
(issue: { code: string }) => issue.code === 'PUBLISH_TITLE_REQUIRED',
),
);
const beforeModeSwitch = await request(`/api/products/${created.productId}/editor`, {
headers: headers({ 'X-Atlas-Platform-Id': platformId }),
});
const snapshot = beforeModeSwitch.body.data;
assert.equal(snapshot.profile.title_mode, 'common');
const draft = {
ai_source_material: snapshot.source_material,
ai_source_overridden_fields: snapshot.source_material_state.overridden_fields,
common: {
...snapshot.product.common,
default_physical_spec: snapshot.product.default_physical_spec,
default_package_spec: snapshot.product.default_package_spec,
},
profile: {
target_store_id: snapshot.profile.target_store.id,
fulfillment: snapshot.profile.fulfillment,
title: null as string | null,
title_mode: 'variant',
description: snapshot.profile.description,
tags: snapshot.profile.tags,
platform_product_category_id: snapshot.profile.category.id,
category_source: snapshot.profile.category.source,
},
variants: snapshot.variants.map((variant: any) => ({
id: variant.id,
client_key: null,
display_name: variant.display_name,
source_sku: variant.source_sku,
specification_values: variant.specification_values,
purchase_cost_cny: variant.purchase_cost_cny,
title: null,
tags: variant.tags,
description: variant.description,
physical_spec: variant.physical_spec,
package_spec: variant.package_spec,
offer_id: variant.listing.offer_id,
media_asset_ids: variant.media.map((item: { asset_id: string }) => item.asset_id),
})),
};
const saveTitleMode = async (body: typeof draft, productRevision: number, profileRevision: number) =>
request(`/api/products/${created.productId}/editor-draft`, {
method: 'PUT',
headers: headers({
'X-Atlas-Platform-Id': platformId,
'Idempotency-Key': randomUUID(),
'If-Match': `"${productRevision}:${profileRevision}"`,
}),
body: JSON.stringify(body),
});
const variantMode = await saveTitleMode(
draft,
snapshot.product.revision,
snapshot.profile.revision,
);
assert.equal(variantMode.response.status, 200, JSON.stringify(variantMode.body));
const blankVariant = await request(
`/api/product-platform-profiles/${profileId}/validation`,
{ headers: headers({ 'X-Atlas-Platform-Id': platformId }) },
);
assert.ok(
!blankVariant.body.data.profile.issues.some(
(issue: { code: string }) => issue.code === 'PUBLISH_TITLE_REQUIRED',
),
);
assert.ok(
blankVariant.body.data.variants[0].issues.some(
(issue: { code: string; field: string }) =>
issue.code === 'PUBLISH_TITLE_REQUIRED' &&
issue.field === `variants.${snapshot.variants[0].id}.title`,
),
);
const afterVariantMode = await request(`/api/products/${created.productId}/editor`, {
headers: headers({ 'X-Atlas-Platform-Id': platformId }),
});
assert.equal(afterVariantMode.body.data.profile.title_mode, 'variant');
assert.equal(afterVariantMode.body.data.profile.title, null);
const filledVariant = await saveTitleMode(
{
...draft,
variants: [{ ...draft.variants[0], title: 'Название SKU' }],
},
afterVariantMode.body.data.product.revision,
afterVariantMode.body.data.profile.revision,
);
assert.equal(filledVariant.response.status, 200, JSON.stringify(filledVariant.body));
const readyTitle = await request(
`/api/product-platform-profiles/${profileId}/validation`,
{ headers: headers({ 'X-Atlas-Platform-Id': platformId }) },
);
assert.ok(
!readyTitle.body.data.variants[0].issues.some(
(issue: { code: string }) => issue.code === 'PUBLISH_TITLE_REQUIRED',
),
);
const afterFilledVariant = await request(`/api/products/${created.productId}/editor`, {
headers: headers({ 'X-Atlas-Platform-Id': platformId }),
});
const commonMode = await saveTitleMode(
{
...draft,
profile: { ...draft.profile, title: '通用俄文标题', title_mode: 'common' },
variants: [{ ...draft.variants[0], title: null }],
},
afterFilledVariant.body.data.product.revision,
afterFilledVariant.body.data.profile.revision,
);
assert.equal(commonMode.response.status, 200, JSON.stringify(commonMode.body));
const afterCommonMode = await request(`/api/products/${created.productId}/editor`, {
headers: headers({ 'X-Atlas-Platform-Id': platformId }),
});
assert.equal(afterCommonMode.body.data.profile.title_mode, 'common');
assert.equal(afterCommonMode.body.data.variants[0].title, null);
});
it('包装重量模式独立保存,并允许 SKU 已确认重量继承通用尺寸', async () => {