fix(viewer): serve static js with script mime type

This commit is contained in:
2026-04-22 21:40:40 +03:00
parent f6517987b3
commit 39a6f128f1
3 changed files with 27 additions and 1 deletions

View File

@@ -82,3 +82,22 @@ func TestStandaloneHandlerRootShowsUploadForm(t *testing.T) {
t.Fatalf("expected standalone handler root to include upload form")
}
}
func TestStaticJSUsesScriptContentType(t *testing.T) {
handler := NewHandler(HandlerOptions{Title: "Reanimator Chart"})
req := httptest.NewRequest(http.MethodGet, "/static/view.js", nil)
rec := httptest.NewRecorder()
handler.ServeHTTP(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("status = %d, want %d", rec.Code, http.StatusOK)
}
contentType := rec.Header().Get("Content-Type")
if !strings.Contains(contentType, "javascript") {
t.Fatalf("Content-Type = %q, want javascript MIME type", contentType)
}
if !strings.Contains(rec.Body.String(), "DOMContentLoaded") {
t.Fatalf("expected static JS asset body to be served")
}
}