diff --git a/admin-ui/src/test/sw.test.ts b/admin-ui/src/test/sw.test.ts index 1bb4d2ca..1a4cd72f 100644 --- a/admin-ui/src/test/sw.test.ts +++ b/admin-ui/src/test/sw.test.ts @@ -43,6 +43,19 @@ describe('service worker', () => { expect(network).toHaveBeenCalledTimes(1); }); + it("fetches the connect and setup pages' stylesheet and scripts from the network even when cached", async () => { + for (const path of ['/assets/style.css', '/assets/theme-init.js']) { + const { network, request } = loadWorker({ [path]: 'stale' }); + await expect(request(path)).resolves.toMatchObject({ body: 'network' }); + expect(network).toHaveBeenCalledTimes(1); + } + }); + + it('serves fonts and icons from the cache first', async () => { + const { request } = loadWorker({ '/assets/fonts/figtree-variable.woff2': 'cached' }); + await expect(request('/assets/fonts/figtree-variable.woff2')).resolves.toBe('cached'); + }); + it('serves hashed console assets from the cache first', async () => { const { request } = loadWorker({ '/admin/assets/index-abc.js': 'cached' }); await expect(request('/admin/assets/index-abc.js')).resolves.toBe('cached'); diff --git a/internal/web/adminui/adminui.go b/internal/web/adminui/adminui.go index 87a8ba3b..e0eef357 100644 --- a/internal/web/adminui/adminui.go +++ b/internal/web/adminui/adminui.go @@ -58,17 +58,22 @@ func Handler(fsys fs.FS, csp string) http.Handler { } // notBuiltPage is what a source build without the console serves at /admin. It -// is self-contained: no inline style or script, so the strict CSP holds. +// wears the connect page's stylesheet (internal/web/assets) and has no inline style +// or script, so the strict CSP holds. const notBuiltPage = `
-This server was compiled without the admin console. Build it, then rebuild the server:
+This server was compiled without the admin console. Build it, then rebuild the server:
scripts/build-admin.sh go build ./cmd/audiosilo-
Release binaries and the Docker image include it.
+Release binaries and the Docker image include it.
+