Skip to content

tests(clerk_flutter): improving ClerkSignInPanel and ClerkSignUpPanel tests - #429

Open
MarkOSullivan94 wants to merge 1 commit into
mainfrom
428-improve-clerksigninpanel-and-clerksignuppanel-test-coverage-and-move-them-out-of-testintegration
Open

tests(clerk_flutter): improving ClerkSignInPanel and ClerkSignUpPanel tests#429
MarkOSullivan94 wants to merge 1 commit into
mainfrom
428-improve-clerksigninpanel-and-clerksignuppanel-test-coverage-and-move-them-out-of-testintegration

Conversation

@MarkOSullivan94

@MarkOSullivan94 MarkOSullivan94 commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Resolves #428

Why

The ClerkSignInPanel and ClerkSignUpPanel tests under test/integration/ were a solid starting point for exercising the sign-in and sign-up flows, but they run with flutter_test against mocked services rather than on a device, so they are widget tests by Flutter's definition — and with Patrol now covering true end-to-end flows (#410, #412), the folder name no longer reflected what they do.

While moving them, I noticed the tests could only verify that ClerkSignInPanel and ClerkSignUpPanel themselves were present in the tree: both panels build an empty widget when no Environment is available, and the test mocks only supplied a Client, so no form fields or buttons were rendered beneath them. Supplying a mocked environment lets the tests assert on the actual UI for each scenario.

What

Test support

  • Added createTestEnvironment(), building an Environment from required/optional user attributes (with matching verification strategies) and identification strategies. The two panels have different rendering gates: ClerkSignUpPanel is driven by env.user.attributes, while ClerkSignInPanel requires a non-empty env.config.identificationStrategies.
  • createTestAuthState() now accepts an environment, served by TestHttpService from the mocked /environment endpoint.

Test files

  • test/integration/*test/widgets/clerk_sign_in_panel_test.dart and test/widgets/clerk_sign_up_panel_test.dart, one file per widget under test.
  • Each test now supplies an environment matching its scenario and asserts on what actually renders (form fields, strategy buttons) rather than just the panel's presence.
  • Consolidated overlapping password-factor scenarios in the ClerkSignInPanel tests into one test each for: password, email code, password + email code, phone code, and second factor (TOTP + backup code).
  • Aligned group/test naming with the existing unit tests: groups named for the widget under test, test names as behaviour statements (renders X when Y).

Test plan

  • flutter test in packages/clerk_flutter: 779 passed, 7 skipped (count down from 781 due to consolidating duplicate scenarios).

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve ClerkSignInPanel and ClerkSignUpPanel test coverage and move them out of test/integration/

1 participant