Commit Graph
119 Commits
Author SHA1 Message Date
Ryan StellyandJohannes Klein 63da9cbcfb upgrade to nativewind@4 (#3826)
* nativewind 4 spike

* themed and cssInterop fixes

* clearify comment on inline Animated.View styles

* remaining style fixes and supplementary agent docs

* fix pill button on media screens

---------

Co-authored-by: Johannes Klein <17345891+jtklein@users.noreply.github.com>
2026-08-24 20:23:03 -05:00
Ryan Stelly 277816b0e0 MOB-1458 use local observation ids (#3763)
* only return observations from useLocalObs

* remove unnecessary var

* export unsync'd filter

* remove obsoleted numUnuploadedObservations zustand state

* tests, typo

* fix tests

* add sync fields to keypaths & depp array

* consistent naming

* handle only ids downstream

* switch over to useIds

* restore ids return

* memoize realm mapping result

* extract realm hooks mocks into factory-available helper

* reapply to myobsresults

* reapply to myobsresults

* go back to wrapped ids for list parity

* fix test

* restrict mocked prop for more accurate MyObsSimple test

* comment cleanup

* fix fake timer flake w/ corrected setup

Claude:

1. withAnimatedTimeTravelEnabled({ skipFakeTimers: true }) does NOT call jest.useFakeTimers(), but still calls jest.setSystemTime(new Date(0)) in beforeEach — which requires fake timers.
2. Both SoundRecorder.test.js and PhotoDeletionExisting.test.js (and ObsEdit.test.js) call global.timeTravel(300) inside waitFor, which also requires fake timers.
3. Tests pass flakily when fake timers accidentally leak from another test file running in the same Jest worker. When they don't leak, timeTravel throws.
4. FadeInView is fully mocked to a plain View (instant) and Reanimated uses setUpTests(), so the 300ms timeTravel isn't actually advancing any real animation — it's just broken.

The fix: guard setSystemTime with the same check, and remove the timeTravel(300) calls from waitFor in tests that use skipFakeTimers: true.

* fix remaining time travel uses

* reset / restore timers to fix leaking fake timers
2026-06-30 11:48:47 -05:00
Johannes Klein 1c56e0da65 Mock new endpoints 2026-06-20 00:08:03 +02:00
Johannes KleinandJohannes Klein b498ffd379 Fix broken integration tests (#3720)
* Move one broken test and switch back to toBeVisible

* Remove comments

* Move without changes

* Add helper function

* Call mock helper in beforeAll

* Add fileName to mock assets

* Refactor navigateToPhotoImporter into helper

* Use fake timers and time travel

* File move without changes

* Add import

* Update addObsBottomSheet.js

* Refactor navigation steps into new helpers

* Add layout setup

* Use skipFakeTimers here

* Remove setup

* Replace final expectation

* Add mock for Mortal in a new helper file

* Sort imports

* Remove superfluous act

* Move file without changes

* Add time travel to final expect

* Use Mortal mock

* Change one test expect

TODO: is this still the same behaviour tested, toBeNull can be of other reasons as well?

* Refactor nav to Standard camera into new helpers

* Replace fireEvent with userEvent

* Update imports

* Move file without changesUpdate firebase mock

* Move file without changes

* Add Mortal mock

* Use toBeVisible again

* Use toBeVisible

* Refactor nav to AI camera into helpers

* Refactor take photo and na into helpers

* Refactor an action of the two previous combined actions

* Somehow there were two identical describe

* Wrong order

* No longer needed

* Refactor last expect of this test into helper

* Use global time travel here

* Remove import

* Move file without changes

* Use toBeVisible again

* Use Mortal mock

* Re-use already made helper fct here

* Fix imports

* Move file without changes

* Enable animated time travel

* Use toBeVisible

* Add time travel to last expects

* Remove double checks for being on the correct screen

* Move file without changes

* Add fileName to mock assets

* Switch back to toBeVisible

* Enable animated time travel

* Add time travel to last expect

* Re-use new navigation helper

* Add mock for InteractionManager

* Move file without changes

* Use toBeVisible again

* Add InteractionManager mock

* Add animate time travel

* Missing import

* Remove from previous commit

* Add helper shell

* Move the Save button press

* Move missing evidence sheet dismissal

* Update MyObservations.test.js

* Set screen after photo import

* Remove import

* Sort imports

* Add a mock for ImagePicker

* Navigate to PhotoImported instead of No evidence option

Does not matter for this test where the new obs comes from

* Re-use helper fct

* Arg name

* Disable lint

* Move file without changes

* Replace with new helper fct

* Enable animated time travel

* Replace also below with new helper

* Move fct call

* Use toBeVisible again

* Use toBeVisible again

* Use toBeVisible again with different find strategy

* Remove trip through Suggestions for this test

* Add InteractionManager mock

* Move beforeEach

* Move function call

* Re-use new helper function

* Handle saveOptions

* Missing imports

* Add helper function

* Wait for toolbar helper

* Wait for the element like we did before this PR

* Wait for one more element

* Update PhotoImport.test.js

* Comment out optional wait

* Rename arg

* File move without changes

* Re-use new helper function

* Re-use new helper function

* Use toBeVisible again

* Enable animated time travel

* Add a new find

* New helper fct

* Remove local version of confirm

* New take photo helper does more, so restrict to not confirm the photo yet here

* Update PhotoDeletion.test.js

* Update PhotoDeletion.test.js

* Remove fake timers

* Missing imports

* Add Mortal mock

* Update PhotoDeletion.test.js

* Update PhotoDeletion.test.js

* Copy PhotoDeletion test into new file to split out tests about existing photos

* Remove other todo test

* Add InteractionManager mock

* Remove Mortal mock

* Remove new photo test

* Delete new photo test

* Remove existing photo test

* Remove existing photo test

* Remove helper fct

* Remove import

* This should not have been deleted

* Refactor to use new helpers to create an obs with photo and wait on ObsEdit

* Add the part until we wait on ObsEdit

* Remove double await

* Rename describe

* This was wrongly inserted here

* Wait with time travel to be on camera

* At this point we have two photos, so tap on first one

* Update PhotoDeletionExisting.test.js

* Move beforeEach

* That was wrong, we should not have taken a second photo

* Remove cv mock

* Add import

* Add import

* Add import

* Remove location mock

* Update PhotoDeletionExisting.test.js

* Move file without changes

* Switch back to toBeVisible again

* Re-use new helper fct

* Add Mortal mock

* Move broken tests without changes

* Mock Mortal

* Use toBeVisible again

* Re-use new helper fct

* Enable animated time trael

* Camera needs different layout state

* This was pressing twice

* Remove tiny local helper

* Re-use local helper

* Remove unused code

* Remove ignore Paths

Yay

* Remove unused helper

* Update react-native-fs.ts

* Move fct out of try/catch

* Revert "Move fct out of try/catch"

This reverts commit f9a138e0dd.

* Only have find text in try catch

* Add mock for useObject

* Remove broken test

---------

Co-authored-by: Johannes Klein <17345891+jtklein@users.noreply.github.com>
2026-06-18 14:37:58 +02:00
Johannes Klein e352905ba8 Mob 1415 third party acknowledgements in about screen (#3664)
* Add react-native-legal

* Update package-lock.json

* Update Podfile.lock

* Git ignore the results of the license gathering script

* Run "npx react-native legal-generate"

* Update .gitignore

* Type navigation in About

* Add link to About to show licenses

* Update strings.ftl

* Add step into build process

* Add jest mock

* Add npm script for legal-generate

* Update project.pbxproj
2026-05-28 10:20:13 +02:00
Abbey Campbell e2346888fb mock only screenOptions 2026-03-25 12:18:36 -07:00
Abbey Campbell a19fb0541c add polyfill for idleCallback 2026-03-23 23:46:37 -07:00
Johannes Klein c7b596a519 Update react-native-logs jest mock (#3450)
* Update jest.setup.js

* Let's log all args instead
2026-03-19 09:34:53 +01:00
Abbey Campbell 41f66ecf3c Merge pull request #3427 from inaturalist/mob-1234-upgrade-react-native-reanimated-to-latest-version-and-fix
Mob 1234 upgrade react native reanimated to latest version and fix
2026-03-12 16:22:43 -07:00
Abbey Campbell 1a7faba1d9 remove eslint-disables 2026-03-12 15:15:08 -07:00
Abbey Campbell a7f262d9d6 add mock for worklets and update snapshots 2026-03-11 13:06:09 -07:00
sepeterson b3ec2788a6 MOB-1182: mocks for unit tests 2026-02-26 11:10:42 -06:00
Ryan Stelly b78be9243d lint rule & autofix for "trailing comma" (#3299)
* (lint) MOB-1063 enforce trailing commas

* autofix trailing commas

* manually fix newly introduced maxlen violations

* add trailing comma convention to i18n build
2025-12-22 20:17:13 -06:00
Abbey Campbell f05d79be24 remove isTest flag, override bottom-tabs animation in jest setup, add comments to detox fix 2025-12-09 18:48:17 -08:00
sepeterson 403be86702 MOB-991 fix perf jest mock 2025-11-25 08:05:31 -06:00
sepeterson fb4a994dd0 MOB-991 add jest mock for perf 2025-11-12 16:15:36 -06:00
Johannes Klein bad9c5a4d8 Add firebase dependency, and basic logging (#3127)
* Update package.json

* Update AppDelegate.mm

* Update Podfile

* Update .gitignore

* Update link-inat-model-files.sh

* Add plist file to project

* Update project.pbxproj

* Add analytics package

* Update project.pbxproj

* Update PrivacyInfo.xcprivacy

* Basic screen tracking

* Basic button press logging to firebase

* Update package-lock.json

* Update Podfile.lock

* Add Android setup

* Update .gitignore

* Add analytics mock

* Ignore rubocop warning here

* Create GoogleService-Info.example.plist

* Create google-services.example.json

* Add instructions to set up Firebase configs

* Update e2e_ios.yml

* Update e2e_android.yml

* Better plural

* Use specific XCode version in e2e CI

* Update GoogleService-Info.example.plist

* Revert "Update GoogleService-Info.example.plist"

This reverts commit 0bc0ed4862.

* We need an actual real app id or we get a crash during app start

* My bad, we do need both files for building

* Also set API key

* Add comments

* Add comment

* Update Podfile.lock

* Revert "Use specific XCode version in e2e CI"

This reverts commit cbd63d1b5d.
2025-10-16 13:15:10 +02:00
Johannes Klein 9c90c2e45f Update react-native to 0.79 (#3051)
* Upgrade helper: package.json

* Upgrade helper: gems

* Upgrade helper: Android

* Update AppDelegate

* Fix error in compiling

* Update package-lock.json

* Update Podfile.lock

* Update package-lock.json

* Update Podfile.lock

* Remove no longer needed mock

* Comment out entire test and not only the expect call

* Most other unit tests use this render helper function that

wraps the component in the entire app.

* Mock react-native exports as esModule

* Update .flowconfig

* Update Gemfile

* Revert "Comment out entire test and not only the expect call"

This reverts commit 8785f81529.
2025-10-01 22:44:14 -05:00
Corey FarwellandJohannes Klein a43446909c Remove the need to specify TypeScript file extensions in imports (#3094)
* Don't require TS extensions in imports

* Resolve all import extension errors

* Remove file extension from import paths used in mocks

* Remove .d of type definition file paths

* Remove .d of type definition file and import as type

---------

Co-authored-by: Johannes Klein <johannes.t.klein@gmail.com>
2025-09-07 23:41:42 +02:00
Johannes Klein dc1e1ec3f1 Testing with mocked FadeInView component (#3064)
* Repair integration test

* Repair Explore.test.js

* Move no longer broken test

* Mock the fadeInView that does screen transitions in tests

* Mock another fade in view
2025-08-22 21:09:23 +02:00
Johannes Klein 4e7322ed3b Update react native gesture handler (#2955)
* Update react-native-gesture-handler

Version 2.18.x introduces support for RN 0.75

* Update package-lock.json

* Update Podfile.lock

* Fix PhotoLibrary tests

* Update jest.setup.js

* Remove time travel calls
2025-06-11 23:24:38 +02:00
bb31c1907b Update react navigation libraries for performance (#2903)
* Update navigators and create util for tabstack navigation

* Changes for react navigation 7

* Refactor to use navigateToTabStack throughout app

* Add comment about unmountOnBlur

* Get all unit tests passing; remove navutils & mock HeaderBackButton

* Fix animation issues in tests

* Temporarily remove parts of tests with back functionality

* Fix tests

* Delete ios/iNaturalistReactNative.xcodeproj/project.pbxproj

* Fix pbxproj

* Code cleanup; minimize unnecessary changes

* Fix tests

* Downgrade react-native-screens to v4.4.0 (#2918)

react-native-screens version 4.5.0 increases the react native version that it supports to 0.74.0+ (https://github.com/software-mansion/react-native-screens/pull/2613/files). So, by using 4.4.0 we are still able to build the app on Android as we are still on 0.73 for now (have tested and it works).
Have not seen any effect on the changes related to the latest react-navigation versions.

* Make requested changes

* Speed up Explore nearby tile loading (#2912)

* Create a performance tracker to show urltile load time in debug mode

* Set default radius to 1km, not 50km

* Code cleanup & TypeScript definitions

* Fix TypeError

* Address eslint error

* Make github actions happy

---------

Co-authored-by: Johannes Klein <johannes.t.klein@gmail.com>

* New Crowdin translations by GitHub Action (#2920)

Co-authored-by: Crowdin Bot <support+bot@crowdin.com>

* MOB-690 - Add error context to 401 errors (#2921)

* MOB-690 - Add error context to 401 errors

* Add Object.defineProperty like in the other error classes

* Add logger line

* Also throw 401 error if the error object has no response property

---------

Co-authored-by: Yaron Budowski <budowski@gmail.com>

* v1.0.4+164

* Rebase with latest version of RN screens. Remove unused code and packages, add eslint package for TS, suppress TS errors (#2924)

* New Crowdin translations by GitHub Action (#2926)

Co-authored-by: Crowdin Bot <support+bot@crowdin.com>

* New Crowdin translations by GitHub Action (#2929)

Co-authored-by: Crowdin Bot <support+bot@crowdin.com>

* Use 3 separate initial routes for tabs; hide animations on drawer screens

* Fix test

---------

Co-authored-by: Johannes Klein <johannes.t.klein@gmail.com>
Co-authored-by: Ken-ichi <kenichi.ueda@gmail.com>
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
Co-authored-by: Yaron Budowski <budowski@gmail.com>
2025-05-30 09:26:47 -07:00
Amanda Bullington 043ea1cf46 Fix: prevent multiple taps on Buttons like Suggest Id (#2833)
* Add debounce to Button to make sure users can't double tap any buttons / navigate twice

* Fix tests by mocking the Button component with a quick debounce
2025-04-08 12:46:01 -07:00
Amanda Bullington 0a7ae03832 Fix attempt: Signal 11 crash on install (#2676)
* Split up all the custom hooks in App.js; begin to only run things when they're needed

* Code cleanup
2025-02-19 19:18:08 -08:00
Ken-ichi 21a66c8580 fix: make UUIDs more random (#2629)
Replaces react-native-uuid with uuid, which might do a better job making UUIDs random
2025-01-21 15:23:15 -08:00
budowskiandAmanda Bullington f89736188c feat: use physical volume buttons to capture photo (#2495)
* Fix #2212 - use physical volume buttons to capture photo

* Fixed tests (mocking VolumeManager)

* Fixed tests (mocking VolumeManager)

* #2212 - physical volume buttons for camera capture - also in AI camera

* #2212 - additional fixes for AI camera

* Update pods

* Update pods

---------

Co-authored-by: Amanda Bullington <albullington@gmail.com>
2024-12-17 16:40:26 -08:00
Ken-ichi Ueda 9bd33b4176 test: mock installData helper 2024-11-11 10:34:37 -08:00
budowskiandKen-ichi Ueda 7b8c88c84d feat: add onboarding carousel (#2285)
Note that offsetting the onboarding images ended up being a bit hard. We're
mostly doing so with a cropped version of one of the images.

Closes #1906

Also tried to de-flake some tests:

* Use fake timers when possible
* Ensure time travel helper doesn't un-fake our timers
* Wait for time travel helper to finish so changes don't happen outside of
  act
* Stop mocking useCurrentUser in integration tests; that's app code and should
  not be mocked when integrating all parts of the app; instead use signIn /
  signOut helpers
* Remove unnecessary direct uses of act()
* Mocked some inatjs calls to prevent React Query complaints about undefined
  query return values
* Close onboarding before all e2e tests

---------

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2024-11-04 12:03:55 -08:00
Ken-ichi 88c7d778c5 feat: set app locale on install, sign in, and sign out (#2294)
* Use system locale on install
* Check for system locale when app comes to foreground (required in Android
  b/c app doesn't get restarted when system locale changes)
* Create a constant of SUPPORTED_LOCALES in loadTranslations.js
* Restart app on sign out
* Use existing transaction when writing to Realm if available (might also
  consider an approach that waits for the existing transaction to complete)
* Make value returned by useCurrentUser actually reactive

Closes #2243
2024-10-25 09:39:50 -07:00
Ken-ichi ddca126ed5 refactor: log around repeat errors (#2293)
* Catch and squelch "Network request failed" errors that happen during logging itself (#1639)
* Log around RNSI access to resolve when/where those errors occur (#1639)
* Log around JWT retrieval to resolve when/where JWT missing errors occur (#2155)
2024-10-22 15:41:54 -07:00
Amanda Bullington 67dffdcf28 Screen transitions with fade animation (#2284)
* Disable animations on tab bar screens

* Fade in pages accessible from the tab bar

* Add fade in view to stack navigator screens

* Use time travel to step through frames of animation for SoundRecorder

* Use time travel to fix all tests with fade in navigation

* Nav fix
2024-10-20 14:45:31 -07:00
Amanda Bullington cf70a4358a Move modules from jest setup to __mocks__ (#1949)
* Get a few mocks working in __mocks__ folder

* Move more mocks into __mocks__

* Move mocks

* Move zustand mock

* Add more mocks to __mocks__

* More mocks

* Move more files to __mocks__ and audit existing mocks

* Mock react navigation in __mocks__

* Restore test to help with imports after jest env torn down

* Add fake timer to integration test with userEvent

* Add RN paper mock
2024-08-11 11:27:52 -07:00
Amanda Bullington cf896a3a17 Toolbar upload status refreshes when user returns to MyObs (#1942)
* Write some failing navigation tests for MyObs navigation

* Add one more failing test to check for empty screen after all obs are deleted

* Update what happens on blur

* Changes to focus effect

* Revert "Changes to focus effect"

This reverts commit c779504cdf.

* Test: toolbar status reset when user leaves screen

* Unmock useFocusEffect in Jest; fix tests

* Minor nav mocking updates

* Fix import
2024-08-09 11:21:25 -07:00
Ken-ichi ea0afb87a9 Don't restart location fetch when view blurred (#1936)
* Don't restart location fetch when view blurred
* Removed what looked like an unnecessary callback in DisplayTaxonName
* Refactored tests
2024-08-07 17:33:22 -07:00
Amanda Bullington b8c08ae2d4 Reassure tests (#1914)
* Basic performance tests for key components

* Fix MyObs integration test with fake timers and less rerendering
2024-08-02 19:07:41 -07:00
Amanda Bullington 9a0581670f Consolidate key-value stores (#1879)
* Switch to zustand mmkv storage instead of async storage

* Update hooks using async storage

* Remove asyncstorage

* Remove LocalPreferences

* Prevent collision upserting from infinite scroll & sync remote obs
2024-07-30 09:12:26 -07:00
Amanda Bullington c3c98deeda Create new obs when backing out to AICamera (#1832)
* Write test to confirm only one obs photo added when backing out of AICamera

* Create new obs when backing out to AICamera; closes #1822
2024-07-19 09:57:16 -07:00
Amanda Bullington 92cafdde83 Land user on Suggestions when one photo imported (#1824)
* Create navigation test for PhotoGallery

* Code and test land user on Suggestions when one photo imported
2024-07-16 14:47:02 -07:00
Amanda Bullington abd4bcee23 Refactored location fetching for accurate locations (#1788)
* Refactor to use watchPosition

* Update useWatchPosition with permissions/retry

* Replace useUserLocation with useWatchPosition and fix tests; return userLocation from watch position hook

* Only update observation keys when there's an observation

* Improve TypeScript definitions

* Revert TypeScript commit

* Revert "Only update observation keys when there's an observation"

This reverts commit a4cd17a513.

* Code cleanup: make useWatchPosition more modular

* Code cleanup; location permission in ObsEdit instead of subcomponent

* Use correct accuracy in Camera photos

* Camera fixes

* Fixes to watching position in ObsEdit

* Fix useWatchPosition tests

* Fix tests

* Make sure state updates when renavigating to OsEdit; test fixes
2024-07-16 09:23:09 -07:00
Ken-ichi fe0229291e Restore photo deletion (#1789)
* Restore photo deletion
* Rename methods for accessing media files
* Added integration test for photo deletion
* Cleaned up some accessibility labels

Closes #1429
2024-07-10 15:23:53 -07:00
Ken-ichi 50d9d1e60c Media clearing (#1771)
* (Re-)Fix bug where shared photo got deleted before it could be used
* Only run cleanup when MyObs has focus
* Only run cleanup once a minute
* Only delete files that are a day old or more
2024-07-05 21:33:52 -07:00
Amanda Bullington 452ebcbdf4 Navigate user correctly with selected ID when coming from TaxonDetails (#1766) 2024-07-03 16:29:46 -07:00
Ken-ichi Ueda 6788601751 Bugfix: first photo was not getting saved to gallery from StandardCamera 2024-06-14 10:44:15 -07:00
Amanda BullingtonandKen-ichi Ueda aa167c669d Refactor upload functionality into hook/zustand (#1606)
* Refactor upload code into hook and zustand slice

* Create a single source of truth for toolbar and individual progress

* Fix unit tests

* Fix more tests

* Continue trying to simplify upload progress and status code

* Continued overhaul of upload code

* Fix exclamation point in Toolbar

* Fix total toolbar progress

* Fix tests

* Update snapshots

* Code cleanup

* Update MyObs test

* Fix most tests by not deleting realm

* Keep attempting to make toolbar text clear in subsequent tests

* Mock Zustand and reset state after all tests

In theory this should make testing with Zustand simpler. The real kicker is
that resetting state will fail if we're not careful about manually replacing
nested objects in Zustand state updates.

* Bugfix: removeAllFilesFromDirectory works with File objects, not raw paths

* Update status text when uploads canceled

* Only show red exclamation rotating icon after all uploads attempted

* Fix progress bar with zustand nested object

* Fix toolbar progress

---------

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2024-05-30 20:36:50 -07:00
Ken-ichi Ueda 1aed88b9f9 Several attempts at error handling
* Catch 401 errors when we try to fetch remotely deleted obs for signed out
  users
* Skip the check to see if a user is a friend on UserProfile when signed out
* Replace uses of RNFS.unlink() with a wrapper that ignores errors about files
  not existing
* Tried to get safeRealmWrite to preserve error type before re-throwing
2024-05-29 17:32:43 -07:00
Amanda Bullington 917f9da7be Clear cached photos for computervision/score_image (#1518)
* Refactor image-resizer into helper function for easy logging

* Create a folder for computerVisionSuggestions

* Display iNat app directories in Debug

* Delete old images from computerVisionSuggestions/ when navigating away from Suggestions

* Fix online suggestions API call

* Fix tests

* Clear computer vision directory when landing on Suggestions screen
2024-05-09 13:32:52 -07:00
Johannes Klein ea6539e35a Vision camera v4.0.3 (#1515)
* Upgrade vision-camera, worklets and plugin

* Update Podfile.lock

* Update runAsync patch

* Update comment

* Update jest.setup.js
2024-05-08 13:48:16 +02:00
Johannes Klein 05b6309307 Vision camera 4.0.1 (#1437)
* Update camera and plugin packages

* Remove one patch

* Replace deprecated function

* Update runAsync patch

Removing this patch leads to non-functioning frame processors in release builds. Contrary to what the original issue's solution states.
2024-04-23 14:27:27 +02:00
Johannes Klein 84d506f184 Mock format 2024-04-22 13:36:04 +02:00
Johannes Klein 700990ba0b 1305 Remove predictions state on blur and focus (#1402)
* Remove predictions state on blur and focus

* Mock for plugin function

* Fix mock

* Update mock

* Rename ARCamera test files
2024-04-17 12:32:53 +02:00