ground-android icon indicating copy to clipboard operation
ground-android copied to clipboard

Handle Continue clicks in Data Collection tasks, move more of state handling to DataCollectionViewModel

Open JSunde opened this issue 3 years ago • 2 comments

  • Store List<AbstractTaskViewModel> in DataCollectionViewModel to track the view models of the Tasks the user has filled out so far
  • Track the currentPosition in the DataCollectionViewModel as well and subscribe to this position from the DataCollectionFragment, allowing the ViewModel to drive the active tasks and update the position when the user hits continue on a completed task
  • Show an error popup if the user's input is invalid when Continue is clicked

Towards #1146

JSunde avatar Oct 13 '22 18:10 JSunde

@JSunde The unit tests are failing. Is it ready to be reviewed?

shobhitagarwal1612 avatar Oct 15 '22 08:10 shobhitagarwal1612

I think the reason they are failing is because we are using a @Mock DataCollectionViewModel instead of an actual instance. This causes an NPE while instantiating the fragment as mock isn't properly set. That being said, I don't think we should mock the DataCollectionViewModel as that is the class being tested here. Instead, we should test the behavior using exposed live data and repositories

shobhitagarwal1612 avatar Oct 15 '22 08:10 shobhitagarwal1612

Okay, I think the tests should be working now 👍

JSunde avatar Oct 18 '22 17:10 JSunde

If DataCollectionViewModelTest is already covered by the added test, then we can get rid of that class as well.

shobhitagarwal1612 avatar Oct 18 '22 19:10 shobhitagarwal1612