From 8c65e505a06e65ab879c2849308b7e82aeedd326 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 08:18:07 +0000 Subject: [PATCH] test(dogfood): the persona matrix hangs its invoice lines off an unpaid invoice The admin payload control created a showcase_invoice_line under firstId('showcase_invoice'), whichever invoice a limit-1 read returned. With random ids that is a different invoice on every boot, and several seeded invoices are paid. Since the showcase locks a paid invoice's lines (its showcase_guard_paid_invoice_line_* hooks), the control answered 400 "This invoice is paid, so its lines are locked" on some boots and not others. The seeded parent is now chosen by the state the lock reads (status not paid), the way the account above it is chosen by its rule. Every line the file creates under a seeded invoice hangs off this one parent. The lock is unchanged. Claude-Session: https://claude.ai/code/session_01LmjU2x1faLZ39DVTFyVca6 Co-authored-by: Claude --- .../showcase-crud-persona-matrix.dogfood.test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/qa/dogfood/test/showcase-crud-persona-matrix.dogfood.test.ts b/packages/qa/dogfood/test/showcase-crud-persona-matrix.dogfood.test.ts index d9a4f06e666..fc0371f00fa 100644 --- a/packages/qa/dogfood/test/showcase-crud-persona-matrix.dogfood.test.ts +++ b/packages/qa/dogfood/test/showcase-crud-persona-matrix.dogfood.test.ts @@ -324,7 +324,19 @@ describe('showcase: persona × CRUD-cell matrix (#9481)', () => { ); seed.productId = await firstId('showcase_product'); seed.projectId = await firstId('showcase_project'); - seed.invoiceId = await firstId('showcase_invoice'); + // NOT `firstId` either, for the same reason as the account: the showcase + // locks a PAID invoice's lines (its `showcase_guard_paid_invoice_line_*` + // hooks), so a line can be neither added under one nor removed from one. + // `firstId` takes whichever invoice a `limit: 1` read returns, and with + // random ids that is a different invoice on every boot — several seeded + // invoices are paid, so the admin control below failed on some boots and + // not others. Every line this file creates under a seeded invoice hangs + // off this one, so the parent is chosen by the state the lock reads. + seed.invoiceId = String( + (await ql.find('showcase_invoice', { + where: { status: { $ne: 'paid' } }, limit: 1, context: SYS, + }))?.[0]?.id ?? '', + ); seed.expenseReportId = await firstId('showcase_expense_report'); seed.teamId = await firstId('showcase_team'); expect(