diff --git a/packages/app/app/components/ArtistView/index.tsx b/packages/app/app/components/ArtistView/index.tsx index 20b28a535d..396b939d40 100644 --- a/packages/app/app/components/ArtistView/index.tsx +++ b/packages/app/app/components/ArtistView/index.tsx @@ -114,9 +114,9 @@ const ArtistView: React.FC = ({ function renderSimilarArtists() { return ( - !isLoading() && + !isLoading() && !isEmpty(artist.similar) && ); diff --git a/packages/app/app/containers/ArtistViewContainer/ArtistViewContainer.test.tsx b/packages/app/app/containers/ArtistViewContainer/ArtistViewContainer.test.tsx index ca45858b9c..c5a7382e85 100644 --- a/packages/app/app/containers/ArtistViewContainer/ArtistViewContainer.test.tsx +++ b/packages/app/app/containers/ArtistViewContainer/ArtistViewContainer.test.tsx @@ -48,6 +48,27 @@ describe('Artist view container', () => { expect(history.location.pathname).toBe('/artist/artist-similar-id'); }); + it('should not render similar artists section if there are no similar artists', async () => { + const stateWithArtistDetails = buildStoreState() + .withArtistDetails() + .build(); + const initialState = buildStoreState() + .withArtistDetails({ + ['test-artist-id']: { + ...stateWithArtistDetails.search.artistDetails['test-artist-id'], + similar: [] + } + }) + .withPlugins() + .withConnectivity() + .build(); + + const { component } = mountComponent(initialState); + await waitFor(() => component.findByText(/popular tracks/i)); + const similarArtists = component.queryByText(/similar artists/i); + expect(similarArtists).toBeNull(); + }); + it('should add a single track to queue after clicking the button in the popup', async () => { const { component, store } = mountComponent(); diff --git a/packages/app/test/storeBuilders.ts b/packages/app/test/storeBuilders.ts index 472f013873..36a9e75a7e 100644 --- a/packages/app/test/storeBuilders.ts +++ b/packages/app/test/storeBuilders.ts @@ -11,6 +11,8 @@ import { TrackStream } from '../app/reducers/queue'; import { LocalLibraryState } from '../app/actions/local'; import { DeezerEditorialCharts } from '@nuclear/core/src/rest/Deezer'; import { Loadable } from '../app/reducers/types'; +import { ArtistDetailsState } from '../app/reducers/search'; +import { SearchResultsSource } from '@nuclear/core/src/plugins/plugins.types'; type StoreStateBuilder = ReturnType; export const buildStoreState = () => { @@ -144,7 +146,7 @@ export const buildStoreState = () => { }; return this as StoreStateBuilder; }, - withArtistDetails(data?: any) { + withArtistDetails(data?: {[key: string]: ArtistDetailsState }) { state = { ...state, search: { @@ -162,11 +164,7 @@ export const buildStoreState = () => { { id: 'test-album-1', title: ' Test album 1', - artists: [ - { - name: 'test artist 1' - } - ], + artist: 'test artist 1', genres: ['genre 1', 'genre 2'], images: ['image 1'], thumb: 'image 1', @@ -174,23 +172,18 @@ export const buildStoreState = () => { tracklist: [ { uuid: 'track-1', - artist: { - name: 'test artist 1' - }, + artist: 'test artist 1', title: 'test track 1', duration: 10 } ], - year: 2019 + year: '2019', + source: SearchResultsSource.Discogs }, { id: 'test-album-2', title: ' Test album 2', - artists: [ - { - name: 'test artist 2' - } - ], + artist: 'test artist 2', genres: ['genre 2', 'genre 3'], images: ['image 2'], thumb: 'image 2', @@ -198,14 +191,13 @@ export const buildStoreState = () => { tracklist: [ { uuid: 'track-2', - artist: { - name: 'test artist 2' - }, + artist: 'test artist 2', title: 'test track 2', duration: 40 } ], - year: 2021 + year: '2021', + source: SearchResultsSource.Discogs } ], releasesLoading: false, @@ -224,37 +216,28 @@ export const buildStoreState = () => { topTracks: [ { artist: { - mbid: 'test mbid', - name: 'test artist', - url: 'test artist url' + name: 'test artist' }, - listeners: '771858', - name: 'test artist top track 1', - playcount: '6900237', + listeners: 771858, + playcount: 6900237, thumb: '', title: 'test artist top track 1' }, { artist: { - mbid: 'test mbid', - name: 'test artist', - url: 'test artist url' + name: 'test artist' }, - listeners: '123', - name: 'test artist top track 2', - playcount: '6969', + listeners: 123, + playcount: 6969, thumb: '', title: 'test artist top track 2' }, { artist: { - mbid: 'test mbid', - name: 'test artist', - url: 'test artist url' + name: 'test artist' }, - listeners: '9', - name: 'test artist top track 3', - playcount: '1', + listeners: 9, + playcount: 1, thumb: '', title: 'test artist top track 3' } diff --git a/packages/core/src/plugins/plugins.types.ts b/packages/core/src/plugins/plugins.types.ts index 10a6664473..91e1ecae38 100644 --- a/packages/core/src/plugins/plugins.types.ts +++ b/packages/core/src/plugins/plugins.types.ts @@ -28,10 +28,19 @@ export type SearchResultsAlbum = { id: string; coverImage?: string; thumb?: string; + genres?: string[]; + images?: string[]; title: string; artist: string; resourceUrl?: string; type?: string; + tracklist?: { + uuid: string; + artist: string; + title: string; + duration: number; + }[]; + year?: string; source: SearchResultsSource; }