From eb4a02205f5b3b972c44b854d5becbbd0b522981 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Wed, 5 Aug 2026 14:10:34 +0200 Subject: readings: PartIDs(new) stops declaring aklamacja, which the engine never emits caldata.go:42 parses only first/psalm/second/gospel out of the lectionary data, so no OF reading ever carries Part == "acclamation". PartIDs("new") listed aklamacja anyway, so the app built a checkbox from it that filters an ID that never appears -- a dead control, same defect class the app previously shipped for the whole 1962 form. ofPartOrder stays the full five-ID set: it also drives render.LocalizeHeading's label matching, where a scraped heading can still read "Aklamacja" even though this engine's own readings never produce that section. PartIDs now draws from a new, narrower ofEmittedPartOrder instead. Rewrote TestPartLabelsMatchesWhatTheEngineEmits's OF half: it compared PartLabels("of") to a hand-copied duplicate of ofPartOrder, asserting a declaration against itself, which cannot fail for this class of bug. It now sweeps Days over calendar year 2026 and asserts PartLabels("of") matches the observed part-ID set exactly (0.5s). Confirmed red against the pre-fix code, green after. --- mobile/mobile_test.go | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) (limited to 'mobile') diff --git a/mobile/mobile_test.go b/mobile/mobile_test.go index cf75b7f..85de500 100644 --- a/mobile/mobile_test.go +++ b/mobile/mobile_test.go @@ -152,23 +152,50 @@ func TestPartLabelsMatchesWhatTheEngineEmits(t *testing.T) { t.Errorf("ef[1] = %v, want evangelium/Ewangelia", ef[1]) } + // OF: derive the expected set from what Days actually emits over a full + // year (2026 -- a full Sunday cycle, so second readings appear too), + // rather than hand-copying the production list, which asserts a + // declaration against itself and can never fail for this class of bug + // (that is exactly how the app came to render a checkbox -- aklamacja -- + // that filters an ID the engine never emits). + observed := map[string]bool{} + s := Days("2026-01-01", 365, "of", "pl") + var days []map[string]any + if err := json.Unmarshal([]byte(s), &days); err != nil { + t.Fatalf("Days returned invalid JSON: %v", err) + } + for _, d := range days { + parts, _ := d["parts"].([]any) + for _, p := range parts { + part, _ := p.(map[string]any) + if id, ok := part["part"].(string); ok { + observed[id] = true + } + } + } + if len(observed) == 0 { + t.Fatal("swept zero part IDs from Days over 2026 -- the sweep is broken, not necessarily the engine") + } + var of []map[string]any if err := json.Unmarshal([]byte(PartLabels("of", "pl")), &of); err != nil { t.Fatalf("invalid JSON: %v", err) } - if len(of) != 5 { - t.Fatalf("of: got %d labels, want 5: %v", len(of), of) - } - // aklamacja was missing from the app's hardcoded list. - var seen []string + got := map[string]bool{} for _, e := range of { - seen = append(seen, e["part"].(string)) + got[e["part"].(string)] = true + } + if len(got) != len(of) { + t.Fatalf("PartLabels(of) lists a part ID more than once: %v", of) + } + for id := range observed { + if !got[id] { + t.Errorf("Days emits part %q somewhere in 2026 but PartLabels(of) does not list it: %v", id, of) + } } - want := []string{"pierwsze_czytanie", "psalm", "drugie_czytanie", "aklamacja", "ewangelia"} - for i := range want { - if seen[i] != want[i] { - t.Errorf("of order = %v, want %v", seen, want) - break + for id := range got { + if !observed[id] { + t.Errorf("PartLabels(of) lists part %q but Days never emits it anywhere in 2026: %v", id, of) } } } -- cgit v1.3