Skip to content

NumberForm foundation 0: baseline characterization tests for NumberWithSymbolForm #98168

Closed

Description

@mountiny

Sub-issue of #97970.
Migration plan: jmgraa comment.

NumberWithSymbolForm has no dedicated test file. Two of its three render paths have zero coverage. Before any of the composition work starts, this issue writes characterization tests against the component exactly as it exists today, so every later batch has a regression net to run.

This is the only issue in the decomposition that does not change production code.

Scope

  • Step: prerequisite, added ahead of step 1 of the migration plan
  • Scope: 1 new test file

Coverage today

Only two tests mount the component at all, both indirectly and both through the portrait path:

  • tests/ui/IOURequestStepHoursTest.tsx — renders IOURequestStepHours, asserts the hrs symbol renders and that the value prefills. The component name appears only in comments, not as an import.
  • tests/ui/IOURequestStepAmountDraftTest.tsx — renders IOURequestStepAmount → MoneyRequestAmountForm → MoneyRequestAmountInput → NumberWithSymbolForm, asserts getByTestId('moneyRequestAmountInput').

Nothing covers the displayAsTextInput path or the landscape path.

Files

  • tests/ui/NumberWithSymbolFormTest.tsx — new

What to cover

Three render paths, all reached by early return in src/components/NumberWithSymbolForm.tsx:

  1. displayAsTextInput (line 542) — plain TextInput with rightHandSideComponent. No number pad, no ScrollView, no landscape handling.
  2. isInLandscapeMode (line 636) — row ScrollView, shared textInputComponent, button row, FormHelpMessage, BigNumberPad, footer.
  3. Portrait default (line 701) — ScrollView, optional shouldWrapInputInContainer wrapper, up to two currency buttons, pad and footer block.

The imperative contract, which every migration batch must preserve verbatim:

  • NumberWithSymbolFormRef = {clearSelection, updateNumber, getNumber}, wired through useImperativeHandle (line 431). 8 files hold one of these refs.
  • The separate ref?: ForwardedRef<BaseTextInputRef> prop, which is not React forwardRef and is fanned out manually to both ref and the internal textInput in each path.

Behaviour that differs per path and is easy to lose in a refactor:

  • Negation. The displayAsTextInput path calls the internal handleFlipPress (line 470). The other two call the caller supplied toggleNegative. Cover both.
  • Value setting. setNewNumber (line 283) serves the pad and the symbol input. setFormattedNumber (line 323) serves displayAsTextInput only and additionally applies addLeadingZero. Cover the leading zero difference explicitly.
  • Selection. handleSelectionChange (line 444) with shouldIgnoreSelectionWhenUpdatedManually and shouldUpdateSelection both set and unset.
  • Validation and rejection through validateAmount with decimals, maxLength, allowNegativeInput and allowFlippingAmount.
  • Backspace on an empty input while negative (line 414) clears the sign.

Out of scope

  • Any change to src/components/NumberWithSymbolForm.tsx. These tests describe current behaviour, including behaviour we consider wrong.
  • Testing the dead props. They are documented in the deprecation guide instead.

Acceptance criteria

  • tests/ui/NumberWithSymbolFormTest.tsx covers all three render paths
  • All three NumberWithSymbolFormRef methods are asserted
  • Both negation mechanisms are asserted
  • The addLeadingZero difference between the two value setters is asserted
  • Tests pass on main with no production code change
  • Verify that no errors appear in the JS console

Dependencies

Issue OwnerCurrent Issue Owner: @bernhardoj

Activity

  1. added
    Weekly
    Skip Payment
    on Aug 10, 2026
  2. added
    Reviewing
    Daily
    and removed
    Reviewing
    Weekly
    on Aug 14, 2026
  3. melvin-bot commented on Aug 21, 2026

    @melvin-bot

    @bernhardoj

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.57-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2026-08-28. 🎊

    The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

DailySkip PaymentTask

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions