Skip to content

Commit 6ee2a63

Browse files
fix(formula): a proven quantity typed dyn answers number, so Studio withdraws a stale currency (#38108)
Fixes #35815 Clause-②: no Metadata-protocol: none ## 维护者速读 - 在 Studio 编辑公式字段的作者:把金额公式改成"数量乘数量"或"同币种金额相除"后,字段不再继续显示货币符号,而是改为普通数字。 - 属于公式货币结果类型这一组修复的后续,替在 Studio 里重构公式的作者解决"不再是金额却仍按金额显示"的问题。 - 出错时只影响作者编辑公式那一刻的类型标注,已存数据不变;作者可以在检查器里把结果类型改回去,也可直接撤回本改动。 - 无。 ## What changes `inferFormulaReturn` (`packages/formula/src/formula-return.ts`) now answers `{ returnType: 'number' }` when the unit proof (`dimOf`) proves a plain number and the CEL type is `dyn`. A field read is `dyn` to cel-js, so any operator over two field reads types `dyn`; before this change such an expression fell through to `inferExpressionType`, which maps `dyn` to `unknown`, and the answer was `{}` (unproven) even though every operand had been read as a declared number. Studio's formula inspector withdraws a declared `currency` only on a `number` answer, so the edit `record.amount * 0.1` into `record.quantity * record.hours` kept `returnType: 'currency'` and its `currencyConfig`. - Both field-over-field shapes the card names now answer `number`: quantity arithmetic (`record.quantity * record.hours`, `/`, `+`, bare `quantity * hours`, a ternary or `max` over two quantities) and a ratio of two amounts in one currency (`record.amount / record.tax`). - Unchanged: money over two field reads (`record.amount * record.quantity`) still answers `currency`; whatever the proof cannot follow still answers `{}` (a ratio across two currencies, anything divided by an amount, an amount times an amount, an operand whose unit cannot be read). The published direction holds: an unproven verdict keeps the declaration. - Relationship hop (`record.account.employee_count * 2`): still `{}`, now recorded as an **accepted limit** in the producer header. Proving it needs the related object's declared fields as a further input to `inferFormulaReturn`, which is a change to its published signature (and to the inspector, which would have to load them). That arm is reported to the seat as a decision, not built here. - No export, signature or `FormulaSourceField` member changes. `listMembershipSource` and every other export are untouched. Rider N3 (test side): - The `record.?amount * 0.1` and `record[?'amount'] * 0.1` pins answered `{}` with or without the unit check: cel-js does not type an optional as a number, so the numeric path never ran. They are replaced by `record.?amount.orValue(0) * 0.1` and `record[?'amount'].orValue(0) * 0.1`, which type `double` and are judged, with CONTROLs `record.?quantity.orValue(0) * 2` and `record[?'quantity'].orValue(0) * 2` that answer `number`. The test comment now says why the bare optional spelling pins nothing. - The released changelog sentence is NOT edited here (see Acceptance notes). Inspector side (test only, `ObjectFieldInspector.returnTypeHeld-27485.test.tsx`, the component's shared stamp harness): a new top-level describe pins the withdrawal for `record.est_hours * record.budget` and `record.amount / record.tax`, with CONTROLs that a ratio across two currencies keeps `currency` and that an amount times a quantity over two field reads still proves money (EUR). One existing pin, "an unproven verdict (a field-over-field quotient) still keeps a declared `currency`", used `record.est_hours / record.budget`, two plain numbers: that is the shape this card fixes, so it now uses `record.est_hours / record.amount`, which is still unproven. The engine stub's `dyn` regex now covers `*` as well as `/`, matching the engine. ## Read first 1. `packages/formula/src/formula-return.ts`, the new line after the money returns in `inferFormulaReturn` (`celType === 'dyn' && isPlainNumber(dim)`): the only behaviour change. Risk: a `dyn` expression `dimOf` calls a quantity that is not numeric. `dimOf` only answers quantity or constant for numeric literals, declared numeric non-money fields, and arithmetic or unit-keeping calls over those. 2. `packages/formula/src/formula-return.test.ts`, the `#35815` describe and the edited `UNPROVEN_OVER_MONEY` list. 3. The inspector test's swapped pin (`record.est_hours / record.amount`). ## Two-minute verification `pnpm --filter @objectstack/formula exec vitest run --maxWorkers=2 src/formula-return.test.ts`: 22 tests pass, among them `#35815 — a proven plain number whose CEL type is dyn answers number`. Delete the `celType === 'dyn'` line and the two `answers number` cases go red. ## Tests All runs below are on head `b9bc5f06` (after merging `origin/main`), unless the line says otherwise. <details><summary>formula: package suite and typecheck</summary> - `pnpm --filter @objectstack/formula exec vitest run --maxWorkers=2`: `Test Files 72 passed (72)`, `Tests 2167 passed (2167)`, lock `VERDICT command-exit 0`. - `pnpm --filter @objectstack/formula typecheck`: exit 0; `check:test-typecheck: OK`, the test layer compiles under `tsconfig.test.json`, debt ledger held. </details> <details><summary>app-shell: the inspector stamp harness</summary> - `pnpm exec vitest run --root ../.. --maxWorkers=2 packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.returnTypeHeld-27485.test.tsx` (from `ui/packages/app-shell`, after building `@objectstack/formula`, `lint` and `client`, which the suite reads from `dist/`): `Tests 28 passed (28)`. - `Type Check UI` is left to CI (the edit is string literals and a regex in one test file). </details> <details><summary>Ablations (fix committed first, `scripts/ablation-replace.mjs`, restore proven by blob == HEAD and an empty `git diff HEAD`)</summary> - Producer, src: delete the `celType === 'dyn'` line ⇒ `formula-return.test.ts` `Tests 2 failed | 20 passed (22)`: "field-over-field quantity arithmetic answers number" and "a ratio of two amounts in one currency answers number". Restored. - Inspector, through `dist/`: same deletion, then `pnpm --filter @objectstack/formula build`, then the inspector file ⇒ `Tests 2 failed | 26 passed (28)`: "the card's repro: an edit from an amount to quantity-times-quantity drops currency and its currencyConfig" and "a ratio of two amounts in one currency drops currency too". Restored and rebuilt; `ablation-dist-preflight.mjs @objectstack/formula` reports the marker present in 2 built files and the tree clean against HEAD. - N3, src: delete the `readsOnlyPlainFields` guard (the #35631 unit check). `record.?amount * 0.1` and `record[?'amount'] * 0.1` stay `{}` (they pin nothing); `record.?amount.orValue(0) * 0.1` and `record[?'amount'].orValue(0) * 0.1` flip to `{ returnType: 'number' }` (they discriminate). With the guard restored, they answer `{}` and both CONTROLs answer `number`. </details> ## Acceptance notes - **N3's changelog sentence is not corrected in this PR.** The sentence ("the indexed and optional spellings of an amount (`record['amount'] * 0.1`)" moved from `number` to `{}`) is in the consumed `.changeset/pre/35631-formula-currency-verdict.md` and was already released into the `19.0.0-next.1` sections of `packages/formula/CHANGELOG.md`, `ui/packages/app-shell/CHANGELOG.md` and `packages/spec/CHANGELOG.md`. AGENTS.md (Documentation Guardrails) says a factual error in a released entry is amended in a dedicated docs-only PR, never as a rider on a code change. Proposed amended text: "the indexed spelling of an amount (`record['amount'] * 0.1`) and the optional spellings read through `orValue` (`record.?amount.orValue(0) * 0.1`); a bare optional (`record.?amount * 0.1`) never typed as a number and answered `{}` before and after". Handed to the seat. - **Pre-existing inspector behaviour, not changed (test-only surface):** a formula declared `number` that is edited into `record.quantity * record.hours` has its `returnType` cleared. The inspector stamps the CEL type (`unknown` for `dyn`) and reads the money verdict only to stamp or withdraw `currency`. The existing pin "CONTROL — the same quotient still clears a declared `number`, as before" asserts this. - A `count` roll-up operand in a field-over-field product (`record.line_count * record.quantity`) still answers `{}`: `dimOf` does not read a roll-up as a quantity, though the read check accepts a `count`. That is the safe direction, and no surface was widened for it. - Local gates are the `dispatch-gates.mjs --commands` subset; every other family is CI's. ## Verification - `node scripts/pm/overlap-check.mjs` before each push: `VERDICT clean`. - Local derived gates: see the report comment on the card. --- _Generated by [Claude Code](https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 10321fa commit 6ee2a63

4 files changed

Lines changed: 162 additions & 20 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/formula': patch
3+
---
4+
5+
fix(formula): `inferFormulaReturn` answers `number` for a proven plain number whose CEL type is `dyn`, so Studio withdraws a stale `currency` on a field-over-field quantity edit
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A field read is `dyn` to cel-js, so an operator over two field reads types `dyn`. `inferFormulaReturn` answered such an expression `{}` (unproven) even when its unit proof had read every operand as a declared number. Studio's formula inspector withdraws a declared `currency` only on a `number` answer, so an author who edited `record.amount * 0.1` into `record.quantity * record.hours` kept `returnType: 'currency'` and its `currencyConfig`, and the value was still drawn as money.
11+
12+
FROM `inferFormulaReturn('record.quantity * record.hours', fields)` → `{}` TO → `{ returnType: 'number' }`, over a field map that declares both as plain numeric fields. The same holds for every expression the unit proof proves a plain number whose CEL type is `dyn`: `record.quantity / record.hours`, `record.quantity + record.hours`, `quantity * hours`, a ternary or `max` over two quantities, and a ratio of two amounts in one currency (`record.amount / record.tax`). Money over two field reads (`record.amount * record.quantity`) still answers `currency`. What the proof cannot follow still answers `{}`: a ratio across two currencies, anything divided by an amount, an amount times an amount, an operand whose unit cannot be read.
13+
14+
A quantity read through a relationship (`record.account.employee_count * 2`) still answers `{}`: the related object's fields are not an input to `inferFormulaReturn`, so the leaf's unit cannot be read, and a declared `currency` is kept on that edit. The function's header now records this as an accepted limit.
15+
16+
Nothing to migrate. A caller that read `{}` for these shapes as "keep the declaration" now gets `number`, which means proved not money.

‎packages/formula/src/formula-return.test.ts‎

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const FIELDS: Readonly<Record<string, FormulaSourceField>> = {
3030
spent: { type: 'currency', currencyConfig: { currencyMode: 'dynamic' } },
3131
probability: { type: 'percent' },
3232
quantity: { type: 'number' },
33+
hours: { type: 'number' },
3334
discount_rate: { type: 'number' },
3435
flag: { type: 'boolean' },
3536
name: { type: 'text' },
@@ -119,9 +120,6 @@ describe('CONTROL — a numeric formula stays `number`', () => {
119120
it('nothing it cannot prove is money: a numeric expression over declared non-money units, or one that is not numeric, gets exactly the plain inference', () => {
120121
for (const source of [
121122
'record.quantity * 2',
122-
// A ratio of two amounts in one currency is proven a plain number, and
123-
// cel-js types it `dyn`: the plain inference answers `{}`.
124-
'record.amount / record.tax',
125123
'record.amount > 100',
126124
'upper(record.name)',
127125
'today()',
@@ -194,8 +192,12 @@ describe('#35631 — an amount the proof cannot follow is unproven, never `numbe
194192
'record.account.balance * 0.9', // a hop through a reference
195193
'record.subtotal * 0.2', // a formula that declares no returnType
196194
"record['amount'] * 0.1", // the indexed spelling of an amount
197-
'record.?amount * 0.1', // the optional spelling
198-
"record[?'amount'] * 0.1", // the optional indexed spelling
195+
// The optional spellings read through `orValue`: a bare `record.?amount`
196+
// is an optional, which cel-js does not type as a number, so
197+
// `record.?amount * 0.1` answers `{}` with or without the unit check and
198+
// pins nothing. Unwrapped, the read types `double` and is judged.
199+
'record.?amount.orValue(0) * 0.1', // the optional spelling
200+
"record[?'amount'].orValue(0) * 0.1", // the optional indexed spelling
199201
'record.unknown_field * 2', // a name the map does not declare
200202
// One shape per leg of the unit check.
201203
'100 / record.weighted', // a formula declared `currency`
@@ -215,10 +217,66 @@ describe('#35631 — an amount the proof cannot follow is unproven, never `numbe
215217
});
216218

217219
it('CONTROL — every spelling of a quantity read, and a formula declared `number`, still answers `number`', () => {
218-
for (const source of ["record['quantity'] * 2", 'record.count_formula * 2', 'quantity * 2', 'record.probability * 2']) {
220+
for (const source of [
221+
"record['quantity'] * 2",
222+
'record.?quantity.orValue(0) * 2',
223+
"record[?'quantity'].orValue(0) * 2",
224+
'record.count_formula * 2',
225+
'quantity * 2',
226+
'record.probability * 2',
227+
]) {
219228
expect(inferFormulaReturn(source, FIELDS), source).toEqual(plainStamp(source));
229+
expect(inferFormulaReturn(source, FIELDS), source).toEqual({ returnType: 'number' });
230+
}
231+
});
232+
});
233+
234+
describe('#35815 — a proven plain number whose CEL type is `dyn` answers `number`', () => {
235+
// A field read is `dyn` to cel-js, so an operator over two field reads types
236+
// `dyn` and the CEL type alone proves nothing. The unit proof read both
237+
// operands' declared units: the result is a plain number, proved not money,
238+
// so a stamp may withdraw a declared `currency` on it.
239+
it('field-over-field quantity arithmetic answers `number`', () => {
240+
for (const source of [
241+
'record.quantity * record.hours',
242+
'record.quantity / record.hours',
243+
'record.quantity + record.hours',
244+
'quantity * hours', // bare identifiers resolve like `record.<field>`
245+
'record.flag ? record.quantity : record.hours',
246+
'max(record.quantity, record.probability)',
247+
]) {
248+
expect(inferExpressionType(source, { fields: NAMES }), source).toBe('unknown');
249+
expect(inferFormulaReturn(source, FIELDS), source).toEqual({ returnType: 'number' });
250+
}
251+
});
252+
253+
it('a ratio of two amounts in one currency answers `number`', () => {
254+
expect(inferExpressionType('record.amount / record.tax', { fields: NAMES })).toBe('unknown');
255+
expect(inferFormulaReturn('record.amount / record.tax', FIELDS)).toEqual({ returnType: 'number' });
256+
expect(inferFormulaReturn('record.budget / record.spent', FIELDS)).toEqual({ returnType: 'number' });
257+
});
258+
259+
it('CONTROL — money over two field reads still stamps `currency`, and an unproven `dyn` stays `{}`', () => {
260+
expect(inferFormulaReturn('record.amount * record.quantity', FIELDS))
261+
.toEqual({ returnType: 'currency', currencyConfig: USD });
262+
for (const source of [
263+
'record.amount / record.fee_eur', // a ratio across two currencies
264+
'record.quantity / record.amount', // a quantity divided by an amount
265+
'record.amount * record.tax', // an amount times an amount
266+
'record.quantity * record.subtotal', // a formula that declares no returnType
267+
'record.quantity * record.rollup', // a roll-up operand
268+
'record.quantity * record.name', // a text operand
269+
'record.quantity * record.unknown_field', // a name the map does not declare
270+
]) {
271+
expect(inferFormulaReturn(source, FIELDS), source).toEqual({});
220272
}
221-
expect(inferFormulaReturn("record['quantity'] * 2", FIELDS)).toEqual({ returnType: 'number' });
273+
});
274+
275+
it('accepted limit — a quantity read through a relationship stays unproven: its unit is not in the host map', () => {
276+
// The producer header records this limit: the related object's fields are
277+
// not an input, so the leaf's unit cannot be read.
278+
expect(inferExpressionType('record.account.employee_count * 2', { fields: NAMES })).toBe('number');
279+
expect(inferFormulaReturn('record.account.employee_count * 2', FIELDS)).toEqual({});
222280
});
223281
});
224282

‎packages/formula/src/formula-return.ts‎

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,29 @@
6565
* not on this object;
6666
* - a read whose key is computed, or a name the map does not declare.
6767
*
68-
* So a numeric formula over declared quantities stays `number`. The CEL type
69-
* still decides once the proof succeeds: a bare ratio of two amounts in one
70-
* currency (`record.amount / record.tax`) is proven a plain number, but cel-js
71-
* types it `dyn`, so it answers `{}` and a declared `currency` is kept. A
72-
* `summary` field is not read as a quantity: a roll-up of a currency field is
73-
* itself money, and its source type is not on this object.
68+
* So a numeric formula over declared quantities stays `number`. Once the unit
69+
* proof succeeds the CEL type is not asked to prove "numeric" again (#35815):
70+
* an operator over two field reads (`record.quantity * record.hours`, or a
71+
* bare ratio of two amounts in one currency, `record.amount / record.tax`)
72+
* types `dyn`, because a field read is `dyn` to cel-js, but every operand the
73+
* proof followed is a declared number, so the result is a plain number and
74+
* answers `number` — a declared `currency` is withdrawn on that edit, exactly
75+
* as it is for `record.quantity * 2`. A `summary` field is not read as a
76+
* quantity: a roll-up of a currency field is itself money, and its source type
77+
* is not on this object.
78+
*
79+
* ## Accepted limit — a read through a relationship stays unproven
80+
*
81+
* `record.account.employee_count * 2` answers `{}` (#35815). The leaf is a
82+
* field of the RELATED object, and this function is handed the host object's
83+
* field map only: neither the reference's target object nor that object's
84+
* fields are in its input, so the leaf's unit cannot be read, and an unread
85+
* unit is never answered `number`. A declared `currency` is therefore kept on
86+
* an edit into such a read — the safe direction: the author's declaration
87+
* stands until an edit proves the result is not money. Proving it would need
88+
* the related objects' declared fields as a further input to this function
89+
* (and a caller that loads them), which is a change to its published
90+
* signature, not to the proof.
7491
*/
7592

7693
import { CurrencyConfigSchema, NUMERIC_VALUE_TYPES, type Field } from '@objectstack/spec/data';
@@ -360,10 +377,13 @@ function sourceOf(input: ExprInput): string | null {
360377
* formula with no `returnType`, a non-`count` roll-up, a reference hop, a
361378
* computed key, an undeclared name) ⇒ `{}`, unproven. `number` is never
362379
* the answer there: a stamp reads it as "proved not money".
380+
* - A numeric expression the unit proof DOES prove a plain number, whose CEL
381+
* type is `dyn` (an operator over two field reads: `record.quantity *
382+
* record.hours`, a same-currency ratio `record.amount / record.tax`) ⇒
383+
* `{ returnType: 'number' }` (#35815): the proof read every operand's unit.
363384
* - Otherwise ⇒ the {@link inferExpressionType} answer as `returnType`
364-
* (`number` / `text` / `boolean` / `date`), or `{}` when that is `unknown`
365-
* (a bare same-currency ratio such as `record.amount / record.tax` types
366-
* `dyn`), so a numeric formula over declared quantities stays `number`.
385+
* (`number` / `text` / `boolean` / `date`), or `{}` when that is `unknown`,
386+
* so a numeric formula over declared quantities stays `number`.
367387
*
368388
* Pure and conservative: it never throws, and an expression that does not
369389
* type-check is never money.
@@ -392,6 +412,10 @@ export function inferFormulaReturn(
392412
}
393413
return { returnType: 'currency' };
394414
}
415+
// #35815 — the unit proof read every operand as a declared number, so a
416+
// `dyn` CEL type (a field read is `dyn` to cel-js) is no reason to leave
417+
// the result unproven: it is a plain number, proved not money.
418+
if (celType === 'dyn' && isPlainNumber(dim)) return { returnType: 'number' };
395419
// #35631 — `number` means proved not money: unless the unit proof
396420
// succeeded, every record read must name a declared field whose unit
397421
// can be read and is not money, or the answer is unproven.

‎ui/packages/app-shell/src/views/metadata-admin/inspectors/ObjectFieldInspector.returnTypeHeld-27485.test.tsx‎

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ function stubEngine({ money = false }: { money?: boolean } = {}) {
7272
if (src.includes("'")) return 'text' as const;
7373
if (src.includes('+')) return 'unknown' as const;
7474
// A field-over-field operator types `dyn`, as the engine answers it
75-
// (formula-return.ts): the quotient's type is unproven.
76-
if (/record\.\w+\s*\/\s*record\./.test(src)) return 'unknown' as const;
75+
// (formula-return.ts): the product's or quotient's CEL type is unproven.
76+
if (/record\.\w+\s*[*/]\s*record\./.test(src)) return 'unknown' as const;
7777
if (src.includes('>')) return 'boolean' as const;
7878
return 'number' as const;
7979
},
@@ -94,6 +94,7 @@ function Harness({
9494
est_hours: { type: 'number' },
9595
budget: { type: 'number' },
9696
amount: { type: 'currency', currencyConfig: USD },
97+
tax: { type: 'currency', currencyConfig: USD },
9798
total: { type: 'summary', summaryOperations: { object: 'line', field: 'amount', function: 'sum' } },
9899
fee_eur: { type: 'currency', currencyConfig: EUR },
99100
home_amount: { type: 'currency' },
@@ -256,9 +257,12 @@ describe('ObjectFieldInspector — the money verdict proves or withdraws a decla
256257
});
257258

258259
it('an unproven verdict (a field-over-field quotient) still keeps a declared `currency`', async () => {
260+
// objectstack#35815 — a quantity over an amount: the proof cannot read it
261+
// as a plain number, so the verdict is unproven. (Two quantities, as
262+
// `record.est_hours / record.budget`, are proven `number` now.)
259263
const { box, latest } = asCurrency();
260-
fireEvent.change(box, { target: { value: 'record.est_hours / record.budget' } });
261-
await waitFor(() => expect(latest().expression).toBe('record.est_hours / record.budget'), { timeout: 3000 });
264+
fireEvent.change(box, { target: { value: 'record.est_hours / record.amount' } });
265+
await waitFor(() => expect(latest().expression).toBe('record.est_hours / record.amount'), { timeout: 3000 });
262266
await settle();
263267
expect(latest().returnType).toBe('currency');
264268
expect(latest().currencyConfig).toEqual(USD);
@@ -335,3 +339,43 @@ describe('ObjectFieldInspector — the money verdict proves or withdraws a decla
335339
expect('currencyConfig' in latest()).toBe(false);
336340
});
337341
});
342+
343+
describe('ObjectFieldInspector — a field-over-field quantity withdraws a declared currency (objectstack#35815)', () => {
344+
// The CEL type of an operator over two field reads is `dyn`, so the plain
345+
// inference proves nothing; the engine's money verdict reads both operands'
346+
// declared units and answers `number`, which withdraws the `currency`.
347+
const MONEY = 'record.amount * 0.1';
348+
const asCurrency = () => renderFormula('currency', { money: true, extra: { expression: MONEY, currencyConfig: USD } });
349+
350+
it("the card's repro: an edit from an amount to quantity-times-quantity drops `currency` and its `currencyConfig`", async () => {
351+
const { box, latest } = asCurrency();
352+
fireEvent.change(box, { target: { value: 'record.est_hours * record.budget' } });
353+
await waitFor(() => expect(latest().returnType).toBe('number'), { timeout: 3000 });
354+
expect(latest().expression).toBe('record.est_hours * record.budget');
355+
expect('currencyConfig' in latest()).toBe(false);
356+
});
357+
358+
it('a ratio of two amounts in one currency drops `currency` too: it is a plain number', async () => {
359+
const { box, latest } = asCurrency();
360+
fireEvent.change(box, { target: { value: 'record.amount / record.tax' } });
361+
await waitFor(() => expect(latest().returnType).toBe('number'), { timeout: 3000 });
362+
expect(latest().expression).toBe('record.amount / record.tax');
363+
expect('currencyConfig' in latest()).toBe(false);
364+
});
365+
366+
it('CONTROL — a ratio across two currencies is unproven and keeps the declared `currency`', async () => {
367+
const { box, latest } = asCurrency();
368+
fireEvent.change(box, { target: { value: 'record.amount / record.fee_eur' } });
369+
await waitFor(() => expect(latest().expression).toBe('record.amount / record.fee_eur'), { timeout: 3000 });
370+
await settle();
371+
expect(latest().returnType).toBe('currency');
372+
expect(latest().currencyConfig).toEqual(USD);
373+
});
374+
375+
it('CONTROL — an amount times a quantity over two field reads still proves money', async () => {
376+
const { box, latest } = asCurrency();
377+
fireEvent.change(box, { target: { value: 'record.fee_eur * record.est_hours' } });
378+
await waitFor(() => expect(latest().currencyConfig).toEqual(EUR), { timeout: 3000 });
379+
expect(latest().returnType).toBe('currency');
380+
});
381+
});

0 commit comments

Comments
 (0)