Up Next: a queue that plays on by itself (#473)
Playing was one episode at a time: when one ended nothing followed. Up Next
is a per-account queue on the server (table `queue`, GET and PUT
/api/queue), so the phone and the browser share it. The page adds to it from
a row or the reader, reorders it by drag or arrow keys, and plays the next
when one ends; what is playing leaves it as it starts, as Overcast's does. An
episode 90% played leaves it on the server too, which covers the phone
playing on while the page is frozen.
The iOS app is told what follows (`{t:'next'}`, gated on the app saying it
can) and starts it at the end of an episode; the page takes it up through
nowPlaying as it does the car's pick. The Swift is not compiled here.
The page stub answered every unknown address with [], whose `.entries` is
Array.prototype.entries, so the queue read a function as its list; it now
answers /api/queue as an entry list.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -425,6 +425,43 @@ test('Currently Listening, its own place below the Directory, resumes an episode
|
||||
await expect(row.locator('.eq')).toBeHidden();
|
||||
});
|
||||
|
||||
test('Up Next lines episodes up, moves them, and plays the next when one ends (#473)', async ({ page }) => {
|
||||
await page.evaluate(() => saveUpNext([]));
|
||||
await page.locator('.feed', { hasText: 'Test Show' }).click();
|
||||
for (const name of ['First Episode', 'Second Episode']) {
|
||||
const ep = page.locator('#eps .ep', { hasText: name });
|
||||
await ep.hover();
|
||||
await ep.locator('[data-a=queue]').click();
|
||||
await expect(ep.locator('[data-a=queue]')).toHaveAttribute('aria-pressed', 'true');
|
||||
}
|
||||
const place = page.locator('#feedlist .place', { hasText: 'Up Next' });
|
||||
await expect(place.locator('.badge')).toHaveText('2');
|
||||
|
||||
await place.click();
|
||||
const rows = page.locator('#listening .childrow .txt b');
|
||||
await expect(rows).toHaveText(['First Episode', 'Second Episode']);
|
||||
// Moved by its handle's arrow keys, and kept so on the server.
|
||||
await page.locator('#listening .childrow', { hasText: 'Second Episode' }).locator('.grip').press('ArrowUp');
|
||||
await expect(rows).toHaveText(['Second Episode', 'First Episode']);
|
||||
await expect.poll(() => page.evaluate(async () => (await api('/api/queue')).entries.map((e: Entry) => e.guid)))
|
||||
.toEqual(['ui-2', 'ui-1']);
|
||||
|
||||
// Playing one takes it out; the end of it plays the next.
|
||||
await page.locator('#listening .childrow', { hasText: 'Second Episode' }).click();
|
||||
await expect(page.locator('#ptitle')).toHaveText('Second Episode');
|
||||
await expect(rows).toHaveText(['First Episode']);
|
||||
await expect(page.locator('#pnext')).toBeVisible();
|
||||
// The fixture files are not real audio, so the end is said rather than played to.
|
||||
await page.evaluate(() => audio.dispatchEvent(new Event('ended')));
|
||||
await expect(page.locator('#ptitle')).toHaveText('First Episode', { timeout: 20_000 });
|
||||
await expect(page.locator('#listening')).toContainText('Nothing lined up');
|
||||
await expect(page.locator('#pnext')).toBeHidden();
|
||||
|
||||
await page.locator('#pclose').click();
|
||||
await page.evaluate(() => api('/api/entries/test-show/ui-1/position', { method: 'POST', body: JSON.stringify({ secs: 0 }) }));
|
||||
await page.evaluate(() => api('/api/entries/test-show/ui-2/position', { method: 'POST', body: JSON.stringify({ secs: 0 }) }));
|
||||
});
|
||||
|
||||
test('a player nobody has played since it last saved does not save again', async ({ page }) => {
|
||||
// A tab left paused at 41:15 saved that as it reloaded, over the 32:48 another had reached,
|
||||
// and the episode dropped out of Currently Listening. The fixture audio does not decode, so
|
||||
|
||||
Reference in New Issue
Block a user