Skip to content

Commit 3e661a7

Browse files
committed
test(app-showcase): seed a line so the committee quorum gate opens
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016g7nYP9wdNx1GDa5XDr7Uy
1 parent 7b7017b commit 3e661a7

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

‎examples/app-showcase/test/expense-approval-write-back.test.ts‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,18 @@ function rows(res: any): any[] {
101101
}
102102

103103
/** A submitted report, opened into approval the way the seed's `launchSignoff` does. */
104-
async function submitReport(booted: Booted, flowName: string): Promise<{ report: any; request: any }> {
105-
const report = one(await booted.data.insert('showcase_expense_report', {
104+
async function submitReport(booted: Booted, flowName: string, amount: number): Promise<{ report: any; request: any }> {
105+
const created = one(await booted.data.insert('showcase_expense_report', {
106106
name: 'EXP-TEST',
107107
employee: 'Mei Phone',
108108
status: 'submitted',
109109
}, SYS));
110+
// One line, so the `total_amount` roll-up the committee gate reads is real.
111+
await booted.data.insert('showcase_expense_line', {
112+
expense_report: created.id, merchant: 'Acme Travel', category: 'travel', amount, status: 'submitted',
113+
}, SYS);
114+
const report = one(await booted.data.findOne('showcase_expense_report', { where: { id: created.id }, ...SYS }));
115+
expect(Number(report.total_amount)).toBe(amount);
110116
const launched: any = await booted.automation.execute(flowName, {
111117
record: report,
112118
previous: { ...report, status: 'draft' },
@@ -147,23 +153,27 @@ const CASES = [
147153
{
148154
flow: ExpenseSignoffFlow,
149155
node: 'dual_signoff',
156+
// Under the $5,000 committee threshold, as the seeded EXP-2001 is.
157+
amount: 1500,
150158
// per_group: one from EACH group finalizes.
151159
approvers: ['position:manager', 'position:auditor'],
152160
rejecter: 'position:auditor',
153161
},
154162
{
155163
flow: CommitteeQuorumFlow,
156164
node: 'committee',
165+
// At or above the $5,000 the committee's start gate requires (EXP-DEMO: 8,900).
166+
amount: 8900,
157167
// quorum: any 2 of 3 finalizes.
158168
approvers: ['position:manager', 'position:legal'],
159169
rejecter: 'position:finance',
160170
},
161171
] as const;
162172

163-
describe.each(CASES)('#25469 — $flow.name writes its decision back onto the report', ({ flow, node, approvers, rejecter }) => {
173+
describe.each(CASES)('#25469 — $flow.name writes its decision back onto the report', ({ flow, node, amount, approvers, rejecter }) => {
164174
it('approve: the report reads `approved` once the approval finalizes, not before', async () => {
165175
const booted = await boot(flow);
166-
const { report, request } = await submitReport(booted, flow.name);
176+
const { report, request } = await submitReport(booted, flow.name, amount);
167177

168178
const first = await decide(booted, request.id, 'approve', approvers[0]);
169179
expect(first.finalized, 'one approval already finalized the request').toBe(false);
@@ -184,7 +194,7 @@ describe.each(CASES)('#25469 — $flow.name writes its decision back onto the re
184194

185195
it('reject: the report goes back to `draft`, a value its status field declares', async () => {
186196
const booted = await boot(flow);
187-
const { report, request } = await submitReport(booted, flow.name);
197+
const { report, request } = await submitReport(booted, flow.name, amount);
188198

189199
const res = await decide(booted, request.id, 'reject', rejecter);
190200
expect(res.finalized).toBe(true);
@@ -205,7 +215,7 @@ describe.each(CASES)('#25469 — $flow.name writes its decision back onto the re
205215
expect((preFix.nodes as any[]).some((n) => n.type === 'update_record')).toBe(false);
206216

207217
const booted = await boot(preFix);
208-
const { report, request } = await submitReport(booted, flow.name);
218+
const { report, request } = await submitReport(booted, flow.name, amount);
209219
await decide(booted, request.id, 'approve', approvers[0]);
210220
const second = await decide(booted, request.id, 'approve', approvers[1]);
211221
expect(second.finalized).toBe(true);

0 commit comments

Comments
 (0)