fix: count and play artist guest appearances
This commit is contained in:
1 parent
12f21583f8
commit
50926cc7bb
11 files changed
+463
-295
No files matched your search
@@ -224,6 +224,7 @@ const burst = stream([
|
||||
assert.deepEqual(await page.evaluate(() => Alpine.store('library').federationSearch),
|
||||
{ loading: false, error: '', artists: [], releases: [], tracks: [] });
|
||||
await verifyReleaseNavigation(page);
|
||||
await verifyArtistListen(page);
|
||||
assert.deepEqual(errors, []);
|
||||
} finally {
|
||||
await browser.close();
|
||||
@@ -279,3 +280,57 @@ async function verifyReleaseNavigation(page) {
|
||||
await page.waitForURL('**/#release/442');
|
||||
await page.locator('.release-cover img[src="/test/local-cover"]').waitFor();
|
||||
}
|
||||
|
||||
async function verifyArtistListen(page) {
|
||||
const feature = {
|
||||
id: 37, content_id: 'diagnosis', title: 'Диагноз', release_id: 87, release_title: '13/87',
|
||||
stream_url: '/api/player/stream/37', duration_seconds: 120,
|
||||
artists: [{ id: 7, name: 'Трагедия Всей Жизни' }], featured_artists: [{ id: 23, name: 'Кизиль' }],
|
||||
};
|
||||
const artist = {
|
||||
id: 23, name: 'Кизиль', releases: [], top_tracks: [], featured_tracks: [feature],
|
||||
total_track_count: 1, total_play_count: 0, track_content_ids: [feature.content_id],
|
||||
};
|
||||
await page.route('**/api/player/artists/23', route => route.fulfill({ json: artist }));
|
||||
await page.route('**/api/player/federation/artists/events?*', route =>
|
||||
route.fulfill({ contentType: 'text/event-stream', body: 'event: artist.completed\ndata: {}\n\n' }));
|
||||
await page.goto('about:blank');
|
||||
await page.goto('http://groups.test/#artist/23');
|
||||
await page.locator('.artist-appearance-row').waitFor();
|
||||
const stats = page.locator('.artist-stats');
|
||||
await stats.getByText('0 releases', { exact: true }).waitFor();
|
||||
await stats.getByText('1 track', { exact: true }).waitFor();
|
||||
await page.evaluate(() => {
|
||||
Alpine.store('player')._playLocal = track => { window.playedStream = track.stream_url; };
|
||||
});
|
||||
const listen = page.getByRole('button', { name: 'Listen', exact: true });
|
||||
await listen.click();
|
||||
const queue = () => page.evaluate(() => Alpine.store('queue').tracks.map(track => track.id));
|
||||
assert.deepEqual(await queue(), [37]);
|
||||
assert.equal(await page.evaluate(() => window.playedStream), feature.stream_url);
|
||||
|
||||
// A local appearance and its peer copy join the ranked queue only once.
|
||||
await page.evaluate(() => {
|
||||
const library = Alpine.store('library');
|
||||
const [feature] = library.currentArtist.featured_tracks;
|
||||
library.currentArtist.top_tracks = [{ ...feature, id: 12, content_id: 'first' }, feature];
|
||||
library.artistFederation.tracks = ['diagnosis', 'remote'].map(id => library.federationTrackFromWire({
|
||||
title: id, owner: 'peer', item_id: id, content_id: id, artist_names: ['Кизиль'],
|
||||
}));
|
||||
});
|
||||
await listen.click();
|
||||
assert.deepEqual(await queue(), [12, 37, 'fed:remote']);
|
||||
await page.evaluate(() => {
|
||||
const library = Alpine.store('library');
|
||||
library.currentArtist.top_tracks = [];
|
||||
library.currentArtist.featured_tracks = [];
|
||||
library.playFederatedTrack = (track, options) => {
|
||||
window.peerPlayback = [track.key.content_id, options.queueIndex];
|
||||
};
|
||||
});
|
||||
await listen.click();
|
||||
assert.deepEqual(await queue(), ['fed:diagnosis', 'fed:remote']);
|
||||
assert.deepEqual(await page.evaluate(() => window.peerPlayback), ['diagnosis', 0]);
|
||||
await page.evaluate(() => { Alpine.store('library').artistFederation.tracks = []; });
|
||||
assert.equal(await listen.isDisabled(), true);
|
||||
}
|
||||
@@ -34,6 +34,32 @@ function key(title, artist, year) {
|
||||
}
|
||||
const link = releaseKey => '#releasefed?key=' + encodeURIComponent(JSON.stringify(releaseKey));
|
||||
|
||||
test('guest appearances add recordings, not owned releases, even across several catalogues', () => {
|
||||
const { library, streams } = setup('#artist/333', () => assert.fail('no request expected'));
|
||||
const wire = id => ({ item_id: id, content_id: id, title: 'Диагноз', artists: ['Трагедия Всей Жизни'], featured_artists: ['Кизиль'] });
|
||||
const appearance = id => ({ release_title: '13/87', year: 2014, release_type: 'album', track: wire(id) });
|
||||
library.currentArtist = { name: 'Кизиль', releases: [], total_track_count: 1,
|
||||
track_content_ids: ['local'], top_tracks: [], featured_tracks: [{ content_id: 'local' }] };
|
||||
library.startArtistFederation('Кизиль');
|
||||
const emit = (peer, ids) => streams[0].emit('federation.artist.catalog', {
|
||||
peer, entity: { name: 'Кизиль', releases: [], appears_on: ids.map(appearance) },
|
||||
});
|
||||
emit('first', ['local']);
|
||||
assert.equal(library.artistFederation.releases.length, 0);
|
||||
assert.equal(library.artistFederation.tracks.length, 0);
|
||||
assert.equal(library.artistTrackCount(), 1);
|
||||
emit('first', ['new-version']);
|
||||
emit('second', ['local', 'new-version']);
|
||||
assert.equal(library.artistFederation.releases.length, 0);
|
||||
assert.equal(library.artistTrackCount(), 2);
|
||||
assert.equal(library.artistFederation.tracks[0].availability.federation.length, 2);
|
||||
library.currentArtist = { name: 'Кизиль', releases: [], total_track_count: 0, featured_tracks: [] };
|
||||
library.startArtistFederation('Кизиль');
|
||||
streams[1].emit('federation.artist.catalog', { peer: 'first', entity: { appears_on: [appearance('remote')] } });
|
||||
assert.equal(library.artistFederation.releases.length, 0);
|
||||
assert.equal(library.artistTrackCount(), 1);
|
||||
});
|
||||
|
||||
test('existing release deep links replace their own history entry with the local edition', async () => {
|
||||
for (const [id, title, artist, year] of [
|
||||
[442, 'вино из цикуты', 'саша скул', 2014],
|
||||
|
||||
Reference in new issue
Block a user