fix(web): манифест PWA отдаётся с правильным типом
Go определяет .webmanifest как text/plain, из-за чего браузер мог отказаться ставить приложение: тип задаём явно вместе с js/css/svg.
This commit is contained in:
@@ -785,3 +785,22 @@ func guildChannelID(t *testing.T, srv *Server, guildID string, cookie *http.Cook
|
||||
t.Fatal("текстовая комната не найдена")
|
||||
return ""
|
||||
}
|
||||
|
||||
func TestStaticServesPWAAssets(t *testing.T) {
|
||||
srv, _ := newTestServer(t)
|
||||
// В тестовом каталоге лежит только index.html: проверяем типы по расширению.
|
||||
cases := map[string]string{
|
||||
"/manifest.webmanifest": "application/manifest+json",
|
||||
"/sw.js": "text/javascript; charset=utf-8",
|
||||
"/offline.html": "text/html; charset=utf-8",
|
||||
}
|
||||
for path, want := range cases {
|
||||
rec := doJSON(t, srv, http.MethodGet, path, "")
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("%s = %d", path, rec.Code)
|
||||
}
|
||||
if got := rec.Header().Get("Content-Type"); got != want {
|
||||
t.Fatalf("%s: Content-Type = %q, ожидался %q", path, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user