test: add component interaction tests for buttons, forms, navigation (#53)#481
Open
menawar wants to merge 1 commit into
Open
test: add component interaction tests for buttons, forms, navigation (#53)#481menawar wants to merge 1 commit into
menawar wants to merge 1 commit into
Conversation
Adds @testing-library/react-native interaction tests that simulate real user behaviour (issue Smartdevs17#53). Until now the suite only had logic/store/ service tests and no component rendering or interaction tests. New suites (24 tests): - Button: onPress called once, not called when disabled/loading, busy/disabled accessibility state - FloatingActionButton: onPress, icon/title rendering, accessibility label - FilterBar: search changeText, clear button, filter press, active count - SubscriptionCard: onPress receives the subscription, confirm-then-toggle flow, conditional toggle rendering/labelling - AddSubscriptionScreen: empty-name and invalid/missing-price validation, valid submit calls addSubscription with the entered data, cancel navigates back, dirty-form cancel prompts to discard Shared infrastructure: - src/test-utils.tsx: provider-wrapped render (SafeAreaProvider + NavigationContainer); supplies concrete safe-area metrics so children render under Jest where initialWindowMetrics is null - src/__fixtures__/subscriptions.ts: typed Subscription fixtures Tooling notes (required to run RN component tests, were not present): - devDeps: @testing-library/react-native@13.3.3, react-test-renderer@19.2.5 - overrides: hermes-parser / babel-plugin-syntax-hermes-parser pinned to 0.33.3 so babel-preset-expo can parse react-native 0.85 Flow source (the Expo 53 toolchain shipped 0.25.1, which fails on RN 0.85's `const` type parameters) No source/config files were modified beyond package.json. The 9 pre-existing failing suites (date-dependent business logic / network) are unchanged. Closes Smartdevs17#53 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@menawar Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #53
Summary
Adds
@testing-library/react-nativeinteraction tests that simulate real user behaviour. Previously the suite had only logic/store/service tests and no component rendering or interaction tests.24 new tests across 5 suites, all passing.
Components/screens that received new interaction tests
components/common/ButtononPresscalled once; not called whendisabled; not called whenloading; busy/disabled accessibility statecomponents/common/FloatingActionButtononPress; icon/title rendering; custom accessibility labelcomponents/home/FilterBarchangeText, clear button, filter-button press, active-filter count (badge + a11y label)components/subscription/SubscriptionCardonPressreceives the subscription; confirm-then-toggle flow viaAlert; conditional toggle render/labelscreens/AddSubscriptionScreenaddSubscriptionwith entered data, cancel navigates back, dirty-form cancel prompts to discardAcceptance criteria
onPresstestedgoBack, discard-changes guard)24/24)Shared infrastructure
src/test-utils.tsx— provider-wrappedrender(SafeAreaProvider+NavigationContainer). Supplies concrete safe-area metrics becauseinitialWindowMetricsisnullunder Jest, which would otherwise stopSafeAreaProviderfrom rendering its children.src/__fixtures__/subscriptions.ts— typedSubscriptionfixtures shared across suites.testID props added to components
None. All queries use existing
testIDs, accessibility labels, placeholder text, role, or visible text. No source/component files were modified.Tooling changes (required — were not present)
The issue assumed
@testing-library/react-nativewas installed; it was not, nor wasreact-test-renderer. To make RN component tests runnable:@testing-library/react-native@13.3.3,react-test-renderer@19.2.5overrides:hermes-parser/babel-plugin-syntax-hermes-parserpinned to0.33.3. The Expo 53 toolchain ships0.25.1, which cannot parsereact-native@0.85's Flowconsttype parameters;0.33.3is the version RN 0.85 itself declares. Without this, any native-component render throws a parse error.These are the only changes to
package.json; no other config files were touched.Verification
npx jest <new suites>→ 24/24 passtaxService,slaStore,walletService) and are unchanged by this PR — the committed baselinetest_output.txtalready shows failing suites.npx tsc --noEmit→ no type errors in the new files; noany, no@ts-ignore, no snapshots.eslint+prettierclean on all new files.Coverage on the targeted files (previously 0%)
🤖 Generated with Claude Code