summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/readings/offline.go14
-rw-r--r--internal/readings/partids_test.go2
-rw-r--r--mobile/mobile_test.go49
3 files changed, 52 insertions, 13 deletions
diff --git a/internal/readings/offline.go b/internal/readings/offline.go
index 608abd8..be7c430 100644
--- a/internal/readings/offline.go
+++ b/internal/readings/offline.go
@@ -98,6 +98,18 @@ var (
efPartOrder = []string{"epistola", "evangelium"}
)
+// ofEmittedPartOrder is the subset of ofPartOrder the offline engine can
+// actually produce, in display order. It excludes "aklamacja":
+// internal/caldata/caldata.go:42 parses only "first", "psalm", "second" and
+// "gospel" out of the lectionary data, so no computed OF reading ever carries
+// Part == "acclamation" and ofPart's "aklamacja" mapping above is never
+// reached. ofPartOrder stays the full five-ID set on purpose -- 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 -- so PartIDs, which promises IDs an app can filter
+// on, needs this narrower list rather than reusing or shrinking ofPartOrder.
+var ofEmittedPartOrder = []string{"pierwsze_czytanie", "psalm", "drugie_czytanie", "ewangelia"}
+
// PartIDs returns the part IDs the given lectionary can emit, in display order.
// lect takes config.Config.Lectionary's values: "new" or "traditional". An
// unknown lectionary returns nil. Callers that build per-part UI (the dlectio
@@ -106,7 +118,7 @@ var (
func PartIDs(lect string) []string {
switch lect {
case "new":
- return append([]string(nil), ofPartOrder...)
+ return append([]string(nil), ofEmittedPartOrder...)
case "traditional":
return append([]string(nil), efPartOrder...)
}
diff --git a/internal/readings/partids_test.go b/internal/readings/partids_test.go
index 1ba9373..fdbd816 100644
--- a/internal/readings/partids_test.go
+++ b/internal/readings/partids_test.go
@@ -35,7 +35,7 @@ func TestDayInfoCarriesRank(t *testing.T) {
// them instead, seven of the nine 1962 IDs were wrong and the epistle's
// checkbox did nothing.
func TestPartIDs(t *testing.T) {
- wantNew := []string{"pierwsze_czytanie", "psalm", "drugie_czytanie", "aklamacja", "ewangelia"}
+ wantNew := []string{"pierwsze_czytanie", "psalm", "drugie_czytanie", "ewangelia"}
wantOld := []string{"epistola", "evangelium"}
if got := PartIDs("new"); !equalSlice(got, wantNew) {
t.Errorf("PartIDs(new) = %v, want %v", got, wantNew)
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)
}
}
}