Files
mailgoserver/internal/webui/vendor_static_test.go
T

37 lines
1.1 KiB
Go
Raw Normal View History

package webui
import (
"net/http"
"net/http/httptest"
"testing"
)
// TestVendoredAssetsServedUnderBothPrefixes confirms Bootstrap/Bootstrap
// Icons/Quill are served locally (no CDN dependency) under both the admin and
// webmail static routes — templates in each tree reference their own prefix.
func TestVendoredAssetsServedUnderBothPrefixes(t *testing.T) {
app := newTestApp(t)
mux := app.Mux()
paths := []string{
Prefix + "/static/vendor/bootstrap/css/bootstrap.min.css",
Prefix + "/static/vendor/bootstrap/js/bootstrap.bundle.min.js",
Prefix + "/static/vendor/bootstrap-icons/font/bootstrap-icons.css",
Prefix + "/static/vendor/bootstrap-icons/font/fonts/bootstrap-icons.woff2",
MailboxPrefix + "/static/vendor/bootstrap/css/bootstrap.min.css",
MailboxPrefix + "/static/vendor/quill/quill.js",
MailboxPrefix + "/static/vendor/quill/quill.snow.css",
}
for _, p := range paths {
req := httptest.NewRequest(http.MethodGet, p, nil)
rec := httptest.NewRecorder()
mux.ServeHTTP(rec, req)
if rec.Code != http.StatusOK {
t.Errorf("%s: status=%d", p, rec.Code)
}
if rec.Body.Len() == 0 {
t.Errorf("%s: empty body", p)
}
}
}