Skip to content

test: refresh stale order.create.failed assertions - #896

Merged
khaira777 merged 1 commit into
mainfrom
fm/flocafe-886-matrix-regression-r1
Sep 26, 2026
Merged

khaira777 merged 1 commit into
mainfrom
fm/flocafe-886-matrix-regression-r1

Conversation

@khaira777

Copy link
Copy Markdown
Contributor

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.

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.
@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 33 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: FreeOpenSourcePOS/FloCafe/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: f77183fd-32fc-41fd-b694-e97ec7aa2ca9

📥 Commits

Reviewing files that changed from the base of the PR and between a2e3460 and 1a27252.

📒 Files selected for processing (1)
  • tests/diagnostics-event.test.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@khaira777
khaira777 merged commit 93ffdd5 into main Sep 26, 2026
20 checks passed
@khaira777
khaira777 deleted the fm/flocafe-886-matrix-regression-r1 branch September 26, 2026 21:25
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.

1 participant