package templates import ( "context" "strings" "testing" "time" ) // The archived-items admin page binds its buttons through the page-wide // Alpine component: Purge All is @click="purgeArchivedItems()" and the // per-row Delete/Restore/Merge buttons rely on listeners main.ts binds at // module load. The body tag therefore MUST carry x-data="admin" — the // other admin pages have it, and when this page's body lost it the purge // button rendered as an inert attribute (Alpine only evaluates directives // inside an x-data tree; the click did literally nothing). // // Regression: /admin/archived rendered with no // Alpine scope, so "Purge All Archived" was dead (prod report 2026-10). func TestAdminArchivedPageHasAlpineScope(t *testing.T) { archivedAt := time.Date(2026, 10, 28, 4, 38, 0, 0, time.UTC) var b strings.Builder err := AdminArchived(User{ID: "u1", Timezone: "UTC"}, []ArchivedItem{{ ID: "m1", Title: "Lost Book", Author: "An Author", LibraryName: "Audiobooks", FilePath: "Author/Book/file.m4b", MissingScans: 2, ArchivedAt: &archivedAt, Status: "Archived - pending purge", }}, 0).Render(context.Background(), &b) if err != nil { t.Fatalf("render: %v", err) } out := b.String() if !strings.Contains(out, `