fix(products): cleared Variant Position resolves to file order, not NULL
A blank Variant Position cell previewed position->null and aborted the confirm transaction (variant.position is NOT NULL). Resolve the clear to the variant's file order at diff time so preview and apply stay in lockstep; carry file_order on VariantPlan instead of an identity-keyed map; release the read snapshot before PreviewStale/NothingToApply. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -113,6 +113,24 @@ def test_changed_variant_position_reports_honest_before():
|
||||
assert {"field": "position", "before": 1, "after": 2} in ventry["changes"]
|
||||
|
||||
|
||||
def test_blank_position_cell_resolves_to_file_order_unchanged():
|
||||
# A present-but-empty Variant Position cell resets to file order (the spec's
|
||||
# "defaults to file order"), never to NULL — here file order matches the
|
||||
# catalog position, so nothing changes.
|
||||
diff = compute_diff(_catalog_mug(), _canon(POSITION_HEADER, MUG_ROW + ","))
|
||||
assert diff.records[0]["kind"] == "unchanged"
|
||||
|
||||
|
||||
def test_blank_position_cell_updates_to_file_order():
|
||||
catalog = _catalog_mug()
|
||||
catalog["moon-mug"].variants[0].position = 2
|
||||
diff = compute_diff(catalog, _canon(POSITION_HEADER, MUG_ROW + ","))
|
||||
[rec] = diff.records
|
||||
assert rec["kind"] == "update"
|
||||
[ventry] = rec["detail"]["variants"]
|
||||
assert {"field": "position", "before": 2, "after": 1} in ventry["changes"]
|
||||
|
||||
|
||||
def test_error_product_classifies_error():
|
||||
diff = compute_diff({}, _canon("Handle,Title,Variant Price", "mug,Mug,nope"))
|
||||
[rec] = diff.records
|
||||
|
||||
Reference in New Issue
Block a user