oficina / calendar Public

Stabilize booked event form test across time zones

Paul Campbell pushed by paul@keymail.dev fa29a1ddaae34c593195f33243702d5de09c3802 parent 3d8ea7b
1 file changed, +26 −3
  • internal/calendartest/booking_settings_test.go +26 −3

CI passed — run details

CI log
=== vet ===
go vet ./...
=== fmt ===
=== test ===
go test ./...
?   	amadan.net/oficina/calendar/cmd/calendar	[no test files]
ok  	amadan.net/oficina/calendar/internal/calendar	(cached)
?   	amadan.net/oficina/calendar/internal/calendar/icons	[no test files]
?   	amadan.net/oficina/calendar/internal/calendar/seal	[no test files]
ok  	amadan.net/oficina/calendar/internal/calendartest	2.007s
ok  	amadan.net/oficina/calendar/internal/guardstest	0.036s
=== migration-check ===
go run github.com/carlosframework/rastrillo/cmd/rastrillo migration check
rastrillo migration check: models and migrations agree
diff --git a/internal/calendartest/booking_settings_test.go b/internal/calendartest/booking_settings_test.go
index 9eeec3b..4525472 100644
--- a/internal/calendartest/booking_settings_test.go
+++ b/internal/calendartest/booking_settings_test.go
@@ -116,11 +116,28 @@ func TestATakenHandleIsRefusedOnSettings(t *testing.T) {
// works — and still works after the host changes their profile zone,
// because the hidden tz is the event's own (B25).
func TestABookedEventsFormLocksItsTimeButSavesItsTitle(t *testing.T) {
+ // Keep this scenario independent of the machine's wall clock. In
+ // particular, exercise both sides of the Dublin DST boundary as well as
+ // the date on which this test previously failed in CI.
+ for _, now := range []struct {
+ name string
+ now time.Time
+ }{
+ {"ci-failure-2026-09-24", time.Date(2026, time.September, 24, 13, 0, 0, 0, time.UTC)},
+ {"dublin-dst-start", time.Date(2026, time.March, 29, 13, 0, 0, 0, time.UTC)},
+ {"dublin-dst-end", time.Date(2026, time.October, 25, 13, 0, 0, 0, time.UTC)},
+ } {
+ t.Run(now.name, func(t *testing.T) {
+ testABookedEventsFormLocksItsTimeButSavesItsTitle(t, now.now)
+ })
+ }
+}
+
+func testABookedEventsFormLocksItsTimeButSavesItsTitle(t *testing.T, now time.Time) {
app, host, page := hostWithPage(t)
h := app.Handler()
session := app.SignInForTest(t, host.Address)
st := app.StoreForTest()
- now := time.Now()
slot := slotsFor(t, app, page, host, now, 3)[0]
b, err := st.HoldBooking(context.Background(), holdInput(page, host, slot, "doc@tito.io", "ip"), now)
if err != nil {
@@ -144,8 +161,14 @@ func TestABookedEventsFormLocksItsTimeButSavesItsTitle(t *testing.T) {
t.Fatalf("title-only save: %d\n%s", rec.Code, rec.Body.String())
}
// And a stale form with the old time after a public reschedule is refused.
- slots := slotsFor(t, app, page, host, now, 3)
- v, _ := st.BookingByID(context.Background(), b.ID, false)
+ // Settings above changed the host's zone. Read the booking again before
+ // selecting the new public slot, so FreeSlots and RescheduleBooking use
+ // the same host-zone record.
+ v, err := st.BookingByID(context.Background(), b.ID, false)
+ if err != nil {
+ t.Fatal(err)
+ }
+ slots := slotsFor(t, app, v.Page, v.Host, now, 3)
if changed, err := st.RescheduleBooking(context.Background(), b.ID, slots[3].StartUTC, slots[3].EndUTC, v.Event.Sequence, now); err != nil || !changed {
t.Fatalf("reschedule: changed=%v err=%v", changed, err)
}