Phase 6b/7b: per-child decoded periods, separate brief blocks, idempotent calendar (AUD-119)
- Parse each child's own "Today" day widget for the timetable (FR-16); drop the school-wide week calendar's lesson grid and clean the leaked routine rows. - Add the editable codes map (FR-17): subjects, rooms, teachers and period labels, seeded, an unknown code falls back to the raw code; `school codes` CLI. - Brief: Finn's block first, then Harry's, four sections always present (FR-9); periods decoded into plain English; the undated tail is one counted line (FR-18). - Calendar: write periods + work due + work overdue + major events, per child, on every pass. Identity is the stable per-item key, so a re-run never re-inserts (FR-8). morning-brief.sh now runs scan -> calendar push -> notify. - Day-widget labels are 12-hour: 1-6 read as PM, fixing afternoon periods. Proven live on .13: image 0.6.2-phase6b7b; both children's briefs decoded and separate; 35 events in calendar.school; runs 2 and 3 of the scan added nothing. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -148,16 +148,20 @@ func TestMorningSendsPerBoyAndCombined(t *testing.T) {
|
||||
t.Fatalf("morning: %v", err)
|
||||
}
|
||||
if len(sends) != 3 {
|
||||
t.Fatalf("sends = %d, want Harry, Finn and combined", len(sends))
|
||||
t.Fatalf("sends = %d, want Finn, Harry and combined", len(sends))
|
||||
}
|
||||
for _, s := range sends {
|
||||
if !s.OK() {
|
||||
t.Errorf("send %s not OK: %+v", s.Scope, s)
|
||||
}
|
||||
}
|
||||
// Finn's block comes first, then Harry's (FR-9).
|
||||
if sends[0].Scope != "Finn" || sends[1].Scope != "Harry" {
|
||||
t.Fatalf("send order = %s, %s; want Finn then Harry", sends[0].Scope, sends[1].Scope)
|
||||
}
|
||||
|
||||
// Harry: 1 recipient x 2 channels. Combined: 2 recipients x 2 channels.
|
||||
if got := len(sends[0].Deliveries); got != 2 {
|
||||
if got := len(sends[1].Deliveries); got != 2 {
|
||||
t.Errorf("Harry deliveries = %d, want 2", got)
|
||||
}
|
||||
combined := sends[2]
|
||||
@@ -193,10 +197,16 @@ func TestMorningSendsPerBoyAndCombined(t *testing.T) {
|
||||
}
|
||||
}
|
||||
if !strings.Contains(combined.Text, "OVERDUE") ||
|
||||
!strings.Contains(combined.Text, "Harry: English: Essay") ||
|
||||
!strings.Contains(combined.Text, "Finn: Science: Lab report") {
|
||||
!strings.Contains(combined.Text, "=== FINN ===") ||
|
||||
!strings.Contains(combined.Text, "=== HARRY ===") ||
|
||||
!strings.Contains(combined.Text, "Science: Lab report") ||
|
||||
!strings.Contains(combined.Text, "English: Essay") {
|
||||
t.Errorf("combined text = %q", combined.Text)
|
||||
}
|
||||
// Finn's block is first and the two children are never interleaved.
|
||||
if i, j := strings.Index(combined.Text, "=== FINN ==="), strings.Index(combined.Text, "=== HARRY ==="); i < 0 || j < 0 || i > j {
|
||||
t.Errorf("combined blocks are not Finn then Harry: %q", combined.Text)
|
||||
}
|
||||
|
||||
rows, err := st.RecentNotifications(context.Background(), 20)
|
||||
if err != nil {
|
||||
@@ -278,19 +288,19 @@ func TestFailedScanIsNeverNothingDue(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("morning: %v", err)
|
||||
}
|
||||
if len(sends[0].ScanFailed) != 1 || sends[0].ScanFailed[0] != "Harry" {
|
||||
t.Errorf("Harry scan failure not reported: %+v", sends[0].ScanFailed)
|
||||
if len(sends[1].ScanFailed) != 1 || sends[1].ScanFailed[0] != "Harry" {
|
||||
t.Errorf("Harry scan failure not reported: %+v", sends[1].ScanFailed)
|
||||
}
|
||||
if !strings.Contains(sends[0].Text, "SCAN FAILED") {
|
||||
t.Errorf("brief does not say the scan failed: %q", sends[0].Text)
|
||||
if !strings.Contains(sends[1].Text, "SCAN FAILED") {
|
||||
t.Errorf("brief does not say the scan failed: %q", sends[1].Text)
|
||||
}
|
||||
if !strings.Contains(sends[0].Text, "UNKNOWN") {
|
||||
t.Errorf("brief does not say due work is unknown: %q", sends[0].Text)
|
||||
if !strings.Contains(sends[1].Text, "UNKNOWN") {
|
||||
t.Errorf("brief does not say due work is unknown: %q", sends[1].Text)
|
||||
}
|
||||
if !strings.Contains(sends[2].Text, "SCAN FAILED") {
|
||||
t.Errorf("combined brief does not carry the failure: %q", sends[2].Text)
|
||||
}
|
||||
if sends[0].OK() {
|
||||
if sends[1].OK() {
|
||||
t.Error("a scan failure must make the run not OK")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user