Compare commits

...
2 Commits
Author SHA1 Message Date
popertots 7d6cb0c375 fix: prettier formatting on EditRequestModal.svelte
CI / Docker compose check (push) Successful in 14s
CI / Env docs check (push) Successful in 14s
CI / Nginx config check (push) Successful in 16s
CI / Frontend deps check (push) Successful in 52s
CI / Frontend major deps (push) Successful in 51s
CI / Frontend build (push) Successful in 1m8s
CI / Secrets scan (push) Successful in 1m8s
CI / Go build (push) Successful in 1m8s
CI / Knip (push) Successful in 45s
CI / Go vet (prod) (push) Successful in 1m19s
CI / Go vet (dev) (push) Successful in 1m37s
CI / Frontend a11y check (push) Successful in 2m21s
CI / go mod tidy (push) Successful in 51s
CI / Frontend QC (audit) (push) Successful in 37s
CI / Staticcheck (prod) (push) Successful in 3m34s
CI / Staticcheck (dev) (push) Successful in 3m35s
CI / golangci-lint (push) Successful in 3m37s
CI / Frontend QC (typecheck) (push) Successful in 1m52s
CI / Go vulnerabilities (push) Successful in 2m26s
CI / Security scan (prod) (push) Successful in 4m9s
CI / Security scan (dev) (push) Successful in 4m43s
CI / Frontend QC (lint) (push) Successful in 2m12s
CI / Svelte strict check (push) Successful in 1m23s
CI / Tests (prod) (push) Successful in 3m25s
CI / Tests (dev) (push) Successful in 3m24s
CI / Race (prod) (push) Successful in 7m7s
CI / Race (dev) (push) Successful in 7m32s
2026-07-11 16:37:33 +01:00
popertotsandSisyphus d6a3e30503 fix: compare notification IDs instead of timestamps in upsert test
The PoolProxy.Begin routes to the outer test transaction, so PG NOW() returns the same value for both handler invocations. Comparing notification IDs correctly verifies the notification was deleted and recreated. Also removes unused testify/assert import.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-11 16:25:33 +01:00
2 changed files with 16 additions and 18 deletions
+10 -17
View File
@@ -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"