Repository navigation
test: refresh stale order.create.failed assertions - #896
Merged
Merged
Conversation
The two assertions the four-platform matrix reported were stale, not a regression: the diagnostic behaviour they describe is unchanged and still intended, and #886 legitimately changed the HTTP status that behaviour is derived from. Both failures came from one cause. Step 8 of tests/diagnostics-event.test.ts posts an order whose product_id does not exist and then looks for the enqueued order.create.failed row by metadata.status 500, a number it had picked up incidentally because a missing product used to be an unhandled internal error. #886 gave that throw a 404, so the row is still enqueued, still carries the order_insert stage, and still records the status the request produced - it simply records 404 now, the 500 lookup finds nothing, and both assertions in that step fail. Nothing in the order-create classification changed: main/routes/orders.ts still enqueues a diagnostic for every failed create, still reports inventory_validation only for an insufficient-stock error, and still reports the actual HTTP status in metadata.status, which is the documented contract the cloud-sync sanitizer accepts over the whole 100-599 range. The fix is therefore in the assertion, not in the route, and no production code is touched here. The brief named order.create.failed is enqueued on inventory failure as a second failure, but that assertion passes both locally and on the CI log for the red run, so step 7 is left exactly as it is. The updated assertion is deliberately stronger than the one it replaces rather than merely rewritten to match the current output. The old version pinned a magic 500 while asserting nothing about how the reported status relates to the response. It now asserts the response is 404, looks the row up by the status the request actually produced, and separately asserts that the diagnostic carries that status, the order_insert stage and the item count, so status and stage are pinned independently instead of one lookup standing in for both. I checked it still has teeth by mutating the production code four ways and confirming red each time: reverting #886's 404 back to a plain Error fails the 404 assertion outright, hard-coding 500 in the diagnostic report fails the status assertions in both step 7 and step 8, classifying every create failure as inventory_validation fails the four step 8 assertions, and hard-coding item_count fails the count assertions. The suite was red with 2 failures before this change and is green with 70 passing after it. Two consequences of #886 are worth recording here rather than acting on, since neither is a regression and both are outside this fix. First, the inventory_validation stage is still chosen by exact message equality on 'Insufficient stock', so the sibling 'Product not found' and the invalid-delta guards that adjustProductStock also throws are reported as order_insert; that imprecision predates #886 and no assertion pins it, but it does under-report inventory-stage failures in telemetry. Second, the matrix explains the 3-of-4-platform pattern exactly: the Windows job runs the first three pretest suites and then the shard, and never runs test:diagnostics-event, so Windows reported success on a suite it did not execute, and PR CI does not run it either because run-test-shard.cjs derives its suite list from the test script while pretest is invoked separately. That is a real coverage hole in both workflows, but widening either one is a deliberate call for a maintainer rather than something to slip into a test-fix commit. Verification: npm run lint (clean, 5 pre-existing frontend warnings), npm run build, and the full local suite including pretest. On the full run tests/diagnostics-event.test.ts goes 2 failures to none, and one unrelated suite, tests/cash-closures.test.ts, failed once with duplicate active opening float is rejected reporting 400 where it expects 409 - it is a different file and a separate process, it passed 320/320 in six consecutive standalone runs and in a subsequent 169-suite shard run, and main's own CI has both core shards green, so I read it as a pre-existing local intermittent and did not touch it. I could not run the four-platform matrix myself; branch CI will.
Contributor
|
Warning Review limit reachedNext included review available in 33 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: FreeOpenSourcePOS/FloCafe/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
test: refresh stale order.create.failed assertions
The two assertions the four-platform matrix reported were stale, not a regression: the
diagnostic behaviour they describe is unchanged and still intended, and #886 legitimately
changed the HTTP status that behaviour is derived from. Both failures came from one
cause. Step 8 of tests/diagnostics-event.test.ts posts an order whose product_id does not
exist and then looks for the enqueued order.create.failed row by metadata.status 500, a
number it had picked up incidentally because a missing product used to be an unhandled
internal error. #886 gave that throw a 404, so the row is still enqueued, still carries the
order_insert stage, and still records the status the request produced - it simply records
404 now, the 500 lookup finds nothing, and both assertions in that step fail. Nothing in
the order-create classification changed: main/routes/orders.ts still enqueues a diagnostic
for every failed create, still reports inventory_validation only for an insufficient-stock
error, and still reports the actual HTTP status in metadata.status, which is the
documented contract the cloud-sync sanitizer accepts over the whole 100-599 range. The fix
is therefore in the assertion, not in the route, and no production code is touched here.
The brief named order.create.failed is enqueued on inventory failure as a second failure,
but that assertion passes both locally and on the CI log for the red run, so step 7 is
left exactly as it is.
The updated assertion is deliberately stronger than the one it replaces rather than merely
rewritten to match the current output. The old version pinned a magic 500 while asserting
nothing about how the reported status relates to the response. It now asserts the response
is 404, looks the row up by the status the request actually produced, and separately
asserts that the diagnostic carries that status, the order_insert stage and the item count,
so status and stage are pinned independently instead of one lookup standing in for both. I
checked it still has teeth by mutating the production code four ways and confirming red
each time: reverting #886's 404 back to a plain Error fails the 404 assertion outright,
hard-coding 500 in the diagnostic report fails the status assertions in both step 7 and
step 8, classifying every create failure as inventory_validation fails the four step 8
assertions, and hard-coding item_count fails the count assertions. The suite was red with
2 failures before this change and is green with 70 passing after it.
Two consequences of #886 are worth recording here rather than acting on, since neither is
a regression and both are outside this fix. First, the inventory_validation stage is still
chosen by exact message equality on 'Insufficient stock', so the sibling 'Product not
found' and the invalid-delta guards that adjustProductStock also throws are reported as
order_insert; that imprecision predates #886 and no assertion pins it, but it does
under-report inventory-stage failures in telemetry. Second, the matrix explains the
3-of-4-platform pattern exactly: the Windows job runs the first three pretest suites and
then the shard, and never runs test:diagnostics-event, so Windows reported success on a
suite it did not execute, and PR CI does not run it either because run-test-shard.cjs
derives its suite list from the test script while pretest is invoked separately. That is a
real coverage hole in both workflows, but widening either one is a deliberate call for a
maintainer rather than something to slip into a test-fix commit.
Verification: npm run lint (clean, 5 pre-existing frontend warnings), npm run build, and
the full local suite including pretest. On the full run tests/diagnostics-event.test.ts
goes 2 failures to none, and one unrelated suite, tests/cash-closures.test.ts, failed once
with duplicate active opening float is rejected reporting 400 where it expects 409 - it is
a different file and a separate process, it passed 320/320 in six consecutive standalone
runs and in a subsequent 169-suite shard run, and main's own CI has both core shards
green, so I read it as a pre-existing local intermittent and did not touch it. I could not
run the four-platform matrix myself; branch CI will.