Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions gui/src/pages/GuidedSetupPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ function BrowserGuidedSetupPage({
<article className="setup-step-card">
<div className="setup-step-heading"><div className="setup-step-icon" aria-hidden="true"><ListVideo size={22} /></div><div><p className="setup-step-number">Step 1</p><h2>Playlists</h2></div></div>
<p className="setup-step-description">Add every playlist that belongs in the source set. Each item can be a local file or a public HTTPS URL.</p>
<p className="setup-step-description">Links with a password or token in them are not supported yet. Use a file instead.</p>
{playlists.map((source, index) => renderSourceRow(source, 'playlist', index))}
<button className="button button-secondary" type="button" onClick={addPlaylist}>Add another playlist</button>
</article>
Expand All @@ -329,6 +330,7 @@ function BrowserGuidedSetupPage({
return (
<fieldset className="setup-binding-fieldset" key={guide.id}>
<legend>{guide.label || 'Guide'} — Apply this guide to:</legend>
{playlists.length > 1 && !selection.all && selection.playlistIds.length === 0 && !selection.explicitlyUnbound ? <p className="setup-binding-status" role="status"><strong>Choose a playlist for this guide</strong></p> : null}
<p className="setup-binding-status" role="status">{bindingStatus}</p>
{playlists.length > 1 ? <label><input checked={selection.all} type="checkbox" onChange={(event) => setBinding(guide.id, { all: event.target.checked, playlistIds: [] })} /> All playlists</label> : null}
{playlists.map((playlist) => <label key={playlist.id}><input checked={!selection.all && selection.playlistIds.includes(playlist.id)} disabled={selection.all} type="checkbox" onChange={(event) => setBinding(guide.id, { all: false, playlistIds: event.target.checked ? [...selection.playlistIds, playlist.id] : selection.playlistIds.filter((id) => id !== playlist.id) })} /> {playlist.label || 'Playlist'}</label>)}
Expand Down
31 changes: 31 additions & 0 deletions gui/src/test/guided-setup-browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,35 @@ describe('browser Guided Setup proposal and acceptance', () => {
expect.objectContaining({ playlistRefs: ['playlist-1', expect.stringMatching(/^playlist-2-/)], appliesToAll: false }),
])
})

it('says tokenized links are unsupported', () => {
render(<GuidedSetupPage pickerAvailable={false} sourceSetProposalSubmitter={vi.fn<GuidedSetupSourceSetSubmitter>()} />)
expect(screen.getByText(/Links with a password or token in them are not supported yet/)).toBeInTheDocument()
})

it('does not ask to choose a playlist when there is only one playlist', async () => {
const user = userEvent.setup()
render(<GuidedSetupPage pickerAvailable={false} sourceSetProposalSubmitter={vi.fn<GuidedSetupSourceSetSubmitter>()} />)

await user.upload(screen.getByLabelText('Choose playlist'), new File(['#EXTM3U\n'], 'one.m3u'))
await user.click(screen.getByRole('button', { name: 'Add guide' }))
await user.upload(screen.getByLabelText('Choose guide'), new File(['<tv></tv>'], 'guide.xml'))
expect(screen.queryByText('Choose a playlist for this guide')).not.toBeInTheDocument()
})

it('asks to choose a playlist for a guide with several playlists and no binding yet', async () => {
const user = userEvent.setup()
render(<GuidedSetupPage pickerAvailable={false} sourceSetProposalSubmitter={vi.fn<GuidedSetupSourceSetSubmitter>()} />)

await user.upload(screen.getByLabelText('Choose playlist'), new File(['#EXTM3U\n'], 'one.m3u'))
await user.click(screen.getByRole('button', { name: 'Add another playlist' }))
await user.upload(screen.getAllByLabelText('Choose playlist')[1], new File(['#EXTM3U\n'], 'two.m3u'))
await user.click(screen.getByRole('button', { name: 'Add guide' }))
await user.upload(screen.getByLabelText('Choose guide'), new File(['<tv></tv>'], 'guide.xml'))
expect(screen.getByText('Choose a playlist for this guide')).toBeInTheDocument()
expect(screen.getByText(/Unbound because no binding decision was supplied/)).toBeInTheDocument()

await user.click(screen.getByRole('checkbox', { name: 'Playlist 1' }))
expect(screen.queryByText('Choose a playlist for this guide')).not.toBeInTheDocument()
})
})
Loading