-
Notifications
You must be signed in to change notification settings - Fork 473
For #9599: Ability to edit top site URLs #9600
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9600 +/- ##
============================================
- Coverage 73.89% 66.63% -7.27%
+ Complexity 5576 553 -5023
============================================
Files 768 120 -648
Lines 28608 3809 -24799
Branches 4710 614 -4096
============================================
- Hits 21140 2538 -18602
+ Misses 5023 958 -4065
+ Partials 2445 313 -2132
Continue to review full report at Codecov.
|
@@ -76,6 +76,16 @@ class DefaultTopSitesStorage( | |||
} | |||
} | |||
|
|||
override fun editTopSite(topSite: TopSite, title: String, url: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove renameTopSite since I don't imagine any consumers of it after this. Can we also call it updateTopSite
instead of editTopSite
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done and done!
...ts/feature/top-sites/src/main/java/mozilla/components/feature/top/sites/PinnedSiteStorage.kt
Outdated
Show resolved
Hide resolved
I'm planning to look at how the edit bookmarks (use case if there is one?) works tomorrow to investigate how it works - looking for clues on how/if it handles empty URL provided and perhaps malformed URLs. Will also look at other browser to see how much we will need to dive into this. Feel free to also investigate this, I just want to make sure we cover our bases. Thanks again for contributing! |
This pull request has conflicts when rebasing. Could you fix it @pepve? 🙏 |
I just rebased on the latest master. I also added a commit with a test to improve the (measured) test coverage, please review, I'm not entirely sure of the About validation, can we pick that up in a separate issue? From the AC perspective it was already possible to add any random string as a URL. And the new update logic doesn't change that. The new issue will then of course block the Fenix issue I'm doing this for: #17636. |
This pull request has conflicts when rebasing. Could you fix it @pepve? 🙏 |
.../src/androidTest/java/mozilla/components/feature/top/sites/OnDevicePinnedSitesStorageTest.kt
Show resolved
Hide resolved
@VisibleForTesting | ||
internal var currentTimeMillis: () -> Long = { System.currentTimeMillis() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's nothing wrong in particular about this, but from looking around our codebase, I would be more comfortable being consistent and calling System.currentTimeMillis() where it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use it to inject a constant time from the tests (in addAllDefaultSites
and addPinnedSite
) so that I can use verify
without much effort. What would be a good alternative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just check for anyLong() as an alternative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that but I think it doesn't work because the long is wrapped in an object. I think this works:
verify(obj).method(eq("foo"), anyLong())
But this doesn't:
verify(obj).method(SomeClass(eq("foo"), anyLong()))
And our case matches the latter. But I don't really have a lot of experience in this area so please correct me if I'm missing something. The real problem I think we're having is that there is no consistent way to mock time used throughout the project. Code that does straight calls to System.currentTimeMillis()
is just not very unit-testable. Perhaps we should make an issue about this?
...s/support/migration/src/test/java/mozilla/components/support/migration/FennecMigratorTest.kt
Outdated
Show resolved
Hide resolved
docs/changelog.md
Outdated
@@ -49,6 +49,9 @@ permalink: /changelog/ | |||
* **lib-state** | |||
* Add `threadNamePrefix` parameter to `Store` to give threads created by the `Store` a specific name. | |||
|
|||
* **feature-top-sites** | |||
* ⚠️ **This is a breaking change**: Replace `TopSitesUseCases.renameTopSites` (which only updates the title) with `TopSitesUseCases.updateTopSites` (which also updates the url). [#9599](https://github.com/mozilla-mobile/android-components/issues/9599) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* ⚠️ **This is a breaking change**: Replace `TopSitesUseCases.renameTopSites` (which only updates the title) with `TopSitesUseCases.updateTopSites` (which also updates the url). [#9599](https://github.com/mozilla-mobile/android-components/issues/9599) | |
* ⚠️ **This is a breaking change**: Replace `TopSitesUseCases.renameTopSites` with `TopSitesUseCases.updateTopSites` which will allow for updating the title and url of a top site. [#9599](https://github.com/mozilla-mobile/android-components/issues/9599) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
class PinnedSitesStorageTest { | ||
|
||
@Test | ||
fun `add all default sites`() = runBlocking { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can simply use the addAllPinnedSites
as the test name and the others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -0,0 +1,127 @@ | |||
/* This Source Code Form is subject to the terms of the Mozilla Public |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
) | ||
entity.id = pinnedSiteDao.insertPinnedSite(entity) | ||
pinnedSiteDao.insertPinnedSite(entity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed this change from your comments in https://github.com/mozilla-mobile/android-components/pull/9600/files#r575826087, can we revert this change for now?
I see we are doing entity.id in a number of places for adding items to the RoomDB - LoginExceptionStorage, TabCollectionStorage. If we think this should be changed, I think we should make a change that also accounts for those 2 other storage. I mostly don't understand the meaning behind the change so happy to be enlighten.
I think this also resolves us from having to return Unit in the other files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I'm undoing this change. I opened #9708 for it. See also my comment here: https://github.com/mozilla-mobile/android-components/pull/9600/files#diff-3a51f71b988baa050dc7351cdbdb1d06369d75afe7fcb0951091d3d642d6318cR56-R59
@VisibleForTesting | ||
internal var currentTimeMillis: () -> Long = { System.currentTimeMillis() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just check for anyLong() as an alternative.
This pull request has conflicts when rebasing. Could you fix it @pepve? 🙏 |
@gabrielluong is there anything else I can do to help progress this? |
Thank you! |
Add functionality to edit both the title and the URL of a top site simultaneouslyDeprecate functionality to edit only the title of a top siteReplace the functionality to rename top sites with functionality to update both the title and the URL.
Pull Request checklist
After merge