Inbäddad mini-spelare: ▶ på korten spelar direkt i appen
All checks were successful
build-and-push / build (push) Successful in 14s

- GET /api/play?q=: slår upp spelbart videoId via YouTube Data API
  (kategori musik, YOUTUBE_API_KEY i stackens .env)
- MiniPlayer: fast spelare nere till höger (YouTube-embed, autoplay),
  ligger kvar medan man bläddrar; stängs med ✕
- MusicCard: ▶-knapp på artist/album/låt/sångare (genrer behåller sina
  två knappar); YT-länken heter nu 'YT ↗'
- 2 nya tester, totalt 31

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01824ZrvG2mDYYrmwqypLNup
This commit is contained in:
2026-08-01 04:38:33 +02:00
parent 4e89bd1986
commit 9874d383ea
7 changed files with 174 additions and 8 deletions

View File

@@ -130,6 +130,38 @@ test('POST /api/add med låt går via albumet', async () => {
await app.close()
})
test('GET /api/play slår upp videoId via YouTube Data API', async () => {
const playConfig = { ...config, youtube: { apiKey: 'yt-nyckel' } }
const app = buildApp(playConfig, {
lidarr: {},
musicbrainz: {},
playFetch: async (url) => {
assert.match(url, /videoCategoryId=10/)
assert.match(url, /q=Powerwolf%20Sanctified/)
return {
ok: true,
json: async () => ({
items: [{ id: { videoId: 'abc123' }, snippet: { title: 'Sanctified with Dynamite', channelTitle: 'Powerwolf - Topic' } }],
}),
}
},
})
const cookie = await loggedIn(app)
const res = await app.inject({ method: 'GET', url: '/api/play?q=Powerwolf%20Sanctified', headers: { cookie } })
assert.equal(res.statusCode, 200)
assert.equal(res.json().videoId, 'abc123')
await app.close()
})
test('GET /api/play utan nyckel ger begripligt fel', async () => {
const app = buildApp({ ...config, youtube: { apiKey: '' } }, { lidarr: {}, musicbrainz: {} })
const cookie = await loggedIn(app)
const res = await app.inject({ method: 'GET', url: '/api/play?q=x', headers: { cookie } })
assert.equal(res.statusCode, 500)
assert.match(res.json().error, /YOUTUBE_API_KEY/)
await app.close()
})
test('POST /api/add svarar already för befintlig artist', async () => {
const app = buildApp(config, {
lidarr: { search: async () => [{ artist: { ...powerwolf, id: 12 } }] },