fix(podcasts): library switcher leaked literal "continue" and the podcasts option
The D13 podcast exclusion (9a148c23) was written as a templ
`if !IsBookLibrary(...) { continue }` — but templ markup control flow
has NO continue STATEMENT: codegen emitted the word as a TEXT node
(visible junk between options on every page's library subbar) and
rendered the podcasts option anyway, defeating the exclusion. The real
browser sweep caught what every Go/API test structurally cannot:
generated markup that renders wrong yet compiles clean.
Rewritten as an inverted guard (the idiomatic templ skip). New render
pin TestLibrarySwitcherExcludesPodcasts fails on both halves of the
original leak — the literal text AND the presence of the podcasts
option — so this codegen gotcha class stays tripped-wired.
This commit is contained in:
1 parent
c54430c254
commit
7bf5697c71
3 files changed
+170
-151
No files matched your search
@@ -106,3 +106,27 @@ func TestUnlinkedBooksPageRender(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The library switcher's D13 podcast exclusion must hold at the
|
||||
// presentation layer — and the templ `continue` statement leak (codegen
|
||||
// emits it as literal TEXT, browser sweep 2026-10-30) must never return.
|
||||
func TestLibrarySwitcherExcludesPodcasts(t *testing.T) {
|
||||
var b strings.Builder
|
||||
libs := []LibraryData{
|
||||
{ID: "l1", Name: "Ebooks", TypeName: "books", MediaCount: 5},
|
||||
{ID: "l2", Name: "Podcasts", TypeName: "podcasts", MediaCount: 235},
|
||||
}
|
||||
if err := LibrarySwitcher(libs, "l1", "", nil).Render(context.Background(), &b); err != nil {
|
||||
t.Fatalf("LibrarySwitcher: %v", err)
|
||||
}
|
||||
out := b.String()
|
||||
if strings.Contains(out, "Podcasts (235)") {
|
||||
t.Error("switcher leaked the podcasts library into the book switcher")
|
||||
}
|
||||
if strings.Contains(out, "continue") {
|
||||
t.Error("switcher rendered the literal text `continue` (templ has no continue statement)")
|
||||
}
|
||||
if !strings.Contains(out, "Ebooks (5)") {
|
||||
t.Error("switcher missing the books library")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user