refactor(viewer): consolidate rendering and harden uploads
This commit is contained in:
@@ -101,3 +101,24 @@ func TestStaticJSUsesScriptContentType(t *testing.T) {
|
||||
t.Fatalf("expected static JS asset body to be served")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStandaloneHandlerAssetsAndFormWorkUnderPathPrefix(t *testing.T) {
|
||||
outer := http.NewServeMux()
|
||||
outer.Handle("/chart/", http.StripPrefix("/chart", NewStandaloneHandler(HandlerOptions{Title: "Reanimator Chart"})))
|
||||
|
||||
pageRec := httptest.NewRecorder()
|
||||
outer.ServeHTTP(pageRec, httptest.NewRequest(http.MethodGet, "/chart/", nil))
|
||||
if pageRec.Code != http.StatusOK {
|
||||
t.Fatalf("page status = %d, want %d", pageRec.Code, http.StatusOK)
|
||||
}
|
||||
body := pageRec.Body.String()
|
||||
if !strings.Contains(body, `href="static/view.css"`) || !strings.Contains(body, `action="render"`) {
|
||||
t.Fatalf("prefixed page contains root-absolute internal URLs: %s", body)
|
||||
}
|
||||
|
||||
staticRec := httptest.NewRecorder()
|
||||
outer.ServeHTTP(staticRec, httptest.NewRequest(http.MethodGet, "/chart/static/view.js", nil))
|
||||
if staticRec.Code != http.StatusOK {
|
||||
t.Fatalf("static asset status = %d, want %d", staticRec.Code, http.StatusOK)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user