refactor(orders): rename runQuoteMatch to runPostCreateMatchers, update stale comments
This commit is contained in:
parent
70932eb967
commit
d9f0925d83
2 changed files with 13 additions and 14 deletions
|
|
@ -2962,13 +2962,13 @@ describe("createOrder quote auto-detection", () => {
|
|||
expect(r.order.id).toBeDefined();
|
||||
// Proves the catch fired AND ran the inline fallback — without
|
||||
// the call assertion the test would pass on the spy alone even
|
||||
// if `void runQuoteMatch()` was deleted.
|
||||
// if `void runPostCreateMatchers()` was deleted.
|
||||
expect(suggestQuoteForOrder).toHaveBeenCalledWith(r.order.id);
|
||||
// The fallback logs its engagement so a silent switch to
|
||||
// fire-and-forget is impossible to miss in production logs.
|
||||
expect(consoleErrorSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
"[createOrder] after() unavailable, running quote match inline",
|
||||
"[createOrder] after() unavailable, running post-create matchers inline",
|
||||
),
|
||||
expect.anything(),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2254,16 +2254,15 @@ export async function createOrder(input: CreateOrderInput): Promise<CreateOrderR
|
|||
// never fail an order creation: an unmatched order is a minor
|
||||
// inconvenience, a lost order is not.
|
||||
//
|
||||
// Two independent `try/catch` blocks below, not one wrapping both —
|
||||
// a delivery-note match failure must not prevent the quote
|
||||
// suggestion from landing (and vice versa). Each matcher is
|
||||
// visibility-only, so the worst-case outcome of either failing is a
|
||||
// missing pill, never lost data.
|
||||
// Four independent `try/catch` blocks below, not one wrapping all —
|
||||
// each matcher's failure must not prevent the others from landing.
|
||||
// Every matcher is visibility-only, so the worst-case outcome of
|
||||
// any single failure is a missing pill, never lost data.
|
||||
//
|
||||
// Writes only the soft suggestions (`potential_quote` +
|
||||
// `potential_delivery_note`). Promoting either to a hard link stays
|
||||
// a deliberate human click.
|
||||
const runQuoteMatch = async () => {
|
||||
// Writes only soft suggestions (quote, delivery-note, order-number
|
||||
// duplicate, order-item duplicate). Promoting any of them to a
|
||||
// hard link stays a deliberate human click.
|
||||
const runPostCreateMatchers = async () => {
|
||||
try {
|
||||
await suggestQuoteForOrder(order.id);
|
||||
} catch (err) {
|
||||
|
|
@ -2298,7 +2297,7 @@ export async function createOrder(input: CreateOrderInput): Promise<CreateOrderR
|
|||
}
|
||||
};
|
||||
try {
|
||||
after(runQuoteMatch);
|
||||
after(runPostCreateMatchers);
|
||||
} catch (err) {
|
||||
// `after()` throws synchronously when called outside a request
|
||||
// scope — `workAsyncStorage.getStore()` comes back empty, throwing
|
||||
|
|
@ -2315,10 +2314,10 @@ export async function createOrder(input: CreateOrderInput): Promise<CreateOrderR
|
|||
// Logged because a silent fallback here is invisible: orders
|
||||
// would lose the latency guarantee permanently with no trace.
|
||||
console.error(
|
||||
`[createOrder] after() unavailable, running quote match inline for ${order.id}:`,
|
||||
`[createOrder] after() unavailable, running post-create matchers inline for ${order.id}:`,
|
||||
err,
|
||||
);
|
||||
void runQuoteMatch();
|
||||
void runPostCreateMatchers();
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Reference in a new issue