-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix artist search when lastfm information isn't available #1554
Conversation
I just added a few checks and extracted the some of the existing logic to a separate function to allow testing it later. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1554 +/- ##
==========================================
+ Coverage 71.60% 71.82% +0.21%
==========================================
Files 364 364
Lines 6713 6729 +16
Branches 479 483 +4
==========================================
+ Hits 4807 4833 +26
+ Misses 1512 1500 -12
- Partials 394 396 +2 ☔ View full report in Codecov by Sentry. |
Should I start reviewing? Or do you want to mark it as ready later one when you finish? |
I did my best to add tests for the my changes but I had to refactor. |
similar: { | ||
artist: similarArtistsOnLastFm | ||
} | ||
} as any; |
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.
It should be possible to use const artistInfoFromLastFm: SimilarArtist = {
, or at least add satisfies SimilarArtist
at the end. If the version of TS we're using is too old to have the satisfies
keyword, you might be able to use as SimilarArtist
.
The same method applies to the as any
uses below. In general we want all objects to have appropriate types.
If the existing SimilarArtist
type doesn't have the fields you need, you should add them there so that it reflects the type of data you want to return from getSimilarArtists
. Or you can create a new type for this.
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.
Thanks for pointing the issues out. The actual type is LastFmArtistInfo
which has multiple fields which are not relevant to the call and I didn't want to declare. satisfies
doesn't seem to be appropriate here, or I don't know how to apply it. I addressed all as any
casts with explicit types. Is that allright?
describe('Tests for DiscogsMetaProvider', () => { | ||
const provider = new DiscogsMetaProvider(); | ||
|
||
describe('Verify if an artist is on tour', () => { |
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 don't think it's needed to unit test small functions like this. Integration tests are more comprehensive, and this function is already included in the output of fetchArtistDetails
.
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 tested only the code which I added or had to touch. The expression wrapped in the function was one of the things which caused the issue because of the missing lastFmInfo
. So it's most certainly not yet covered by any existing test.
Should I remove the function, the tests and inline the expression? Then my change won't be tested. : )
Ok, I finished my review. In general, I appreciate that you tested everything very comprehensively. |
Side note: I just noticed that when using the Bandcamp metadata provider, the UI doesn't display proper images for similar artists. This is because there's no logic for fetching artist images from Spotify, like the Discogs metadata provider does. If this PR gets approved, afterwards it would be possible to address this issue by extracting and reusing the current implementation for fetching artist images for the Bandcamp metadata provider. |
As requested in the review.
Fix #1554: Center Play/Pause Button
Addresses #1427