Curate daypart prompt exports

This commit is contained in:
2026-06-15 20:38:56 +00:00
parent 1bfd865333
commit 9261431329
6 changed files with 312 additions and 0 deletions

View File

@@ -578,6 +578,84 @@ func TestRenderToday(t *testing.T) {
}
}
func TestRenderDaypartTemplatesUseRichHelperFields(t *testing.T) {
tests := []struct {
name string
template string
context any
want []string
}{
{
name: "daily",
template: "daily",
context: testDailyRenderContext{
Report: testDailyReportContext{Title: "Daily", ForecastDateLabel: "Monday, June 15, 2026"},
GeneratedText: testDailyGeneratedText{Summary: "Daily summary."},
Modules: testDailyModules{Dayparts: []testDailyDaypart{
{Key: "morning", Summary: testDaypartSummary{
DisplayName: "Morning",
DominantConditionDisplay: "Showers",
TemperaturePhraseF: "upper 60s",
}},
}},
},
want: []string{"- **Morning:** Showers, with temperatures in the upper 60s."},
},
{
name: "today",
template: "today",
context: testTodayRenderContext{
Report: testTodayReportContext{Title: "Today", ForecastDateLabel: "Monday, June 15, 2026"},
GeneratedText: testTomorrowGeneratedText{Summary: "Today summary."},
Modules: testTodayModules{Dayparts: []testTomorrowDaypart{
{Key: "afternoon", Summary: testDaypartSummary{
DisplayName: "Afternoon",
DominantConditionDisplay: "Storms",
TemperaturePeakPhraseF: "low 80s",
TemperatureTrend: "peaking",
MaxPopPercent: intPtr(70),
MentionPrecipitation: true,
}},
}},
},
want: []string{"- **Afternoon:** Storms, with temperatures peaking in the low 80s. Chance of precipitation is 70%."},
},
{
name: "tomorrow",
template: "tomorrow",
context: testTomorrowRenderContext{
Report: testTomorrowReportContext{Title: "Tomorrow", ForecastDateLabel: "Tuesday, June 16, 2026"},
GeneratedText: testTomorrowGeneratedText{Summary: "Tomorrow summary."},
Modules: testTomorrowModules{Dayparts: []testTomorrowDaypart{
{Key: "morning", Summary: testDaypartSummary{
DisplayName: "Morning",
DominantConditionDisplay: "Clear",
TemperatureStartPhraseF: "upper 50s",
TemperatureEndPhraseF: "upper 60s",
TemperatureTrend: "rising",
}},
}},
},
want: []string{"- **Morning:** Clear, with temperatures rising from the upper 50s to the upper 60s."},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
rendered, err := Render(tt.template, tt.context)
if err != nil {
t.Fatalf("Render() error = %v", err)
}
text := string(rendered)
for _, want := range tt.want {
if !strings.Contains(text, want) {
t.Fatalf("rendered template missing %q:\n%s", want, text)
}
}
})
}
}
func TestRenderTomorrowOmitsPrecipitationTimingWithoutWindows(t *testing.T) {
rendered, err := Render("tomorrow", testTomorrowRenderContext{
Report: testTomorrowReportContext{