test(collection-pool): pin nearby-sort behaviour for missing coords
This commit is contained in:
parent
7a7ad71ac0
commit
363cdebe36
1 changed files with 71 additions and 0 deletions
|
|
@ -195,3 +195,74 @@ describe("buildProximityMarkerMap", () => {
|
|||
expect(markers.get("sup-a")).not.toBe(markers.get("sup-c"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildVisibleRows sort modes (nearby pinning)", () => {
|
||||
const todayYmd = "2026-07-09";
|
||||
|
||||
it("operational sort is stable on the same input regardless of readyFilter", () => {
|
||||
const rows: CollectionPoolViewRow[] = [
|
||||
makeRow({ id: "a", poNumber: "PO-A", updated: "2026-07-02T00:00:00.000Z" }),
|
||||
makeRow({ id: "b", poNumber: "PO-B", updated: "2026-07-01T00:00:00.000Z" }),
|
||||
];
|
||||
|
||||
const all = buildVisibleRows(rows, {
|
||||
todayYmd,
|
||||
searchText: "",
|
||||
readyFilter: "all",
|
||||
sortMode: "operational",
|
||||
});
|
||||
const ready = buildVisibleRows(rows, {
|
||||
todayYmd,
|
||||
searchText: "",
|
||||
readyFilter: "ready",
|
||||
sortMode: "operational",
|
||||
});
|
||||
const pending = buildVisibleRows(rows, {
|
||||
todayYmd,
|
||||
searchText: "",
|
||||
readyFilter: "unready",
|
||||
sortMode: "operational",
|
||||
});
|
||||
|
||||
expect(all.map((r) => r.id)).toEqual(["a", "b"]);
|
||||
expect(ready.map((r) => r.id)).toEqual(["a", "b"]);
|
||||
expect(pending.map((r) => r.id)).toEqual(["a", "b"]);
|
||||
});
|
||||
|
||||
it("nearby sort groups rows by clusterSortKey ascending", () => {
|
||||
const rows: CollectionPoolViewRow[] = [
|
||||
makeRow({ id: "c", clusterSortKey: "cluster-c" }),
|
||||
makeRow({ id: "a", clusterSortKey: "cluster-a" }),
|
||||
makeRow({ id: "b", clusterSortKey: "cluster-b" }),
|
||||
];
|
||||
|
||||
const out = buildVisibleRows(rows, {
|
||||
todayYmd,
|
||||
searchText: "",
|
||||
readyFilter: "all",
|
||||
sortMode: "nearby",
|
||||
});
|
||||
|
||||
expect(out.map((r) => r.id)).toEqual(["a", "b", "c"]);
|
||||
});
|
||||
|
||||
it("nearby sort sinks rows with missing clusterSortKey to the end", () => {
|
||||
const rows: CollectionPoolViewRow[] = [
|
||||
makeRow({ id: "no-coords-1", clusterSortKey: undefined }),
|
||||
makeRow({ id: "a", clusterSortKey: "cluster-a" }),
|
||||
makeRow({ id: "no-coords-2", clusterSortKey: undefined }),
|
||||
makeRow({ id: "b", clusterSortKey: "cluster-b" }),
|
||||
];
|
||||
|
||||
const out = buildVisibleRows(rows, {
|
||||
todayYmd,
|
||||
searchText: "",
|
||||
readyFilter: "all",
|
||||
sortMode: "nearby",
|
||||
});
|
||||
|
||||
// Rows WITH coords come first, ordered by cluster key.
|
||||
// Rows WITHOUT coords come last (sink to the end).
|
||||
expect(out.map((r) => r.id)).toEqual(["a", "b", "no-coords-1", "no-coords-2"]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue