Commit Graph
28 Commits
Author SHA1 Message Date
Johannes Klein 94fac460ea Update return item shape 2026-08-11 16:37:48 +02:00
Johannes Klein 9d59294168 Update mock to also have named exports 2026-08-11 16:35:29 +02:00
sepeterson 67ed9c875c MOB-1595: redo search tests 2026-08-03 17:08:38 -05: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 3036529323 Switch react-native-fs (#3524)
* Update package.json

* Update package-lock.json

* Update Podfile.lock

* Update PrivacyInfo.xcprivacy

* Update react-native-logs.config.ts

* Update paths.ts

* Update savePhotoToDocumentsDirectory.ts

* Update useAppSize.ts

* Update installData.ts

* Update mlModel.ts

* Update storageMetrics.ts

* Update removeAllFilesFromDirectory.ts

* Update util.ts

* Update removeSyncedFilesFromDirectory.ts

* Update contexts.ts

* Update index.ts

* Update Photo.ts

* Update Sound.js

* Update logManagementHelpers.ts

* Update PhotoLibrary.tsx

* Update flattenUploadParams.ts

* Update shouldFetchObservationLocation.ts

* Update Developer.tsx

* Update vision-camera.js

* Update sentinelFiles.ts

* Move mock

* Switch to unlink util
2026-04-14 00:57:20 +02:00
Johannes Klein 8597afb194 Defer some StartupService tasks to idle callbacks (#3494)
* Create new component for deferred startup tasks

* Function wrapper to defer a task with requestIdleCallback

* Split cache clearing into separate callbacks

So that we can interleave user interactions, I believe.

* We have no await anymore

Also add cancel by id to effect cleanup

* Move over getStorageMetrics

* Add optional timeout param

* Change order of tasks

* Add timeout to diagnostics

* Move findAndLogSentinelFiles over

* Move checkForPreviousCrash over

* Sorry, this does not belong to this PR

But since I am here already it is just a removal without consequences.

* Add TODO

* Do not return anything from findAndLogSentinelFiles

* Rename function

* Update react-native-fs.ts

We were treating every "app start" during testing as having had some sentinel files present from a previous session, i.e. having had an error during a previous camera usage session. Changing to not having sentinelFiles present seems a more sensible default for testing to me.

* Oh, git, why?

* Refactor component to hook
2026-04-07 21:09:36 +02:00
Johannes Klein e3c53cf7ad Switch to react-native-exify (#3471)
* Update package.json

* Update package.json

* MIgrate parseExif to TS

* Update parseExif.ts

* Type exif objects

* Update types

* Remove write wrapper

* Update parseExif.ts

* Remove react-native-exif-reader

* Replace mock

* Wrongly mocked

* Replace library in test

* Update package-lock.json

* Update Podfile.lock

* Update project.pbxproj

* Append scheme if missing

* Log rejected promises reasons

* Update parseExif.ts

* Adjust exif coordinates with ref with

* Time zone error

* Revert "Time zone error"

This reverts commit 538fb244b7.

* Update parseExif.ts

* Update parseExif.test.js

* Show literal date string in debug mode

* Simpler regex

* Update parseExif.ts

* Major code cleanup

* Update parseExif.test.js

* Update parseExif.ts

* Update Observation.js

* Rename param

* Infer readExifFromMultiplePhotos return type
2026-03-29 20:32:40 +02:00
Johannes Klein 25c13c9eb5 Reapply react-native-sensitive-info update with "migration" (#3373)
* Reapply "Update react-native-sensitive-info to 5.6.2 (#3346)"

This reverts commit 4bd596074c.

* Explicitly set keychainService to "app" for all calls to RNSInfo

So, apparently the default string used to save sensitive items changed from "app" to "default" between versions 6.0.0-alpha.9 and 5.6.2.
So if we install an app update built with 5.6.2 on top of our previous version (using 6.0.0-alpha.9) we can no longer find our previously stored secrets.
I am leaving the key as overridable by actual options propped in, in case someone wants to build a separate slice at one point. In contrast to accessControl which probably should not be a decision in engineerings court.

* Add comment

* Update test helpers
2026-02-19 22:36:20 +01:00
Johannes Klein abfb6a3ce8 Mob 1100 update react-native-maps-package to latest (#3376)
* Update package.json

* Update package-lock.json

* Update Podfile.lock

* Create react-native-maps.js

* Add function mock
2026-02-16 11:37:58 +01:00
Johannes Klein 4bd596074c Revert "Update react-native-sensitive-info to 5.6.2 (#3346)"
This reverts commit d30e788ed0.
2026-02-11 23:51:15 +01:00
Johannes Klein d30e788ed0 Update react-native-sensitive-info to 5.6.2 (#3346)
* Update react-native-sensitive-info

* Delete react-native-sensitive-info+6.0.0-alpha.9.patch

* Migrate sensitive info error handling

* Lint rules changes

* Add comment

* Remove incomplete type

* Add hasItem mock

* Update type

* Remove exported function getUsername

This is nowhere imported, used only in AuthenticationService. Have added the only function that makes use of getSensitiveItem( "username" ) = isCurrentUser to the Auth integration test instead.

* Update package-lock.json

* Update Podfile.lock

* Replace string with exported error code

* Add try catch to hasItem call
2026-02-10 23:42:35 +01:00
Johannes Klein 3d9f2c3040 Refactor lodash function imports (#3348)
* Change destructured imports to individual imports

* Change full lodash imports to individual function imports

* Remove unused imports

* One more
2026-02-03 18:12:48 +01: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
Ryan StellyandJohannes Klein ca686f3c11 lint config for consistent import style (#3248)
* MOB-1008 add lint config for consistent ts imports

* auto-fix consistent imports

* auto-fix consistent imports

* reapply autofix from latest main

* Extend Props interface from PropsWithChildren

---------

Co-authored-by: Johannes Klein <johannes.t.klein@gmail.com>
2025-11-27 20:21:03 -06: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 a15e4c7076 Allow some time for camera initialization, add log if no device found (#3059)
* Start screen in a loading state for 700ms

One idea I have about the bug is that maybe it takes a few renders to initialize the device. As we are immediately backing out of the screen in case we have no device, maybe just adding a few ms to give the native side time helps.

* If no device is selected log the length of devices available

* Add missing mock
2025-08-13 19:20:36 +02:00
Amanda Bullington 5eb77e91fd Add unit and integration tests around sharing photos (#2948) 2025-06-12 16:00:50 -07:00
Amanda BullingtonandJohannes Klein 3c4ec368f5 Fix: isLoggedIn memory leak (#2952)
* Fix memory leak from isLoggedIn

* Fix tests with mocking for clearAuthCache

---------

Co-authored-by: Johannes Klein <johannes.t.klein@gmail.com>
2025-06-11 10:04:54 -07:00
Johannes Klein 271d0bd856 Add higher rank mode unrestricted to offline suggestions (#2711)
* Use unrestricted commonAncestorRankType for offline predictions from file

* The plugin provides an interface for this

* Fix type error

* Add missing type

* The iconic taxon is no longer part of the predictions result

If we use common ancestor rollup mode the ancestor taxa are no longer included in the result (which in turn are the top 10 species predictions). So, we have to get the iconic taxon name for each result in a different manner.

* Not needed as results are returned with highest score first

* Remove number wrapper

* Update comment

* There is no special offline not-confident criterion

This now returns common ancestor as top ID in case there is none over the threshold. So, same as online.

* No distinction between debug types

* Update ModelPrediction.js

* This is actually redundant

* Offline suggestions need to be sorted same as online

* Should not have removed the export

* Update comments
2025-03-04 16:37:14 +01:00
Kirk van Gorkom 375937bd6b Add common ancestor mode to vision camera plugin mock 2025-03-03 11:02:36 -08:00
Johannes Klein f84d09648d chore: rename look up location (#2603)
Renames a function call and fixes a NullPointerException on Android
2025-01-09 16:43:54 +01:00
Johannes Klein feec5567a3 feat: update vision-camera-plugin-inatvision to a version that fully supports the geomodel (#2584)
* Update vision-plugin

* useOfflineSuggestion TS

* Use location for prediction from file

* Remove log

* Use plugin function to lookup location and elevation based on h3 cells

* taxonomyRollupCutoff is now done in the plugin on basis of the tops score for a frame

* Fix wrong commit reference. Now references main branch

* Fix has location check to account for 0.0 locations

* Only prop in lat and long

* Add explanation

* Fix: Import vision-plugin function from wrapper file

* Add jest mock for new plugin function
2025-01-08 16:15:36 +01:00
Amanda Bullington c6a09a2a8c Refactor to begin simplifying device orientation/rotation code (#2422)
* Refactor useDeviceOrientation to remove extra useEffects

* Rotation code cleanup

* Update mock with useDeviceOrientationChange
2024-11-13 16:24:08 -08:00
Johannes Klein 5c8e3be12c test AI camera in e2e (#2188)
* Add a cameraZoomRange default
* Small detox version bump
* Add a mocked camera with a take photo button
* An e2e mock for the computer vision plugin predicting a frame
* Mock taking a photo by loading the first photo from the CameraRoll

Closes #1981
2024-11-01 10:38:37 -07:00
Amanda Bullington 15382cee35 Integration test for photo import (#2058)
* Write an integration test for PhotoImport; closes #1430

* Add test for photo importer -> group photos -> obs edit flow

* Remove global image-picker mock
2024-09-10 16:26:23 -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 3536fa15ae Move all RN/JS code under src folder to (hopefully) make things easier to find & edit 2021-11-12 17:10:54 -08:00
Amanda Bullington ff6789c32c Merge obs list, obs card, and user profile into main (#4)
* Obs detail screen skeleton; move safe area view to wrapper component

* Progress on obs detail

* Get ids and photos from api v2

* Fetch data needed for data tab in obs detail

* Create basic map for data tab, centered on lat/long

* Create linked realms for photos and identifications; access these on obs detail screen

* User Profile and more setup for test suite

* Delete coverage directory

* Add Jest coverage folder to gitignore

* Keep trying to mock out fetch for inatjs in ObsList.test.js

* Rename ObsList.test to match component name
2021-11-04 15:44:57 -07:00