Skip to content

PhoneNumberField prefix tests miss 1-digit codes and the digits-only filter #915

Description

@marassteiner

Summary

PR #909 adds a free-text prefix field (1–3 digits, FilteringTextInputFormatter.digitsOnly, fixed + via prefixText). Widget tests cover 2-digit (43), 3-digit (423), empty-required, and the 4-digit cap. They do not cover:

  • a 1-digit prefix (+1, +7)
  • letters / mixed paste into the prefix field (the existing “digits-only” test writes only to the national-number field)
  • pasting +41 into the prefix (double-plus) or deleting the decorative +

Found while reviewing #909. Not a merge-blocker: the formatters and the ^[0-9]{1,3}$ validator already encode those rules; this is a test-coverage gap on new logic.

Evidence

  • lib/widgets/form/phone_number_field.dart:79FilteringTextInputFormatter.digitsOnly
  • lib/widgets/form/phone_number_field.dart:91RegExp(r'^[0-9]{1,3}$')
  • test/widgets/form/phone_number_field_test.dart:47,89_enterAndValidate / “digits-only” only call _numberField()
  • test/widgets/form/phone_number_field_test.dart:138-145 — 2-digit prefix
  • test/widgets/form/phone_number_field_test.dart:176-183 — 3-digit prefix
  • test/widgets/form/phone_number_field_test.dart:199-206prefixText == '+' after typing 41, no paste/+ deletion case

Suggested follow-up

Add widget tests that:

  1. Accept prefix 1 + a national number and compose +1….
  2. Enter letters / mixed paste into _prefixField() and assert they are filtered or rejected.
  3. Paste +41 and assert the stored value is still a single + plus digits.
  4. Clear the editable prefix and assert the required-prefix error.

Related

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions