mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-19 16:48:47 +01:00
test(lyrics): add subsonic e2e baseline for getLyrics endpoints
Establishes a behavioral baseline for getLyricsBySongId (v2 structured)
and getLyrics (legacy) before the lyrics parser refactor. Covers embedded
formats (LRC synced, plain text, TTML) and sidecar formats (LRC, SRT,
YAML), all isolated under a Lyrics/ fixture folder so the new fixtures
do not perturb existing test behavior beyond fixture counts.
Sidecar files are injected as raw &fstest.MapFile{Data: []byte(...)}
entries; the scanner skips non-audio extensions (.lrc, .srt, .yaml) so
they are invisible to scanning but reachable via the fake FS at request
time through fromExternalFile/storage.For.
Update album/artist/song counts in the album-list, multi-library, and
search3 empty-query tests to reflect the six new tracks (1 new artist,
1 new album, 6 new songs).
This commit is contained in:
parent
6672bb52ef
commit
7f004c3268
5 changed files with 124 additions and 18 deletions
|
|
@ -70,6 +70,18 @@ const (
|
|||
mbidSomethingRec = "44444444-4444-4444-a444-444444444444" // mbz_recording_id
|
||||
)
|
||||
|
||||
// Lyric fixture payloads used in buildTestFS.
|
||||
const embeddedTTML = `<tt xmlns="http://www.w3.org/ns/ttml"><body><div><p begin="00:00.000" end="00:01.000">embedded ttml line</p></div></body></tt>`
|
||||
|
||||
const sidecarLyricsfileYAML = `version: "1.0"
|
||||
metadata:
|
||||
title: Sidecar YAML
|
||||
language: eng
|
||||
lines:
|
||||
- text: sidecar yaml line
|
||||
start_ms: 6000
|
||||
`
|
||||
|
||||
// Shared test state
|
||||
var (
|
||||
ctx context.Context
|
||||
|
|
@ -128,6 +140,9 @@ func buildTestFS() storagetest.FakeFS {
|
|||
// Template for diverse-format transcode test tracks
|
||||
tcBase := _t{"albumartist": "Test Artist", "artist": "Test Artist", "album": "Transcode Formats", "year": 2024, "genre": "Test"}
|
||||
|
||||
// Template for lyrics e2e fixture tracks — isolated under Lyrics/ to keep other suite counts stable
|
||||
lyricsAlbum := template(_t{"albumartist": "Lyric Tester", "artist": "Lyric Tester", "album": "Lyrics", "year": 2024, "genre": "Test"})
|
||||
|
||||
return createFS(fstest.MapFS{
|
||||
// Rock / The Beatles / Abbey Road (with MBIDs)
|
||||
// Note: "musicbrainz_trackid" is an alias for the musicbrainz_recordingid tag (populates MbzRecordingID),
|
||||
|
|
@ -177,6 +192,25 @@ func buildTestFS() storagetest.FakeFS {
|
|||
"bitrate": 4500, "samplerate": 48000, "bitdepth": 24, "channels": 6, "duration": int64(180),
|
||||
}),
|
||||
|
||||
// Lyrics fixtures (isolated under Lyrics/ to keep other suite counts stable)
|
||||
// Embedded — lyrics delivered via the "lyrics" tag, parsed at scan time
|
||||
"Lyrics/Embedded/01 - Embedded Synced LRC.mp3": lyricsAlbum(track(1, "Embedded Synced LRC",
|
||||
_t{"lyrics": "[00:01.00]embedded lrc line one\n[00:02.00]embedded lrc line two"})),
|
||||
"Lyrics/Embedded/02 - Embedded Plain.mp3": lyricsAlbum(track(2, "Embedded Plain",
|
||||
_t{"lyrics": "plain embedded line one\nplain embedded line two"})),
|
||||
"Lyrics/Embedded/03 - Embedded TTML.mp3": lyricsAlbum(track(3, "Embedded TTML",
|
||||
_t{"lyrics": embeddedTTML})),
|
||||
|
||||
// Sidecar — raw lyric text files read from the library FS at request time via fromExternalFile.
|
||||
// The scanner skips non-audio extensions (.lrc, .srt, .yaml), so placing them as raw MapFile
|
||||
// entries is safe: they are visible to the fake FS but invisible to the scanner.
|
||||
"Lyrics/Sidecar/01 - Sidecar LRC.mp3": lyricsAlbum(track(1, "Sidecar LRC")),
|
||||
"Lyrics/Sidecar/01 - Sidecar LRC.lrc": &fstest.MapFile{Data: []byte("[00:03.00]sidecar lrc line"), ModTime: time.Now()},
|
||||
"Lyrics/Sidecar/02 - Sidecar SRT.mp3": lyricsAlbum(track(2, "Sidecar SRT")),
|
||||
"Lyrics/Sidecar/02 - Sidecar SRT.srt": &fstest.MapFile{Data: []byte("1\n00:00:04,000 --> 00:00:05,000\nsidecar srt line\n"), ModTime: time.Now()},
|
||||
"Lyrics/Sidecar/03 - Sidecar YAML.mp3": lyricsAlbum(track(3, "Sidecar YAML")),
|
||||
"Lyrics/Sidecar/03 - Sidecar YAML.yaml": &fstest.MapFile{Data: []byte(sidecarLyricsfileYAML), ModTime: time.Now()},
|
||||
|
||||
// _empty folder (directory with no audio)
|
||||
"_empty/.keep": &fstest.MapFile{Data: []byte{}, ModTime: time.Now()},
|
||||
})
|
||||
|
|
@ -409,6 +443,7 @@ var _ = BeforeSuite(func() {
|
|||
|
||||
// Initial setup: schema, user, library, and full scan (runs once for the entire suite)
|
||||
conf.Server.MusicFolder = "fake:///music"
|
||||
conf.Server.LyricsPriority = "embedded,.lrc,.srt,.yaml"
|
||||
conf.Server.DevExternalScanner = false
|
||||
|
||||
db.Init(ctx)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ var _ = Describe("Album List Endpoints", func() {
|
|||
|
||||
Expect(resp.Status).To(Equal(responses.StatusOK))
|
||||
Expect(resp.AlbumList).ToNot(BeNil())
|
||||
Expect(resp.AlbumList.Album).To(HaveLen(7))
|
||||
Expect(resp.AlbumList.Album).To(HaveLen(8))
|
||||
})
|
||||
|
||||
It("type=alphabeticalByName sorts albums by name", func() {
|
||||
|
|
@ -27,15 +27,16 @@ var _ = Describe("Album List Endpoints", func() {
|
|||
|
||||
Expect(resp.AlbumList).ToNot(BeNil())
|
||||
albums := resp.AlbumList.Album
|
||||
Expect(albums).To(HaveLen(7))
|
||||
// Verify alphabetical order: Abbey Road, COWBOY BEBOP, Help!, IV, Kind of Blue, Pop, Transcode Formats
|
||||
Expect(albums).To(HaveLen(8))
|
||||
// Verify alphabetical order: Abbey Road, COWBOY BEBOP, Help!, IV, Kind of Blue, Lyrics, Pop, Transcode Formats
|
||||
Expect(albums[0].Title).To(Equal("Abbey Road"))
|
||||
Expect(albums[1].Title).To(Equal("COWBOY BEBOP"))
|
||||
Expect(albums[2].Title).To(Equal("Help!"))
|
||||
Expect(albums[3].Title).To(Equal("IV"))
|
||||
Expect(albums[4].Title).To(Equal("Kind of Blue"))
|
||||
Expect(albums[5].Title).To(Equal("Pop"))
|
||||
Expect(albums[6].Title).To(Equal("Transcode Formats"))
|
||||
Expect(albums[5].Title).To(Equal("Lyrics"))
|
||||
Expect(albums[6].Title).To(Equal("Pop"))
|
||||
Expect(albums[7].Title).To(Equal("Transcode Formats"))
|
||||
})
|
||||
|
||||
It("type=alphabeticalByArtist sorts albums by artist name", func() {
|
||||
|
|
@ -43,23 +44,24 @@ var _ = Describe("Album List Endpoints", func() {
|
|||
|
||||
Expect(resp.AlbumList).ToNot(BeNil())
|
||||
albums := resp.AlbumList.Album
|
||||
Expect(albums).To(HaveLen(7))
|
||||
Expect(albums).To(HaveLen(8))
|
||||
// Articles like "The" are stripped for sorting, so "The Beatles" sorts as "Beatles"
|
||||
// Non-compilations first: Beatles (x2), Led Zeppelin, Miles Davis, Test Artist, then compilations: Various, then CJK: シートベルツ
|
||||
// Non-compilations: Beatles (x2), Led Zeppelin, Lyric Tester, Miles Davis, Test Artist, then compilations: Various, then CJK: シートベルツ
|
||||
Expect(albums[0].Artist).To(Equal("The Beatles"))
|
||||
Expect(albums[1].Artist).To(Equal("The Beatles"))
|
||||
Expect(albums[2].Artist).To(Equal("Led Zeppelin"))
|
||||
Expect(albums[3].Artist).To(Equal("Miles Davis"))
|
||||
Expect(albums[4].Artist).To(Equal("Test Artist"))
|
||||
Expect(albums[5].Artist).To(Equal("Various"))
|
||||
Expect(albums[6].Artist).To(Equal("シートベルツ"))
|
||||
Expect(albums[3].Artist).To(Equal("Lyric Tester"))
|
||||
Expect(albums[4].Artist).To(Equal("Miles Davis"))
|
||||
Expect(albums[5].Artist).To(Equal("Test Artist"))
|
||||
Expect(albums[6].Artist).To(Equal("Various"))
|
||||
Expect(albums[7].Artist).To(Equal("シートベルツ"))
|
||||
})
|
||||
|
||||
It("type=random returns albums", func() {
|
||||
resp := doReq("getAlbumList", "type", "random")
|
||||
|
||||
Expect(resp.AlbumList).ToNot(BeNil())
|
||||
Expect(resp.AlbumList.Album).To(HaveLen(7))
|
||||
Expect(resp.AlbumList.Album).To(HaveLen(8))
|
||||
})
|
||||
|
||||
It("type=byGenre filters by genre parameter", func() {
|
||||
|
|
@ -190,7 +192,7 @@ var _ = Describe("Album List Endpoints", func() {
|
|||
Expect(resp.Status).To(Equal(responses.StatusOK))
|
||||
Expect(resp.AlbumList2).ToNot(BeNil())
|
||||
albums := resp.AlbumList2.Album
|
||||
Expect(albums).To(HaveLen(7))
|
||||
Expect(albums).To(HaveLen(8))
|
||||
// Verify AlbumID3 format fields
|
||||
Expect(albums[0].Name).To(Equal("Abbey Road"))
|
||||
Expect(albums[0].Id).ToNot(BeEmpty())
|
||||
|
|
@ -201,7 +203,7 @@ var _ = Describe("Album List Endpoints", func() {
|
|||
resp := doReq("getAlbumList2", "type", "newest")
|
||||
|
||||
Expect(resp.AlbumList2).ToNot(BeNil())
|
||||
Expect(resp.AlbumList2.Album).To(HaveLen(7))
|
||||
Expect(resp.AlbumList2.Album).To(HaveLen(8))
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
69
server/e2e/subsonic_lyrics_test.go
Normal file
69
server/e2e/subsonic_lyrics_test.go
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
package e2e
|
||||
|
||||
import (
|
||||
"github.com/navidrome/navidrome/server/subsonic/responses"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Lyrics endpoints", func() {
|
||||
BeforeEach(func() {
|
||||
setupTestDB()
|
||||
})
|
||||
|
||||
// songID resolves a track title to its Subsonic ID via search3.
|
||||
songID := func(title string) string {
|
||||
resp := doReq("search3", "query", title, "songCount", "1", "artistCount", "0", "albumCount", "0")
|
||||
Expect(resp.Status).To(Equal("ok"))
|
||||
Expect(resp.SearchResult3).ToNot(BeNil())
|
||||
Expect(resp.SearchResult3.Song).ToNot(BeEmpty(), "expected to find song %q", title)
|
||||
return resp.SearchResult3.Song[0].Id
|
||||
}
|
||||
|
||||
// main extracts the first StructuredLyric from a LyricsList response.
|
||||
main := func(list *responses.LyricsList) responses.StructuredLyric {
|
||||
Expect(list).ToNot(BeNil())
|
||||
Expect(list.StructuredLyrics).ToNot(BeEmpty())
|
||||
return list.StructuredLyrics[0]
|
||||
}
|
||||
|
||||
Describe("getLyricsBySongId (v2 structured)", func() {
|
||||
DescribeTable("returns structured lyrics for embedded formats",
|
||||
func(title string, wantSynced bool, wantFirstLine string) {
|
||||
resp := doReq("getLyricsBySongId", "id", songID(title))
|
||||
Expect(resp.Status).To(Equal("ok"))
|
||||
got := main(resp.LyricsList)
|
||||
Expect(got.Synced).To(Equal(wantSynced))
|
||||
Expect(got.Line).ToNot(BeEmpty())
|
||||
Expect(got.Line[0].Value).To(Equal(wantFirstLine))
|
||||
},
|
||||
Entry("synced LRC", "Embedded Synced LRC", true, "embedded lrc line one"),
|
||||
Entry("plain text", "Embedded Plain", false, "plain embedded line one"),
|
||||
Entry("TTML", "Embedded TTML", true, "embedded ttml line"),
|
||||
)
|
||||
|
||||
DescribeTable("returns structured lyrics for sidecar formats",
|
||||
func(title string, wantSynced bool, wantFirstLine string) {
|
||||
resp := doReq("getLyricsBySongId", "id", songID(title))
|
||||
Expect(resp.Status).To(Equal("ok"))
|
||||
got := main(resp.LyricsList)
|
||||
Expect(got.Synced).To(Equal(wantSynced))
|
||||
Expect(got.Line).ToNot(BeEmpty())
|
||||
Expect(got.Line[0].Value).To(Equal(wantFirstLine))
|
||||
},
|
||||
Entry("LRC sidecar", "Sidecar LRC", true, "sidecar lrc line"),
|
||||
Entry("SRT sidecar", "Sidecar SRT", true, "sidecar srt line"),
|
||||
Entry("YAML sidecar", "Sidecar YAML", true, "sidecar yaml line"),
|
||||
)
|
||||
})
|
||||
|
||||
Describe("getLyrics (legacy artist/title)", func() {
|
||||
It("returns the main lyric as plain text for an embedded match", func() {
|
||||
resp := doReq("getLyrics", "artist", "Lyric Tester", "title", "Embedded Plain")
|
||||
Expect(resp.Status).To(Equal("ok"))
|
||||
Expect(resp.Lyrics).ToNot(BeNil())
|
||||
Expect(resp.Lyrics.Value).To(ContainSubstring("plain embedded line one"))
|
||||
Expect(resp.Lyrics.Value).To(ContainSubstring("plain embedded line two"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
@ -142,7 +142,7 @@ var _ = Describe("Multi-Library Support", Ordered, func() {
|
|||
resp := doReqWithUser(adminWithLibs, "getAlbumList", "type", "alphabeticalByName", "musicFolderId", fmt.Sprintf("%d", lib.ID))
|
||||
|
||||
Expect(resp.AlbumList).ToNot(BeNil())
|
||||
Expect(resp.AlbumList.Album).To(HaveLen(7))
|
||||
Expect(resp.AlbumList.Album).To(HaveLen(8))
|
||||
for _, a := range resp.AlbumList.Album {
|
||||
Expect(a.Title).ToNot(Equal("Symphony No. 9"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,9 +115,9 @@ var _ = Describe("Search Endpoints", func() {
|
|||
|
||||
Expect(resp.Status).To(Equal(responses.StatusOK))
|
||||
Expect(resp.SearchResult3).ToNot(BeNil())
|
||||
Expect(resp.SearchResult3.Artist).To(HaveLen(6))
|
||||
Expect(resp.SearchResult3.Album).To(HaveLen(7))
|
||||
Expect(resp.SearchResult3.Song).To(HaveLen(14))
|
||||
Expect(resp.SearchResult3.Artist).To(HaveLen(7))
|
||||
Expect(resp.SearchResult3.Album).To(HaveLen(8))
|
||||
Expect(resp.SearchResult3.Song).To(HaveLen(20))
|
||||
})
|
||||
|
||||
It("finds across all entity types simultaneously", func() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue