Skip to content

fix(platform): show a dash for an unset product price and stock - #4274

Merged
yannickmonney merged 2 commits into
mainfrom
fix/products-null-price-stock-dash
Oct 4, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
fix/products-null-price-stock-dash

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

What changed

An unpriced product read as free. The products listing returns null for a price or stock nobody set, and the products adapter passed that null through unchanged. The product document (ProductDoc) declares both fields optional (price?: number). The Products cells and the details dialog test !== undefined, so:

  • a missing price was formatted as $0.00, or as zero in the row's currency;
  • a missing stock showed an empty cell;
  • in the details dialog, the Price and Stock facts appeared too.

Fix: a new withProductFields step in services/platform/app/lib/backend/engagement.ts wraps withRecordDates for the listProductsPaginated lane and drops each top-level null. An unset column now arrives absent, which is the shape the document declares:

  • missing price and stock show the dash the cells already render for an absent field;
  • the details dialog leaves them out, as it does for a product that never had them;
  • an explicit 0 stays 0.

That lane is the only source of product rows in the app. The table, the details dialog, the edit dialog's prefill and the row menu all read its rows, so this one change covers all of them. No UI file changes.

The sweep turned up no reader that depends on a null value:

  • The edit dialog prefills with ?.toString() || '' and || ''.
  • The cells and dialog read category, status, imageUrl, currency, description and tags by truthiness.
  • The row menu reads metadata with ?..

No strings changed, so no locales are touched. No markup changed either: the dash is the existing missing-value rendering.

I didn't touch the files of open PR #4251 (the create and edit dialogs and product-number-schema.ts). The change builds on #4230's clearing rule: once an edit clears a price, it reads back as null, which now shows the dash.

#4251 also edits the two manual files, so I put the register row beside the adapter-dates row rather than after the #3619 row, where #4251 adds its own. I ran a trial git merge-tree of this head with #4251's head 394dcb947. It merges both manual files cleanly. Its only conflict is product-edit-dialog.tsx, and #4251 has that same conflict against main alone, so it isn't caused by this branch.

The manual layer gets KNOW-B22, which covers the real-database readback after a reload that a jsdom test can't reach. reference/automation.md gets a row for the half the specs own; it also re-points #4230's row, which named this issue as open.

How it was verified

Regression across the failing boundary. products-table.test.tsx › unset price and stock answers fetch with pg-shaped rows and runs them through the real listProductsPaginated adapter, as a reload does. It then renders the real Products table, cells and details dialog:

Row Price Stock
null price and stock - -
explicit 0 / 0, currency CHF (control) CHF 0.00 0
absent fields (control) - -

For the details dialog:

  • the null product shows no Price or Stock fact and no 0.00;
  • the zero product shows CHF 0.00 and 0 units.

engagement.test.ts › the products listing rows pins the adapter shape. It uses toStrictEqual, so every null column must be absent and an explicit zero is kept.

Mutation check. I restored withRecordDates on the products lane and kept the new tests. Both table tests and the adapter test then fail, and the table failure reproduces the issue's frozen observation exactly:

    "Unpriced gadget": {
-     "price": "-",
-     "stock": "-",
+     "price": "$0.00",
+     "stock": "",
    },

The zero control and the absent control pass under the mutant too. That is the same split the issue reports.

Checks run locally on the changed files:

  • bunx vitest run --config vitest.ui.config.ts: 5 files and 34 tests passed. The files are products-table, product-view-dialog, use-products-table-config, product-edit-dialog.wire and products-crud.
  • bunx vitest run --config vitest.config.ts --project server: engagement.test.ts and adapters.test.ts, 52 tests passed.
  • Scoped tsc over the changed files plus app/router.tsx (6,178 files): exit 0.
  • oxlint --type-aware on the changed files: clean. oxfmt --check: clean.
  • bun run lint:manual: ok. check-guide.ts on suites/knowledge.md: OK.
  • commitlint on both commits: ok. bun run lint:conflicts: ok.

Not run: no browser and no backend or PostgreSQL stack. The real-database readback after a reload is KNOW-B22's manual half.

Closes #3617

The products listing returns `null` for a price or stock nobody set,
and the products adapter passed it through. The product document
declares both fields optional, and the Products cells and the details
dialog test `!== undefined`, so an unpriced product read `$0.00` and
an unknown stock showed an empty cell.

The listing adapter now leaves an unset column absent, as the document
declares it. An explicit zero still reads as zero, and every reader of
the listing rows gets the same shape.

Closes #3617
KNOW-B22 covers the real database readback after a reload, which the
component regression for #3617 cannot reach. The automation register
names the half the specs own.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent review: ACCEPT

Reviewed exact head 210683c16a8e190cadd01ae8cc2f59787d33a0f5 (unchanged at posting).

Evidence:

  • products-table.test.tsx: exact backend-shaped null price/stock render the existing dash in the table; the view dialog omits both facts; explicit 0 renders CHF 0.00 and 0 units; absent fields still render the dash. 13/13 passed.
  • engagement.test.ts: the products pagination adapter drops top-level null fields while retaining explicit zero and date/id mapping. 20/20 server tests passed.
  • Main-equivalent mutant (restoring withRecordDates) fails the regression: UI 2 failed / 13, adapter 1 failed / 20, including the original $0.00 and blank-stock behavior.
  • Product-reader sweep found no competing nullable reader; PR fix(platform): send product stock as the number the form accepted #4251 overlap is limited to the already-described shared manual files, with no product dialog/schema overlap.

Blockers: none found.

Unrun proof: no browser, PostgreSQL/backend stack, manual KNOW-B22 round, CI wait, or full suite, per the light-review instruction. CI was not rerun or cancelled. This accepts the code/tests for review; the real-database reload remains the documented manual proof boundary.

yannickmonney added a commit that referenced this pull request Oct 4, 2026
Open PRs #4290 and #4274 each add a KNOW-B22 already, and the guide
linter refuses a duplicate box ID. The suite's cost counts the new box.
@yannickmonney
yannickmonney merged commit 9f3c254 into main Oct 4, 2026
@yannickmonney
yannickmonney deleted the fix/products-null-price-stock-dash branch October 4, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Products with no price are displayed as zero-priced after backend null readback

1 participant