Commit Graph

13 Commits

Author SHA1 Message Date
Johannes Klein
1b4039eb36 417 eslint testing (#419)
* Add eslint-plugin-testing-library dependency

* Enable plugin inside tests folder

* Fix errors given by eslint-plugin
2023-02-01 12:50:59 +01:00
Johannes Klein
14d0239468 308 accessibility tests (#393)
* Regroup accessibility label strings at end of strings file
* Add accessibility test to AddID
* Add a11y labels to AddID
* Add a11y test to StandardCamera
* Add a11y props to StandardCamera
* Remove unit test with only todos
* Add a11y test to Messages
* Refactor PhotoScroll test into own file
* Add a11y test to ObsDetails
* Add a11y test to ObsList
* Add a11y matcher to PhotoGallery test
* Add a11y matcher to ProjectDetails test
* Add a11y matcher to ProjectObservations test
* Add a11y matcher to Projects test
* Add a11y props to ProjectList
* Add a11y props to ProjectTabs
* Add a11y matcher to Search
* Add a11y matcher to UserProfile test
* Add a11y test matcher to UserText test
* Update react-native-accessibility-engine
* Add a11y matcher to Tabs test
* Add a11y label to a selectable photo
* Refactor DataTab tests into separate file
* Refactor ActivityTab test out into own file
* Added a test how to check if a component uses a mocked container
* Add wrong a11y props to TextInput left icon
* Enable a11y test with actual BottomSheet because mock does not pass a11y props down
* Add a11y default props to Button
2023-01-27 12:30:57 -08:00
Amanda Bullington
0d69fe1568 Fetch user locale from server and change language (#255)
* Fetch user from server, set locale in realm and change language with i18next
* Added some Spanish translations so I can see localization working
* config QueryClient with `cacheTime: Infinity` to deal with "Jest did not
  exit" errors

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-12-09 15:51:17 -08:00
Amanda Bullington
a96e379b09 Standardize headers with react navigation (#243)
* Use react navigation header for photo gallery / album picker
* Use react navigation for group photos header
* Use react nav header for Add ID
* Use react navigation header for ObsEdit
* Fix tests by mocking navigation setOptions
* Show all buttons in camera options modal; remove header from StandardCamera
* Only show obs edit header when observations have loaded

Closes #226
2022-11-23 14:09:17 -08:00
Amanda Bullington
4d213bd4c6 Create / update / delete requests with useMutation (#206)
* Use authenticated query for search results
* Use search API for fetching places from Settings
* Use authenticated query for authorized applications
* Use authenticated query to fetch user.me
* Move fetch/search api calls into react query format, out of hooks
* Update with react query instead of hooks
* Fetch list of blocked and muted users with authenticated query
* Added Podfile postinstall block to get app running in a Simulator
* Use auth query in identify
* Upgrade @realm/react library to 0.4.0; fixes initialization error on android due to importing realm
* Use authquery for explore provider
* Use mutations for blocking/muting users, invalidating queries, and refetching settings data
* Add react mutation to create/update/delete api calls
* Use mutation for creating identification on identity/obs detail screens
* Use mutations to update and delete relationships
* Use mutation to revoke authorized apps
* Use mutation for updating user settings
* Fix ids on activity tab; fix safe area view; fix mark viewed
* Limit fields for remote observation api call

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-10-31 20:39:38 -07:00
Amanda Bullington
e81894d406 Use authenticated queries for fetch/search requests (#195)
* Use authenticated query for search results
* Use search API for fetching places from Settings
* Use authenticated query for authorized applications
* Use authenticated query to fetch user.me
* Move fetch/search api calls into react query format, out of hooks
* Update with react query instead of hooks
* Fetch list of blocked and muted users with authenticated query
* Added Podfile postinstall block to get app running in a Simulator
* Use auth query in identify
* Upgrade Realm to 11.0.0-rc.0, most recent version that will work with RN 0.68.2
* Upgrade @realm/react library to 0.4.0; fixes initialization error on android due to importing realm
* Use authquery for explore provider
* ObsDetail wasn't showing the edit button for obs created while signed out
* simplified ObsEditHeader so it takes a full observation instead of relying
  on the ObsEditContext
* ObsEdit now accepts an obs UUID as a param and loads that if the context
  doesn't have a current obs
* null checks for API methods, mostly to prevent requests that won't work b/c
  of missing params

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-10-19 13:01:04 -07:00
Amanda Bullington
c4d9cd4dc6 Use babel-plugin-module-resolver (#188)
* Add alias and update eslint/flow to resolve modules

* Update aliases for components and api

* Add other src directories to module resolver aliases
2022-10-07 10:20:55 -07:00
Ken-ichi
c22d0fe79a Use RealmProvider (#183)
This attempts to remove the necessity of opening and closing Realm
connections, which can lead to stale connections and invalidated objects. I
did not try to remove direct access to realm from AuthenticatedService,
which exists outside of the component hierarchy and can't really access
context, but I think eventually we may want to bring all that functionality
within the component hierarchy so there really is only one Realm connection
in the app.

Probably still some bugs here. One major problem is that deleting the Realm
file does not seem to trigger a re-render of the RealmProvider. My workaround
was to delete all the data in RealmProvider connection to Realm before
deleting the file, but it seems kind of redundant.

Some other changes

* Updated react-native-image-resizer and worked around some regressions
* Needed to use Array.from on Realm collections in many places;
  map( o => o ) doesn't seem to work for creating POJOs from realm objects any more
* React Native Paper provider needs to be inside the Realm provider for any
  realm stuff to happen with rn paper modals
* Several workarounds for the fact that Realm objects don't behave like POJOs
* Added useApiToken hook (#158)
* Renamed the useUser hook to useRemoteUser, since that's what it was doing
2022-10-06 16:15:22 -07:00
Amanda Bullington
337d812ab9 UI updates to bottom sheet (#181)
* Changes My Observations upload bottom sheet from modal to non-modal
* Give flatlist container a minHeight to make bottom sheet snap correctly when flatlist has few items
* Mock useLoggedIn hook in tests
* Move useCurrentUser to sharedHooks/ and mock in ObsList test
* Mock useUser hook
* Use useCurrentUser hook on user profile
* Downgrade gesture handler
2022-09-19 14:40:26 -07:00
Ken-ichi
e929764c25 Adopted and enforced code style from other iNat Javascript projects
These rules are largely based on the AirBnB ones, which are not quite standard
for the React Native world, where Prettier seems to be more common, but I
think they add a lot of useful checks, and unlike Prettier we can customize
them. This also just makes it easier for people on the iNat team to work on
the mobile app.

Some specific changes:

* Added eslint-plugin-react-hooks to eslint rules
* Added eslint-plugin-simple-import-sort to eslint rules
* Bugfix: could not import photo from gallery
* Added support for react-native/no-inline-styles eslint rule
* useUser should not bother fetching a user for a blank userId
2022-07-13 13:55:59 -07:00
Amanda Bullington
59508b6840 Merge user profile, obs detail updates (#56)
* Add to user profile

* Create a hook to fetch member projects

* Create custom header for user profile

* Updates to user profile; resize image for CV suggestions; build config for Android

* Bug fixes with obs list & CV suggestion fields

* Add functions for creating id, faving obs and adding comment in obsdetail

* Show comments as activity items; create comments and refetch obs data

* Fix activity item keys

* Add data to data tab, obs detail

* Let user unfave observation

* Fix camera modal

* Get tests passing
2022-03-15 18:00:54 -07:00
Amanda Bullington
9ef85a6818 Explore and explore filters (#24)
* Create Explore screen

* Add input field component

* Add input fields

* UI for list view in Explore; dropdown taxa picker

* UI for list view in Explore; dropdown taxa picker

* ObservationViews component is shared between Explore and My Observations

* Get tests passing with Explore + ObservationViews

* Add map view, iOS location permission whenInUse, and geolocation fetch

* Add RN permissions and geolocation to jest mocks

* Explore filters, testing, explore provider/navigation stack

* Crash fix for grid items with no observation photos

* Code cleanup; remove duplicate files

* Remove more duplication

* Consolidate pickers into a single component

* Move copyRealmSchema into Observation model

* Move copyRealmSchema into Observation model

* Move observation photo logic to Obs model

* Obs details fetches an observation from API instead of from realm/exploreList

* Rename hooks files with 'use' instead of 'fetch'

* Add user to observation schema

* Change realm keys from camelcase to snakecase with mapping

* Simplify model code

* Fix tests for ObsDetails

* Attempt to clean up ObsList code; move useObservations hook into provider

* Several minor changes to get tests passing

* Stopped mocking useObservation hook in MyObservations integration test; this
  should not be mocked in an integration test since the point is to test the
  integration of all the different moving pieces within the app, and it was
  causing a failure because it was mocked but none of the methods were
  actually provided with mock responses, so it wasn't doing anything
* Used the LocalObservation factory for ObsDetails.test.js, where the
  useObservation hook should return an observation in the Realm schema
  (or something like it), not in the remote schema
* Updated the LocalObservation factory to meet expectations

* Attempting to work around weird problem with fkirc/skip-duplicate-actions

* Removed fkirc/skip-duplicate-actions from CI for now

* CI fix

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-01-07 11:38:50 -08:00
Amanda Bullington
e8da272dbd Taxon detail; testing coverage (#21)
* Fetch taxon details from API v2

* Add basic styling, html renderer, Wikipedia link

* Add testing for TaxonDetails API results

* Code cleanup

* Upgrade accessibility engine

* Add testing for ObsDetails

* Check that data tab renders when user taps it

* Make user profiles dynamic and tappable from ObsDetail

* Add test coverage for user profile

* Test navigation and linking to wikipedia

* Add accessibility roles and test todos

* Add grid view to observation list

* Add accessibility roles to pressables in obslist
2021-12-02 14:49:07 -08:00