uoftblueprint / the-period-purse-2023

Menstruation Nation (M. Nation) is a free period tracker designed for youth. The app helps people learn more about their bodies by tracking their period cycle and symptoms.
https://uoftblueprint.org/#/
GNU General Public License v3.0
5 stars 1 forks source link

Let tests handle async operations #168

Open leowrites opened 1 year ago

leowrites commented 1 year ago
          All tests under` CalendarCycleTabTest` are failing

The problem is where databaseIsLoadedFromStorage.postValue(true) is placed in AppViewModel. Before it is placed outside of the view model so it's executed immediately and the UI is not actually showing the loading screen when waiting to fetch database.

This caused the tests to fail because after properly using async operations (and I moved databaseIsLoadedFromStorage.postValue(true) to after the fetching operation is complete), the tests are not waiting for the loading to complete and tried to navigate around when it's still showing the loading screen.

For this patch, I will update databaseIsLoadedFromStorage immediately when AppViewModel.loadData is called to make the tests pass, but the tests needs to be fixed either to

  1. Wait for asynchronous loading to complete
  2. Jump over the loading screen to the calendar screen immediately

Originally posted by @leowrites in https://github.com/uoftblueprint/the-period-purse-2023/issues/167#issuecomment-1625431744