package router import "testing" // The four utterances in Vikunja #552 plus the ones that must keep reaching // the calendar. The list is the whole point of the predicate: every "want // false" row was answered "на 05.08.2026 ничего нет" on the deployed daemon. func TestIsAgendaQuestionSeparatesHisDayFromTheWorld(t *testing.T) { tests := []struct { utterance string want bool }{ // His day. {"что у меня сегодня", true}, {"во сколько у меня встреча сегодня", true}, {"что в календаре на завтра", true}, {"какие планы на завтра", true}, {"какие встречи завтра", true}, {"когда планёрка", true}, {"покажи расписание на среду", true}, {"что дальше?", true}, // No subject of its own, so his day by default. {"что сегодня?", true}, {"что на завтра", true}, {"что там в среду?", true}, // The world, naming a day. Every one of these is #552. {"во сколько закат сегодня", false}, {"какой сегодня курс доллара", false}, {"какой сегодня праздник", false}, {"что интересного произошло сегодня в мире", false}, {"кто выиграл вчера матч", false}, // A day word plus a subject is never subjectless, however short. {"что за праздник сегодня", false}, } for _, tt := range tests { if got := IsAgendaQuestion(tt.utterance); got != tt.want { t.Errorf("IsAgendaQuestion(%q) = %v, want %v", tt.utterance, got, tt.want) } } } // One hand-written utterance per agenda grammar, keyed by name. Asserting that // the grammars pass IsAgendaQuestion would be true by construction, since the // first arm is the loop over them. This asserts something else: that each // grammar still matches the case its own comment gives, and that the set of // grammars has not grown a member nobody wrote an example for. func TestEachAgendaGrammarStillMatchesItsOwnExample(t *testing.T) { examples := map[string]string{ "calendar-query": "что в календаре на завтра", "agenda-query": "что у меня сегодня", "plan-day-query": "какие планы на завтра", "rest-of-day-query": "что дальше?", "event-time-query": "когда планёрка", } for _, g := range AgendaQueryGrammars() { u, ok := examples[g.Name] if !ok { t.Errorf("agenda grammar %q has no example here — add one", g.Name) continue } if !g.Pattern.MatchString(u) { t.Errorf("grammar %q no longer matches %q", g.Name, u) } } }