From 7458fa87f4a3c7a7a257e210c4998895aa116a92 Mon Sep 17 00:00:00 2001 From: xarmian Date: Fri, 25 Sep 2026 01:36:38 -0400 Subject: [PATCH] test(BUG-2684): pin that the copy preflight labels a dropped-then-defaulted key from=default, the case the bug was filed for (#1533) The labelling fix shipped in TASK-2878 (#1246, codex round 9); existing pins covered only null-source and destination-only defaults. Claude-Session: https://claude.ai/code/session_01A3rXV7GDLAhBe9mL4V6z2m --- .../server/bug2684_preflight_origin_test.go | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 internal/server/bug2684_preflight_origin_test.go diff --git a/internal/server/bug2684_preflight_origin_test.go b/internal/server/bug2684_preflight_origin_test.go new file mode 100644 index 000000000..1950ebcbd --- /dev/null +++ b/internal/server/bug2684_preflight_origin_test.go @@ -0,0 +1,37 @@ +package server + +import "testing" + +// BUG-2684, the case it was filed for: the SOURCE declares a key, migration +// DROPS its value (it cannot convert), and the destination's default fills the +// key back in. The carried row must say from="default" — the destination chose +// that value — not "migrated", which would tell the user a value came across +// that did not survive. +// +// Fixed by TASK-2878 (#1246, codex round 9), which labels from the source +// values that SURVIVED migration (store.CarriedSourceValues) rather than from +// the source map. The existing pins cover a null source value and a +// destination-only default; neither is this shape, where the source value was +// present, non-null and discarded. +func TestBUG2684_PreflightLabelsADroppedThenDefaultedKeyAsDefault(t *testing.T) { + f := newCopyPreflightFixture(t) + // The fixture's source has count=7 (number); here the destination's + // `count` is a select that cannot hold 7, with a default. + dst := mustSchemaCollection(t, f.srv, f.wsB.ID, "Counted B", `{"fields":[ + {"key":"status","label":"Status","type":"select","options":["open","done"]}, + {"key":"count","label":"Count","type":"select","options":["x","y"],"default":"x"} + ]}`) + body := f.baseBody() + body["target_collection"] = dst.Slug + resp := f.ok(body) + + got := carriedByKey(t, resp, "count") + if got.Value != "x" || got.From != "default" { + t.Fatalf("count: the source's 7 was discarded and the destination default filled it; want value=x from=default, got %+v", got) + } + // CONTROL: a key whose source value DID survive is still "migrated", so + // the leg above is not satisfied by labelling everything "default". + if st := carriedByKey(t, resp, "status"); st.From != "migrated" { + t.Fatalf("status carried across unchanged and must be from=migrated, got %+v", st) + } +}