Skip to content
This repository has been archived by the owner on Feb 1, 2025. It is now read-only.

Add multiple collections #90

Merged
merged 23 commits into from
Mar 30, 2023
Merged

Conversation

simone-kalbermatter
Copy link
Contributor

@simone-kalbermatter simone-kalbermatter commented Mar 29, 2023

  • Added class CollectionListAdapter to display multiple collections on the profile
  • Added a button to add new collections on the profile
  • Added dialog box to enter new collection name
  • Changed ProfileFragment and ProfileViewmodel to adapt to these changes
  • Refactored ProfileFragment
  • Added tests

@simone-kalbermatter simone-kalbermatter self-assigned this Mar 29, 2023
@simone-kalbermatter simone-kalbermatter changed the title Add multiple collections structure Add multiple collections Mar 30, 2023
@simone-kalbermatter simone-kalbermatter marked this pull request as ready for review March 30, 2023 02:31
Copy link
Contributor

@MariemBaccari MariemBaccari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job ! Also, the tests are very clean and cover most cases. I left a few comments to be addressed before we merge.

// Check that a new collection has been added to the outer RecyclerView if the user chooses a valid collection name
@Test
public void testAddValidCollection() throws UiObjectNotFoundException {
ViewInteraction outerRecyclerView = onView(withId(R.id.collection_list_recycler_view));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to store these ViewInteractions as an attribute to the class or does it not work ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point I changed it.


// Check that no new collection has been added to the outer RecyclerView if the user enters an empty collection name
@Test
public void testEmptyCollectionNameNotAdded() throws UiObjectNotFoundException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is valid for all the tests: Are you updating the collections in the database in the code that you're testing here ? If so, you could use the emulator in this class like in the DatabaseTests classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code storing the collection in the database will be run, however these tests don't verify the upload to the database but only the ProfileFragment UI. The database functions should probably be tested outside of this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database functions are already tested in another class but we should still use the emulator to avoid spamming the "production" database with test values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I just start the database emulator before testing it won't upload to the actual database? Even if it is not in a database test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you can just copy the setup method from the database tests (just the part where you use the emulator ofc).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay thanks, done!

}
/* holder.mediaRating.setText(review.getGrade());*/
// Set the media rating
int grade = review.getGrade();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that this may cause some error ? Since the grade attribute isn't mandatory in the declaration of a new review getGrade() might return 0 when the user simply didn't give a rating. Maybe we can choose not to display any rating when it's less than 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I changed it to display an empty string if the return value is 0.

return collections.size();
}

public static class ViewHolder extends RecyclerView.ViewHolder {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

@codeclimate
Copy link

codeclimate bot commented Mar 30, 2023

Code Climate has analyzed commit 5b5ecd2 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 2

The test coverage on the diff in this pull request is 95.8% (80% is the threshold).

This pull request will bring the total coverage in the repository to 77.7% (0.0% change).

View more on Code Climate.

Copy link
Contributor

@MariemBaccari MariemBaccari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adressing my comments, here you go :)

@MariemBaccari MariemBaccari merged commit b6fc53d into main Mar 30, 2023
@MariemBaccari MariemBaccari deleted the add_multiple_collections_structure branch March 30, 2023 16:20
@MariemBaccari MariemBaccari restored the add_multiple_collections_structure branch March 30, 2023 16:35
MariemBaccari added a commit that referenced this pull request Mar 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants