Repository navigation
fix(platform): show a dash for an unset product price and stock - #4274
Merged
Merged
Conversation
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.
Contributor
Author
Independent review: ACCEPTReviewed exact head Evidence:
Blockers: none found. Unrun proof: no browser, PostgreSQL/backend stack, manual |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
An unpriced product read as free. The products listing returns
nullfor a price or stock nobody set, and the products adapter passed thatnullthrough unchanged. The product document (ProductDoc) declares both fields optional (price?: number). The Products cells and the details dialog test!== undefined, so:$0.00, or as zero in the row's currency;Fix: a new
withProductFieldsstep inservices/platform/app/lib/backend/engagement.tswrapswithRecordDatesfor thelistProductsPaginatedlane and drops each top-levelnull. An unset column now arrives absent, which is the shape the document declares:0stays0.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
nullvalue:?.toString() || ''and|| ''.category,status,imageUrl,currency,descriptionandtagsby truthiness.metadatawith?..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 asnull, 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-treeof this head with #4251's head394dcb947. It merges both manual files cleanly. Its only conflict isproduct-edit-dialog.tsx, and #4251 has that same conflict againstmainalone, 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.mdgets 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 stockanswersfetchwith pg-shaped rows and runs them through the reallistProductsPaginatedadapter, as a reload does. It then renders the real Products table, cells and details dialog:nullprice and stock--0/0, currencyCHF(control)CHF 0.000--For the details dialog:
nullproduct shows no Price or Stock fact and no0.00;CHF 0.00and0 units.engagement.test.ts›the products listing rowspins the adapter shape. It usestoStrictEqual, so everynullcolumn must be absent and an explicit zero is kept.Mutation check. I restored
withRecordDateson 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: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 areproducts-table,product-view-dialog,use-products-table-config,product-edit-dialog.wireandproducts-crud.bunx vitest run --config vitest.config.ts --project server:engagement.test.tsandadapters.test.ts, 52 tests passed.tscover the changed files plusapp/router.tsx(6,178 files): exit 0.oxlint --type-awareon the changed files: clean.oxfmt --check: clean.bun run lint:manual: ok.check-guide.tsonsuites/knowledge.md: OK.commitlinton 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