web: friendly Paste ID not found page for missing pastes (#173)
Missing or expired paste IDs (and unknown routes) now render the main UI chrome with a 'Paste ID not found' message in a color-coded result card instead of a bare text/JSON 404. HTTP status stays 404. No inline scripts or styles; new CSS uses existing --err token and pill radii.
This commit is contained in:
@@ -299,3 +299,27 @@ func TestNotFound(t *testing.T) {
|
||||
t.Fatalf("expected 404, got %d", rec.Code)
|
||||
}
|
||||
}
|
||||
|
||||
// #173: a missing paste ID on the UI route (/p/{id}, i.e. /{id} HTML view)
|
||||
// should render the main UI page with a friendly "Paste ID not found"
|
||||
// message, not a bare text 404. Status stays 404.
|
||||
func TestPasteViewNotFoundFriendly(t *testing.T) {
|
||||
s := testServer(t)
|
||||
h := s.routes()
|
||||
req := httptest.NewRequest("GET", "/zzzzzz", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
h.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusNotFound {
|
||||
t.Fatalf("expected 404 status, got %d", rec.Code)
|
||||
}
|
||||
body := rec.Body.String()
|
||||
if !strings.Contains(body, "Paste ID not found") {
|
||||
t.Fatalf("expected friendly message in body, got: %.200s", body)
|
||||
}
|
||||
if !strings.Contains(body, "<nav>") {
|
||||
t.Fatalf("expected main UI chrome in body")
|
||||
}
|
||||
if strings.Contains(body, "404 page not found") {
|
||||
t.Fatalf("body still contains bare Go 404 text")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user