Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
76a1d98
Redesign foundations: tokens, motion, and the libraries the new UI reads
RobbieTheWagner Nov 20, 2026
f880c10
Address CodeRabbit on the foundations
RobbieTheWagner Nov 22, 2026
3492991
Media engine and the player island
RobbieTheWagner Nov 20, 2026
c5c5b25
Tighten name, cue and flip edges found in review
RobbieTheWagner Nov 22, 2026
1e09ab0
Address CodeRabbit's review of the media engine and player (#79)
RobbieTheWagner Nov 21, 2026
9ad863d
Merge pull request #83 from shipshapecode/split/1-foundations
RobbieTheWagner Nov 22, 2026
63d62c5
Fix playback edges found in review of the media engine
RobbieTheWagner Nov 22, 2026
f709f65
Merge pull request #79 from shipshapecode/split/2-media
RobbieTheWagner Nov 22, 2026
1233ffe
The episode page, built around its stage
RobbieTheWagner Nov 20, 2026
5b9f652
Hold a landed section under the bar where there's no scroll anchoring
RobbieTheWagner Nov 20, 2026
dc14fdc
Hold a landed section in WebKit too, which accepts overflow-anchor
RobbieTheWagner Nov 20, 2026
7603296
Hold a landed section to the pixel
RobbieTheWagner Nov 20, 2026
05c64b7
Address CodeRabbit on the episode page
RobbieTheWagner Nov 23, 2026
13e5615
Fix episode page edges found in review
RobbieTheWagner Nov 23, 2026
9d1ad41
Put the phone script limits after the base script rules
RobbieTheWagner Nov 24, 2026
d6c3b2d
Expect the redesigned transcript in the transcript tests
RobbieTheWagner Nov 24, 2026
cd01e81
Merge pull request #80 from shipshapecode/split/3-episode
RobbieTheWagner Nov 24, 2026
d240365
The home page becomes an episode explorer
RobbieTheWagner Nov 20, 2026
c799f2f
Keep the open card's parts on their slots in Firefox
RobbieTheWagner Nov 20, 2026
53d275b
Show the close-up's resume line by the engine's resume rule
RobbieTheWagner Nov 21, 2026
8ea5661
Measure the close-up's anchor gap in a frame, confirmed over two
RobbieTheWagner Nov 21, 2026
9f34036
Give explorer faces without a photo the light-or-dark avatar
RobbieTheWagner Nov 23, 2026
d729623
Address CodeRabbit and review on the explorer
RobbieTheWagner Nov 24, 2026
e448e27
Name each episode's people from the database or the feed
RobbieTheWagner Nov 24, 2026
c8fa4a4
Keep the explorer's state in the hash, through Astro's router
RobbieTheWagner Nov 24, 2026
03ed73a
Say the explorer's state lives in the hash
RobbieTheWagner Nov 24, 2026
16a29c8
Look for the home page's first card art in the explorer's markup
RobbieTheWagner Nov 24, 2026
5550a9b
Merge pull request #81 from shipshapecode/split/4-explorer
RobbieTheWagner Nov 24, 2026
7663e48
The new shell: rail, layout and the pages around the media
RobbieTheWagner Nov 20, 2026
97ccdaa
Give client-side navigations in e2e the time CI's Firefox takes
RobbieTheWagner Nov 20, 2026
46b62a8
Play a generated WAV in the audio e2e tests
RobbieTheWagner Nov 20, 2026
73fe3b0
Skip the audio e2e tests in CI's Firefox, which has no audio output
RobbieTheWagner Nov 20, 2026
92ab1aa
Space the rail's synthetic throw by waiting in place
RobbieTheWagner Nov 20, 2026
ff7c3d0
Give the jump to episode 184 the navigation timeout too
RobbieTheWagner Nov 20, 2026
e63c4ed
Land a section within a pixel of 16px under the bar in e2e
RobbieTheWagner Nov 21, 2026
7f9575a
Expect focus to open a clamped transcript only on what it cuts off
RobbieTheWagner Nov 23, 2026
d1f25ca
Give hosts without a photo the light-or-dark avatar
RobbieTheWagner Nov 24, 2026
a6b1d22
Remove the avatar PNGs now that avatar.svg carries both
RobbieTheWagner Nov 24, 2026
f82253d
Count the hosts' episodes on About wherever episodes name them
RobbieTheWagner Nov 24, 2026
8ade50a
Link to the explorer's cuts by hash, and let the router take skip links
RobbieTheWagner Nov 24, 2026
a0099be
Address CodeRabbit on the shell
RobbieTheWagner Nov 24, 2026
53a4d30
Keep a squeezed follow flyout to one scrolling column, without a caret
RobbieTheWagner Nov 24, 2026
7245bc7
Let the mobile header's title go home for a pointer, as the artwork's…
RobbieTheWagner Nov 24, 2026
f14bf66
Merge pull request #82 from shipshapecode/split/5-shell
RobbieTheWagner Nov 25, 2026
df6b4d7
Design context and docs for the redesign
RobbieTheWagner Nov 20, 2026
6c66edf
Name the explorer's hash in the design notes
RobbieTheWagner Nov 24, 2026
1b97a52
Address CodeRabbit on the design docs
RobbieTheWagner Nov 25, 2026
e8d6d62
Bring the design docs in line with the code
RobbieTheWagner Nov 25, 2026
bf8e1c8
Lay the preview's more button over the fade from the start
RobbieTheWagner Nov 25, 2026
08676cb
Keep holding a landed section when the page shrinks to it
RobbieTheWagner Nov 25, 2026
3287b06
Merge pull request #84 from shipshapecode/split/6-docs
RobbieTheWagner Nov 26, 2026
a3317ac
Move the stage's plain layout and type to Tailwind
RobbieTheWagner Nov 23, 2026
82eb7cb
Move the episode and About pages' plain spacing and type to Tailwind
RobbieTheWagner Nov 23, 2026
89cdd7c
Move the top bar, crumbs and sheet titles' plain styles to Tailwind
RobbieTheWagner Nov 23, 2026
27d15f0
Move the home hero and toolbar's plain spacing and type to Tailwind
RobbieTheWagner Nov 23, 2026
5ce114f
Move the Up next board's plain text and grid styles to Tailwind
RobbieTheWagner Nov 23, 2026
7778f73
Move the search palette's plain row text styles to Tailwind
RobbieTheWagner Nov 23, 2026
5e10bd4
Move the archive chips, toolbar row and dock times' plain styles to T…
RobbieTheWagner Nov 23, 2026
8c59416
Draw every colour from the theme
RobbieTheWagner Nov 25, 2026
4fa71e7
Add utilities for the modern CSS Tailwind doesn't ship
RobbieTheWagner Nov 25, 2026
29c4852
Move the stage's grid, frame and title plain styles to Tailwind
RobbieTheWagner Nov 25, 2026
8ca90e8
Move the shell's plain styles to Tailwind
RobbieTheWagner Nov 25, 2026
38a95f9
Put element defaults under utilities, and use Tailwind's own utilities
RobbieTheWagner Nov 25, 2026
01f1696
Move the episode page's plain styles to Tailwind
RobbieTheWagner Nov 25, 2026
c7dc725
Move the player's plain styles to Tailwind
RobbieTheWagner Nov 25, 2026
a8e6752
Read the player home's hook class, not its whole class list
RobbieTheWagner Nov 25, 2026
f688ec1
Move the rail's plain styles to Tailwind
RobbieTheWagner Nov 26, 2026
f7a9aa8
Move the explorer's plain styles to Tailwind
RobbieTheWagner Nov 26, 2026
72f1b60
Keep the hook classes sites style through customCss
RobbieTheWagner Nov 26, 2026
5de1554
Measure Tailwind's spacing and breakpoints in px
RobbieTheWagner Nov 26, 2026
f055da9
Drop the hook classes again
RobbieTheWagner Nov 26, 2026
600c895
Give Starpod its own Tailwind type, leading and radius scales
RobbieTheWagner Nov 26, 2026
80a2fc3
Fold near-duplicate sizes into the scale steps
RobbieTheWagner Nov 26, 2026
18b95e6
Document theming through CSS variables
RobbieTheWagner Nov 26, 2026
9bf2c60
Name the easings, fonts, layout spacing and hairline in the theme
RobbieTheWagner Nov 27, 2026
83ec05d
Size the player card's title row to the title
RobbieTheWagner Nov 27, 2026
be04cc9
Make the playback speed a plain control like the icons beside it
RobbieTheWagner Nov 27, 2026
4038d92
Outline every outlined button the same way, and line up the hosts
RobbieTheWagner Nov 28, 2026
9d37f47
Keep the host photos whole; size the posters instead
RobbieTheWagner Nov 28, 2026
49cc054
Merge pull request #87 from shipshapecode/split/7-tailwind
RobbieTheWagner Nov 30, 2026
1bf1a1a
Make the contact form placeholder generic
RobbieTheWagner Nov 30, 2026
97b7ba3
Gather the palette's people only on prerendered pages
RobbieTheWagner Nov 30, 2026
cb9d025
Load the search palette's episodes when it opens, from a slim endpoint
RobbieTheWagner Nov 30, 2026
d33508f
Treat --slomo 0 as 0 so reduced motion skips the motion waits
RobbieTheWagner Nov 30, 2026
f9d8584
Keep the live script off the clock unless its episode is playing
RobbieTheWagner Nov 30, 2026
1d96fdd
Make the contact form placeholder generic (#88)
RobbieTheWagner Nov 30, 2026
7e13c4f
Serve the stylesheets as cached files, and load page CSS only where used
RobbieTheWagner Nov 30, 2026
4fa57f0
Keep the scroll reveals in the shared sheet
RobbieTheWagner Nov 30, 2026
7bde971
Treat a failed palette.json response as a failed load
RobbieTheWagner Nov 30, 2026
7387790
Merge pull request #89 from shipshapecode/fix/404-people
RobbieTheWagner Nov 30, 2026
9765576
Merge pull request #90 from shipshapecode/fix/palette-payload
RobbieTheWagner Nov 30, 2026
2840c82
Merge pull request #92 from shipshapecode/fix/livescript-clock
RobbieTheWagner Nov 30, 2026
8bdf42d
Merge pull request #93 from shipshapecode/fix/css-weight
RobbieTheWagner Nov 30, 2026
680d20c
Time the rail re-form only in Chromium; unit test slomo()
RobbieTheWagner Nov 30, 2026
faca13a
Test the engine's edges: Watch mid-episode, seeks during a load, shel…
RobbieTheWagner Nov 30, 2026
4d7a323
Let e2e run on any port and pin Playwright to the CI image
RobbieTheWagner Nov 30, 2026
5b2a8b1
Delete dead code and stale references
RobbieTheWagner Nov 30, 2026
2449ab7
Search the palette the way the explorer does
RobbieTheWagner Nov 30, 2026
87c6245
Leave each typed word plain in palette results
RobbieTheWagner Nov 30, 2026
edeadc8
Keep the engine's place through a source change, and ask for a failed…
RobbieTheWagner Nov 30, 2026
dd1a65f
Name the explorer filter, its clear buttons and the palette's groups
RobbieTheWagner Nov 30, 2026
152664a
Stagger palette rows from a per-row --i
RobbieTheWagner Nov 30, 2026
40344ba
Render the feed transcript on the server, not as a load island
RobbieTheWagner Nov 30, 2026
b9889b3
Point CLAUDE.md at packages/starpod and list PageHeader in the README
RobbieTheWagner Nov 30, 2026
e3044bc
Do a keystroke's explorer work once, not three times
RobbieTheWagner Nov 30, 2026
a3ebea3
Fetch the feed once per build and load sponsors in one batch
RobbieTheWagner Nov 30, 2026
9f278c0
Mark the current section from the page, not Chromium's :target-current
RobbieTheWagner Nov 30, 2026
524c1f7
Cap hls.js to the player's size
RobbieTheWagner Nov 30, 2026
1ad976e
Merge pull request #101 from shipshapecode/docs/claude-md-readme
RobbieTheWagner Dec 1, 2026
a1931f4
Merge pull request #95 from shipshapecode/chore/dead-code
RobbieTheWagner Dec 1, 2026
ec0eaa2
Merge pull request #91 from shipshapecode/fix/reduced-motion-slomo
RobbieTheWagner Dec 1, 2026
ac04a4b
Test that typing keeps its words in the explorer's search box
RobbieTheWagner Dec 1, 2026
7a56480
Merge pull request #105 from shipshapecode/perf/explorer-typing
RobbieTheWagner Dec 1, 2026
1134aa0
Merge pull request #108 from shipshapecode/test/ci-flakes
RobbieTheWagner Dec 1, 2026
12c795f
Merge branch 'media-redesign' into chore/e2e-port
RobbieTheWagner Dec 1, 2026
dc81c20
Install CI's browsers from the repo's own Playwright
RobbieTheWagner Dec 1, 2026
2f1d0d3
Merge pull request #94 from shipshapecode/chore/e2e-port
RobbieTheWagner Dec 1, 2026
80ea3e7
Merge pull request #106 from shipshapecode/perf/build-data
RobbieTheWagner Dec 1, 2026
c8a82e2
Merge pull request #98 from shipshapecode/fix/search-a11y
RobbieTheWagner Dec 1, 2026
6e5cabb
Merge remote-tracking branch 'origin/media-redesign' into perf/rss-tr…
RobbieTheWagner Dec 1, 2026
055932b
Merge pull request #102 from shipshapecode/perf/rss-transcript
RobbieTheWagner Dec 1, 2026
d377fcd
Merge pull request #97 from shipshapecode/fix/search-matching
RobbieTheWagner Dec 1, 2026
c3f3caa
Find the explorer's search box by its new name in the typing tests
RobbieTheWagner Dec 1, 2026
24f1518
Merge pull request #109 from shipshapecode/fix/explorer-test-label
RobbieTheWagner Dec 1, 2026
0ce72e0
Merge media-redesign into fix/engine-edges
RobbieTheWagner Dec 1, 2026
6fa1c9e
Merge main into fix/engine-edges
RobbieTheWagner Dec 1, 2026
f1373e4
Address CodeRabbit on the engine edges
RobbieTheWagner Dec 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions packages/starpod/src/components/media/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,18 +727,27 @@ export function mountBoard(host: HTMLElement): Board {
}
const idle = window.requestIdleCallback ?? ((fn: () => void) => window.setTimeout(fn, 200));
const lean = (navigator as Navigator & { connection?: { saveData?: boolean } }).connection?.saveData === true;
// A shelf that failed to load is asked for again when the card is open
// (at once if it is), then each time it opens: never in a loop.
// A shelf that failed to load is asked for again each time the card
// opens: never in a loop.
let asked = false;
// Each opening of a failed card asks only through its own callback: one
// left waiting from an earlier opening goes quiet.
let opening = 0;
const failed = signal(false);
const stopAsking = effect(() => {
const due = failed.value || lean ? open() : currentTime.value > 0;
const isOpen = open();
if (failed.value && !isOpen) {
asked = false;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
opening++;
}
const due = failed.value || lean ? isOpen : currentTime.value > 0;
if (asked || !due) {
return;
}
asked = true;
const mine = opening;
idle(() => {
if (stopped) {
if (stopped || mine !== opening) {
return;
}
void loadShelf().then((ok) => {
Expand All @@ -749,8 +758,6 @@ export function mountBoard(host: HTMLElement): Board {
arrive();
stopAsking();
} else {
asked = false;
// Asked again once the card next opens (not while it is open now).
failed.value = true;
}
});
Expand Down
46 changes: 31 additions & 15 deletions packages/starpod/src/components/media/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type Hls from 'hls.js';
import { flipFrom, registerFlipTargets } from '../../motion/propflip';
import {
activeMedium,
anchorPositioning,
currentEpisode,
currentTime,
isBuffering,
Expand Down Expand Up @@ -83,6 +84,8 @@ let generation = 0;
let stoppedAt = 0;
/** The episode whose playhead the element holds, once its source is ready. */
let playhead: string | null = null;
/** Where the source being loaded starts; a seek or skip meanwhile moves it. */
let startAt = 0;
/** Fired on the element when a source is ready and its playhead placed. */
const READY = 'starpod:ready';
/**
Expand Down Expand Up @@ -263,11 +266,16 @@ async function loadSource(
const video = element!;
const source = ++generation;
const sameEpisode = loaded?.id === episode.id;
// Switching medium mid-episode keeps the visitor's place; a new episode
// resumes where they left it last time; a retry, where it stopped.
const startAt =
// Switching medium mid-episode keeps the visitor's place (still pending in
// startAt if the source isn't ready yet); a new episode resumes where they
// left it last time; a retry, where it stopped.
startAt =
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
retry?.at ??
(sameEpisode ? video.currentTime : resumePoint(episode.id));
(sameEpisode
? playhead === episode.id
? video.currentTime
: startAt
: resumePoint(episode.id));
if (retry) {
isPlaying.value = retry.resume;
}
Expand All @@ -278,8 +286,10 @@ async function loadSource(
playhead = null;
delete video.dataset.ready;
if (video.currentSrc) {
// The old source's pause on the way out is not the visitor's.
// The old source's pause on the way out is not the visitor's. Paused
// now, it can't play on past startAt while hls.js loads.
swapping = true;
video.pause();
}
if (!sameEpisode && video.currentSrc) {
// Let go of the last episode before anything waits (hls.js is imported
Expand Down Expand Up @@ -337,7 +347,7 @@ async function loadSource(
return;
}
swapping = false;
if (startAt > 0 && Math.abs(video.currentTime - startAt) > 1) {
if (Math.abs(video.currentTime - startAt) > 1) {
video.currentTime = startAt;
}
playhead = episode.id;
Expand Down Expand Up @@ -386,21 +396,28 @@ function setMediaSession(episode: PlayableEpisode) {
}
}

/** Is the current episode's source still loading (its playhead is startAt)? */
const loading = () => playhead !== currentEpisode.peek()?.id;

export function skip(seconds: number) {
if (!element) {
return;
}
const max = Number.isFinite(element.duration) ? element.duration : Infinity;
element.currentTime = Math.max(0, Math.min(max, element.currentTime + seconds));
currentTime.value = element.currentTime;
seek(Math.max(0, Math.min(max, (loading() ? startAt : element.currentTime) + seconds)));
}

/** Seek without changing play/pause (the scrubber). */
export function seek(seconds: number) {
if (element) {
if (!element) {
return;
}
if (loading()) {
startAt = seconds;
} else {
element.currentTime = seconds;
currentTime.value = seconds;
}
currentTime.value = seconds;
}

/** Is the media element (or its container) showing fullscreen right now? */
Expand Down Expand Up @@ -500,8 +517,6 @@ function decideStation(fresh = false): Station {
: 'corner';
}

// Flights and anchors need anchor positioning to target a home that scrolls.
const canAnchor = () => globalThis.CSS?.supports?.('anchor-name: --a') ?? false;
let flight = 0;
// Where the picture was on the page being navigated away from.
let departure: DOMRect | null = null;
Expand Down Expand Up @@ -574,9 +589,10 @@ export function placeMedia(mode?: 'again') {
park(outer, station);
return;
}
// With nowhere to fly from, the box would only grow on its new home from
// the size it was parked at.
if (home && (!canAnchor() || !from?.width)) {
// Flights need anchor positioning to target a home that scrolls. With
// nowhere to fly from, the box would only grow on its new home from the
// size it was parked at.
if (home && (!anchorPositioning.value || !from?.width)) {
moveInto(home);
park(outer, station);
return;
Expand Down
112 changes: 108 additions & 4 deletions tests/unit/engine-sources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ vi.mock('../../packages/starpod/node_modules/hls.js', () => {
return { default: FakeHls };
});

import { setRate, startEngine } from 'starpod/src/components/media/engine';
import { seek, setRate, skip, startEngine } from 'starpod/src/components/media/engine';
import { POSITION_PREFIX } from 'starpod/src/components/media/position';
import { currentEpisode, isPlaying, seekTo, setMedium } from 'starpod/src/components/state';
import {
anchorPositioning,
currentEpisode,
isPlaying,
miniClosed,
seekTo,
setMedium
} from 'starpod/src/components/state';

const episode = (id: string, video: false | 'hls' | 'mp4' | true = false) => ({
id,
Expand All @@ -39,11 +46,15 @@ let video: HTMLVideoElement;
let time = 0;
let ready = 0;
let failure: { code: number } | null = null;
let paused = true;
const load = vi.fn(() => {
failure = null;
ready = 0;
});
const play = vi.fn(() => Promise.resolve());
const play = vi.fn(() => {
paused = false;
return Promise.resolve();
});

beforeAll(() => {
Object.defineProperty(navigator, 'mediaSession', {
Expand All @@ -65,7 +76,9 @@ beforeAll(() => {
);
vi.spyOn(HTMLMediaElement.prototype, 'load').mockImplementation(load);
vi.spyOn(HTMLMediaElement.prototype, 'play').mockImplementation(play);
vi.spyOn(HTMLMediaElement.prototype, 'pause').mockImplementation(() => {});
vi.spyOn(HTMLMediaElement.prototype, 'pause').mockImplementation(() => {
paused = true;
});
const make = document.createElement.bind(document);
const spy = vi.spyOn(document, 'createElement').mockImplementation((tag: string, options?: ElementCreationOptions) => {
const element = make(tag, options);
Expand Down Expand Up @@ -233,4 +246,95 @@ describe('the engine', () => {
video.dispatchEvent(new Event('pause'));
expect(localStorage.getItem(POSITION_PREFIX + 'pause-save')).toBe('103');
});

it('starts the video where the audio got to when Watch is chosen', async () => {
currentEpisode.value = episode('to-watch', true);
isPlaying.value = true;
arrive();
time = 100;
setMedium('watch');
// The MP3 plays on while hls.js loads, unless it was stopped.
if (!paused) {
time = 130;
}
const heard = time;
await vi.waitFor(() => expect(video.getAttribute('src')).toBe('blob:stream'));
arrive();
expect(time).toBe(heard);
});

it('keeps a scrub made while loading when Watch is chosen before it is ready', async () => {
currentEpisode.value = episode('scrub-watch', true);
time = 0;
seek(600);
setMedium('watch');
await vi.waitFor(() => expect(video.getAttribute('src')).toBe('blob:stream'));
arrive();
expect(time).toBe(600);
});

it('keeps a skip made while the next episode loads', () => {
localStorage.setItem(POSITION_PREFIX + 'skip-b', '200');
currentEpisode.value = episode('skip-a');
arrive();
time = 50;
currentEpisode.value = episode('skip-b');
time = 0;
skip(30);
arrive();
expect(time).toBe(230);
expect(isPlaying.value).toBe(false);
});

it('keeps a scrub made while the next episode loads', () => {
localStorage.setItem(POSITION_PREFIX + 'scrub-b', '200');
currentEpisode.value = episode('scrub-a');
arrive();
currentEpisode.value = episode('scrub-b');
time = 0;
seek(600);
arrive();
expect(time).toBe(600);
expect(isPlaying.value).toBe(false);
});

it('places the picture without a flight where the player has no anchor positioning', () => {
const css = Object.getOwnPropertyDescriptor(globalThis, 'CSS');
// The browser's own check would say yes; the player's homes say no.
Object.defineProperty(globalThis, 'CSS', {
configurable: true,
value: { supports: () => true, escape: (value: string) => value }
});
anchorPositioning.value = false;
// A flight never finishes here, so a picture that flew stays in the box.
const animations = Object.getOwnPropertyDescriptor(Element.prototype, 'getAnimations');
Object.defineProperty(Element.prototype, 'getAnimations', {
configurable: true,
value: () => [{ finished: new Promise(() => {}) }]
});
document.body.innerHTML =
'<div data-player-media><div><div data-media-dock></div></div></div><div data-media-cell></div>';
try {
setMedium('watch');
currentEpisode.value = episode('no-anchor', 'mp4');
expect(video.parentElement).toBe(document.querySelector('[data-media-dock]'));
video.getBoundingClientRect = () => new DOMRect(0, 0, 160, 90);
miniClosed.value = true;
expect(video.parentElement).toBe(document.querySelector('[data-media-cell]'));
} finally {
miniClosed.value = false;
anchorPositioning.value = true;
document.body.replaceChildren();
if (animations) {
Object.defineProperty(Element.prototype, 'getAnimations', animations);
} else {
delete (Element.prototype as { getAnimations?: unknown }).getAnimations;
}
if (css) {
Object.defineProperty(globalThis, 'CSS', css);
} else {
delete (globalThis as { CSS?: unknown }).CSS;
}
}
});
});
57 changes: 57 additions & 0 deletions tests/unit/queue.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,63 @@ describe('the Up next board', () => {
await waitFor(() => expect(fetched).toHaveBeenCalledTimes(1));
});

it('asks for a shelf that failed again each time the card opens, not while it stays open', async () => {
stop();
document.body.replaceChildren();
const fetched = vi.fn(async () => ({ ok: false, status: 503 }));
vi.stubGlobal('fetch', fetched);
vi.resetModules();
const fresh = await import('starpod/src/components/media/board');
const state = await import('starpod/src/components/state');
state.currentEpisode.value = episode(1);
state.currentTime.value = 1;
state.islandHome.value = 'card';
const host = document.createElement('div');
document.body.append(host);
stop = fresh.mountBoard(host).stop;
await waitFor(() => expect(fetched).toHaveBeenCalledTimes(1));
await new Promise((done) => setTimeout(done, 500));
expect(fetched).toHaveBeenCalledTimes(1);

act(() => {
state.islandHome.value = 'dock';
});
act(() => {
state.islandHome.value = 'card';
});
await waitFor(() => expect(fetched).toHaveBeenCalledTimes(2));
});

it('asks once for a failed shelf when the card closes and opens again before asking', async () => {
stop();
document.body.replaceChildren();
const fetched = vi.fn(async () => ({ ok: false, status: 503 }));
vi.stubGlobal('fetch', fetched);
vi.resetModules();
const fresh = await import('starpod/src/components/media/board');
const state = await import('starpod/src/components/state');
state.currentEpisode.value = episode(1);
state.currentTime.value = 1;
state.islandHome.value = 'card';
const host = document.createElement('div');
document.body.append(host);
stop = fresh.mountBoard(host).stop;
await waitFor(() => expect(fetched).toHaveBeenCalledTimes(1));

// Two openings in quick succession: only the last one's ask goes out.
for (let i = 0; i < 2; i++) {
act(() => {
state.islandHome.value = 'dock';
});
act(() => {
state.islandHome.value = 'card';
});
}
await waitFor(() => expect(fetched).toHaveBeenCalledTimes(2));
await new Promise((done) => setTimeout(done, 500));
expect(fetched).toHaveBeenCalledTimes(2);
});

it('gives every episode one cover that fills a slot by name, and never moves it in the DOM', async () => {
await waitFor(() => expect(fill('ep-5')).toBe('--slot-s0'));
expect(fill('ep-1')).toBe('--slot-now');
Expand Down
Loading