From ec703a39738fefb60817f5659f76f8e683f8d301 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 5 Oct 2026 17:39:06 -0400 Subject: fix: admin undo/redo failure, video poker cabinet ids, room ref behavior --- internal/admin/correct_audit_fixes_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'internal/admin/correct_audit_fixes_test.go') diff --git a/internal/admin/correct_audit_fixes_test.go b/internal/admin/correct_audit_fixes_test.go index 60073f7..d97732d 100644 --- a/internal/admin/correct_audit_fixes_test.go +++ b/internal/admin/correct_audit_fixes_test.go @@ -49,3 +49,27 @@ func TestRestoreAccountSecretRefusesNonMappingBody(t *testing.T) { t.Fatalf("password hash not preserved: %s", out) } } + +// Regression: a failed undo returned a nil change exactly like an empty +// history, so the UI reported "Nothing to undo" for a real failure. +func TestUndoFailureIsReportedDistinctly(t *testing.T) { + dir := t.TempDir() + us := NewUndoStack(dir) + us.Push(ChangeDesc{ + Description: "edit with a missing before-image", + FilePath: filepath.Join(dir, "rooms", "1.yaml"), + OldContent: nil, + NewContent: []byte("id: 1\n"), + }) + if ch := us.Undo(); ch != nil { + t.Fatal("undo with a missing before-image unexpectedly succeeded") + } + if err := us.LastError(); err == nil { + t.Fatal("LastError = nil after a failed undo; the UI would report 'Nothing to undo'") + } + // A genuinely empty history is a clean nil change and nil error. + us2 := NewUndoStack(t.TempDir()) + if ch := us2.Undo(); ch != nil || us2.LastError() != nil { + t.Fatal("empty history must be a clean nil change and nil error") + } +} -- cgit v1.2.3