Compare commits
2
Commits
c8051a76d6
...
7d6cb0c375
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d6cb0c375 | ||
|
|
d6a3e30503 |
@@ -39,7 +39,6 @@ import (
|
|||||||
"crussell/testutils/jwt"
|
"crussell/testutils/jwt"
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
@@ -2284,11 +2283,10 @@ func TestRequestEditHandler_NotificationUpsertOnReplace(t *testing.T) {
|
|||||||
t.Fatalf("first edit request failed: %d", w.Code)
|
t.Fatalf("first edit request failed: %d", w.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Capture first notification's created_at
|
var firstNotifID string
|
||||||
var firstCreatedAt time.Time
|
|
||||||
err := tx.QueryRow(ctx,
|
err := tx.QueryRow(ctx,
|
||||||
"SELECT created_at FROM admin_notifications WHERE booking_id = $1 AND reason = 'edit_requested'",
|
"SELECT id FROM admin_notifications WHERE booking_id = $1 AND reason = 'edit_requested'",
|
||||||
bookingID).Scan(&firstCreatedAt)
|
bookingID).Scan(&firstNotifID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("expected first notification to exist: %v", err)
|
t.Fatalf("expected first notification to exist: %v", err)
|
||||||
}
|
}
|
||||||
@@ -2304,12 +2302,7 @@ func TestRequestEditHandler_NotificationUpsertOnReplace(t *testing.T) {
|
|||||||
t.Fatalf("expected 1 notification after first request, got %d", notifCount)
|
t.Fatalf("expected 1 notification after first request, got %d", notifCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure time has advanced past firstCreatedAt so the next notification has a distinct timestamp
|
// Create second edit request (upsert) — deletes old notification, inserts new one
|
||||||
assert.Eventually(t, func() bool {
|
|
||||||
return time.Now().After(firstCreatedAt.Add(time.Millisecond))
|
|
||||||
}, 5*time.Second, time.Millisecond, "timed out waiting for time to advance")
|
|
||||||
|
|
||||||
// Create second edit request (upsert)
|
|
||||||
w = makeRequest(handler, "POST", "/api/bookings/"+bookingID+"/edit-request",
|
w = makeRequest(handler, "POST", "/api/bookings/"+bookingID+"/edit-request",
|
||||||
map[string]interface{}{"new_start_time": time2.Format(time.RFC3339)}, token, ctx)
|
map[string]interface{}{"new_start_time": time2.Format(time.RFC3339)}, token, ctx)
|
||||||
if w.Code != http.StatusCreated {
|
if w.Code != http.StatusCreated {
|
||||||
@@ -2327,16 +2320,16 @@ func TestRequestEditHandler_NotificationUpsertOnReplace(t *testing.T) {
|
|||||||
t.Errorf("expected 1 notification after upsert, got %d", notifCount)
|
t.Errorf("expected 1 notification after upsert, got %d", notifCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the notification has a fresh created_at (newer than original)
|
// Verify the notification was recreated (different ID from original)
|
||||||
var secondCreatedAt time.Time
|
var secondNotifID string
|
||||||
err = tx.QueryRow(ctx,
|
err = tx.QueryRow(ctx,
|
||||||
"SELECT created_at FROM admin_notifications WHERE booking_id = $1 AND reason = 'edit_requested'",
|
"SELECT id FROM admin_notifications WHERE booking_id = $1 AND reason = 'edit_requested'",
|
||||||
bookingID).Scan(&secondCreatedAt)
|
bookingID).Scan(&secondNotifID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("expected notification to exist after upsert: %v", err)
|
t.Fatalf("expected notification to exist after upsert: %v", err)
|
||||||
}
|
}
|
||||||
if !secondCreatedAt.After(firstCreatedAt) {
|
if secondNotifID == firstNotifID {
|
||||||
t.Errorf("expected notification created_at to be newer than original: first=%v, second=%v", firstCreatedAt, secondCreatedAt)
|
t.Errorf("expected notification to be recreated (new ID), but got same ID: %s", secondNotifID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -777,7 +777,12 @@
|
|||||||
<p class="font-medium text-amber-900">Cannot Reschedule Online</p>
|
<p class="font-medium text-amber-900">Cannot Reschedule Online</p>
|
||||||
<p class="mt-1">{noticeBlockedMessage}</p>
|
<p class="mt-1">{noticeBlockedMessage}</p>
|
||||||
<p class="mt-1">
|
<p class="mt-1">
|
||||||
<a href="/contact" target="_blank" rel="noopener noreferrer external" class="underline">Contact us</a>
|
<a
|
||||||
|
href="/contact"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer external"
|
||||||
|
class="underline">Contact us</a
|
||||||
|
>
|
||||||
to discuss options, or
|
to discuss options, or
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
Reference in New Issue
Block a user