package handlers

import (
	"net/http"
	"net/http/httptest"
	"testing"
)

// t-paliad-177 Slice 2 — visibility leak fix.
//
// The end-to-end "GET /chart returns 404 for invisible projects" check
// would need a mocked ProjectService + auth.Client; the handler package
// has no harness for that today (all existing _test.go files unit-test
// pure helpers). Until that harness exists, we pin the contract from
// the helper layer: serveChartNotFound writes a 404 + an HTML
// Content-Type. The dist/notfound.html lookup falls back to a plain
// 404 string in test environments without a built frontend, which is
// the documented degraded path.

func TestServeChartNotFound_Returns404HTML(t *testing.T) {
	w := httptest.NewRecorder()
	serveChartNotFound(w)
	if w.Code != http.StatusNotFound {
		t.Fatalf("status = %d, want %d", w.Code, http.StatusNotFound)
	}
	body := w.Body.String()
	if body == "" {
		t.Error("body is empty — should be either the notfound chrome or the plain-text fallback")
	}
}
