* fix(home): render every active daily program slot instead of four * fix(program): support all daily highlights and release v1.5.77 * fix(program): support all daily highlights and release v1.5.77 * test(home): prevent evening program slots being truncated * docs(program): note full-day homepage highlights v1.5.77 * docs(program): note full-day homepage highlights v1.5.77 * docs(program): note full-day homepage highlights v1.5.77 * docs: publish Landwelle v1.5.77 release notes
52 lines
2.0 KiB
Go
52 lines
2.0 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestHomepageDailyHighlightsIncludeBothEveningSlots(t *testing.T) {
|
|
now := time.Date(2026, time.November, 10, 18, 15, 0, 0, time.Local)
|
|
store := &programStore{items: []ProgramItem{
|
|
{ID:"overnight", Weekday:-1, Start:"00:00", End:"05:00", Show:"Nacht", Active:true},
|
|
{ID:"morning", Weekday:-1, Start:"05:00", End:"10:00", Show:"Morgen", Active:true},
|
|
{ID:"day", Weekday:-1, Start:"10:00", End:"15:00", Show:"Tag", Active:true},
|
|
{ID:"afternoon", Weekday:-1, Start:"15:00", End:"20:00", Show:"Nachmittag", Active:true},
|
|
{ID:"evening", Weekday:-1, Start:"20:00", End:"22:00", Show:"Abend", Active:true},
|
|
{ID:"dockx", Weekday:-1, Start:"22:00", End:"00:00", Show:"dockX", Active:true},
|
|
{ID:"wrongday", Weekday:3, Start:"21:00", End:"22:00", Show:"Mittwoch", Active:true},
|
|
{ID:"disabled", Weekday:-1, Start:"20:30", End:"21:30", Show:"Inaktiv", Active:false},
|
|
}}
|
|
got := store.Highlights(now, 0)
|
|
if len(got) != 6 {
|
|
t.Fatalf("want six shows incl. two evening slots, got %d: %#v", len(got),got)
|
|
}
|
|
if got[4].Start != "20:00" || got[4].End != "22:00" ||
|
|
got[5].Start != "22:00" || got[5].End != "00:00" {
|
|
t.Fatalf("evening highlights missing or unsorted: %#v", got)
|
|
}
|
|
for _, item := range got {
|
|
if !item.Active || item.Weekday == 3 {
|
|
t.Fatalf("inactive or wrong-day show visible: %#v", item)
|
|
}
|
|
}
|
|
if len(store.Highlights(now, 4)) != 4 {
|
|
t.Fatal("explicit highlight limits must remain supported")
|
|
}
|
|
if len(store.Highlights(now, -1)) != 6 {
|
|
t.Fatal("negative limit must not panic or truncate daily schedule")
|
|
}
|
|
}
|
|
|
|
func TestHomepageCallsAllDailyProgramHighlights(t *testing.T) {
|
|
src, err := os.ReadFile("main.go")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.Contains(string(src), "homeData.Program = programs.Highlights(time.Now(), 0)") {
|
|
t.Fatal("homepage highlights must include all active daily slots")
|
|
}
|
|
}
|