fix(intake): show successful inventory channel exclusively
Hide the other inventory channel once either warehouse or fixed inventory has succeeded. Keep unresolved statuses visible when neither has succeeded.
This commit is contained in:
parent
4f7ad254c9
commit
efcba62d3b
@ -42,16 +42,16 @@ describe("ProductPricingWorkspace", () => {
|
||||
{ source: "draft_group_modular_sku" },
|
||||
{ source: "draft_group", skuCode: "MKH-001", componentDetails: [{ code: "CHILD-001", name: "子商品", quantity: "1", role: "", assetType: "" }] },
|
||||
])("does not flag combination-only rows as missing inventory: %j", (overrides) => {
|
||||
const row = createPricingRow({ ...overrides, jstVirtualInventoryStatus: undefined, jstVirtualInventoryError: "" });
|
||||
const row = createPricingRow({ ...overrides, jstVirtualInventoryStatus: undefined, jstVirtualInventoryError: "", fixedVirtualInventoryStatus: undefined });
|
||||
render(<ProductPricingInventoryStatuses row={row} />);
|
||||
expect(screen.getByText("仓库无需库存")).toHaveAttribute("title", "组合商品不单独推送库存,库存由子商品承担");
|
||||
expect(screen.queryByText("仓库库存无记录")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("flags a system-entered normal SKU without a warehouse inventory record", () => {
|
||||
render(<ProductPricingInventoryStatuses row={createPricingRow({ jstVirtualInventoryStatus: undefined, jstVirtualInventoryError: "" })} />);
|
||||
render(<ProductPricingInventoryStatuses row={createPricingRow({ jstVirtualInventoryStatus: undefined, jstVirtualInventoryError: "", fixedVirtualInventoryStatus: undefined })} />);
|
||||
expect(screen.getByText("仓库库存无记录")).toBeInTheDocument();
|
||||
expect(screen.getByText("简尚库存已推")).toBeInTheDocument();
|
||||
expect(screen.queryByLabelText("简尚固定虚拟库存")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("locks only the cost controls of system-entered SKU rows", () => {
|
||||
@ -109,7 +109,7 @@ describe("ProductPricingWorkspace", () => {
|
||||
expect(onUpdateRow).toHaveBeenCalledWith("sku-2", "costPrice", "67");
|
||||
});
|
||||
|
||||
it("shows warehouse failure and fixed inventory success independently", () => {
|
||||
it("shows only fixed inventory success when warehouse inventory failed", () => {
|
||||
const row = createPricingRow();
|
||||
|
||||
render(
|
||||
@ -133,10 +133,10 @@ describe("ProductPricingWorkspace", () => {
|
||||
"title",
|
||||
"固定虚拟库存已于 2026-08-10T09:00:01.000Z 推送",
|
||||
);
|
||||
expect(screen.getByText("仓库库存失败")).toHaveAttribute("title", "聚水潭未找到对应仓库");
|
||||
expect(screen.queryByLabelText("仓库虚拟库存")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows a fixed virtual inventory configuration failure as skipped", () => {
|
||||
it("hides the fixed configuration failure when warehouse inventory succeeded", () => {
|
||||
const row = createPricingRow({
|
||||
jstVirtualInventoryStatus: "pushed",
|
||||
jstVirtualInventoryError: "",
|
||||
@ -162,21 +162,30 @@ describe("ProductPricingWorkspace", () => {
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.getByText("简尚库存已跳过")).toHaveAttribute(
|
||||
"title",
|
||||
"code=100,未开通了分仓虚拟库存!",
|
||||
);
|
||||
expect(screen.queryByText("库存重试中")).not.toBeInTheDocument();
|
||||
expect(screen.queryByText("库存已推")).not.toBeInTheDocument();
|
||||
expect(screen.queryByLabelText("简尚固定虚拟库存")).not.toBeInTheDocument();
|
||||
expect(screen.queryByTitle("code=100,未开通了分仓虚拟库存!")).not.toBeInTheDocument();
|
||||
expect(screen.getByText("仓库库存已推")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows one warehouse success when both inventory channels succeeded", () => {
|
||||
render(<ProductPricingInventoryStatuses row={createPricingRow({ jstVirtualInventoryStatus: "pushed", jstVirtualInventoryError: "" })} />);
|
||||
expect(screen.getByText("仓库库存已推")).toBeInTheDocument();
|
||||
expect(screen.queryByLabelText("简尚固定虚拟库存")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("keeps the configuration reason visible when neither channel succeeded", () => {
|
||||
render(<ProductPricingInventoryStatuses row={createPricingRow({ fixedVirtualInventoryStatus: "skipped", fixedVirtualInventoryError: "code=100,未开通了分仓虚拟库存!" })} />);
|
||||
expect(screen.getByText("仓库库存失败")).toBeInTheDocument();
|
||||
expect(screen.getByText("简尚库存已跳过")).toHaveAttribute("title", "code=100,未开通了分仓虚拟库存!");
|
||||
});
|
||||
|
||||
it("shows an uncertain upstream result before fixed inventory status without exposing actions to read-only users", () => {
|
||||
const row = {
|
||||
...createPricingRow(),
|
||||
jstVirtualInventoryStatus: "pending" as const,
|
||||
jstVirtualInventoryError: JST_VIRTUAL_INVENTORY_IN_FLIGHT_ERROR,
|
||||
jstVirtualInventorySoId: "VIRTUAL-001",
|
||||
fixedVirtualInventoryStatus: "pending" as const,
|
||||
};
|
||||
|
||||
render(
|
||||
|
||||
@ -64,10 +64,17 @@ function fixedStatus(row: ProductPricingDisplayRow) {
|
||||
}
|
||||
|
||||
export function ProductPricingInventoryStatuses({ row }: { row: ProductPricingDisplayRow }) {
|
||||
const warehouse = { key: 'warehouse', name: '仓库虚拟库存', meta: warehouseStatus(row) }
|
||||
const fixed = { key: 'fixed', name: '简尚固定虚拟库存', meta: fixedStatus(row) }
|
||||
const statuses = row.jstVirtualInventoryStatus === 'pushed'
|
||||
? [warehouse]
|
||||
: row.fixedVirtualInventoryStatus === 'pushed'
|
||||
? [fixed]
|
||||
: [warehouse, fixed]
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-start gap-1">
|
||||
{[{ key: 'warehouse', name: '仓库虚拟库存', meta: warehouseStatus(row) },
|
||||
{ key: 'fixed', name: '简尚固定虚拟库存', meta: fixedStatus(row) }].map(({ key, name, meta }) => meta ? (
|
||||
{statuses.map(({ key, name, meta }) => meta ? (
|
||||
<span key={key} aria-label={name} title={meta.title}
|
||||
className={`inline-flex h-6 min-w-[64px] items-center justify-center whitespace-nowrap rounded-full px-2 text-[11px] font-apple-medium ${meta.tone}`}>
|
||||
{meta.label}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user