Phase 6b/7b: dashboard codes editor, decode events, human-readable briefs (AUD-115)
- New /codes dashboard page (behind the session login, linked in the top bar):
lists every mapping by kind with Add, inline Edit+Save and Delete. Sam can put
real teacher surnames in without a rebuild (FR-17).
- Decode timetable EVENTS through the same map as periods, so an ensemble reads
'JAZZ ENSEMBLE - Ensemble Room - Mr KWO' instead of raw codes.
- teacherName splits comma- or space-separated codes ('HHL, OFG').
- SeedCodes is a one-time bootstrap while the table is empty, so a correction or
a delete is never overwritten or restored.
- Tests: decode Label/Event, the /codes page (save, refuse, csrf, delete, auth),
store re-seed behaviour. go test ./internal/... passes.
This commit is contained in:
@@ -50,3 +50,31 @@ func TestPeriodLeavesEventsAlone(t *testing.T) {
|
||||
t.Errorf("Period = %q, want the event unchanged", got)
|
||||
}
|
||||
}
|
||||
|
||||
// TestLabelDecodesEventsAndLessons proves FR-17 covers timetable events too: an
|
||||
// ensemble or a concert reads as plain English, its room and teachers decoded,
|
||||
// while the event name is kept as the school wrote it. A single-part label is
|
||||
// returned unchanged and an unmapped code stays raw.
|
||||
func TestLabelDecodesEventsAndLessons(t *testing.T) {
|
||||
codes := testCodes()
|
||||
codes.Room["THEATRE"] = "Theatre"
|
||||
codes.Room["ENS"] = "Ensemble Room"
|
||||
codes.Room["IM3"] = "Room IM3"
|
||||
codes.Teacher["HHL"] = "Mr HHL"
|
||||
codes.Teacher["OFG"] = "Mr OFG"
|
||||
codes.Teacher["KWO"] = "Mr KWO"
|
||||
|
||||
cases := map[string]string{
|
||||
"1 - 7SCF - H14LAB - KNI": "Period 1 — Year 7 Science — Room H14LAB — Mr KNI",
|
||||
"JUNIOR GUITAR ENSEMBLE - THEATRE - HHL, OFG": "JUNIOR GUITAR ENSEMBLE — Theatre — Mr HHL / Mr OFG",
|
||||
"JAZZ ENSEMBLE - ENS - KWO": "JAZZ ENSEMBLE — Ensemble Room — Mr KWO",
|
||||
"HHL GUITAR E - IM3 - HHL": "HHL GUITAR E — Room IM3 — Mr HHL",
|
||||
"Curriculum Day": "Curriculum Day",
|
||||
"Concert - HALL": "Concert — HALL",
|
||||
}
|
||||
for raw, want := range cases {
|
||||
if got := Label(raw, codes); got != want {
|
||||
t.Errorf("Label(%q) = %q, want %q", raw, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user