From ff3cbce1e9c047a2372b94669c5e3634cbe766cb Mon Sep 17 00:00:00 2001 From: Sam Dornan Date: Fri, 18 Sep 2026 01:03:27 +0000 Subject: [PATCH] test(frontend): cover the dev server's CSS prefixing Nothing exercised the dev CSS path: CI's e2e run serves a production build, and vitest.config.ts never loads vite.config.js, so dropping `css.transformer` would leave every check green while Safari below 18.4 lost its blur again. Drives the real config through Vite's programmatic server and asserts both the standard and prefixed properties. Removing the transformer fails it. Also trims the comment above the setting to the two lines the repo allows. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01BEtFQ17BQDS52wXosTjcUU --- frontend/test/devCssPrefixing.test.ts | 30 +++++++++++++++++++++++++ frontend/test/fixtures/prefix-probe.css | 5 +++++ frontend/vite.config.js | 9 ++------ 3 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 frontend/test/devCssPrefixing.test.ts create mode 100644 frontend/test/fixtures/prefix-probe.css diff --git a/frontend/test/devCssPrefixing.test.ts b/frontend/test/devCssPrefixing.test.ts new file mode 100644 index 000000000..afc7e1dc5 --- /dev/null +++ b/frontend/test/devCssPrefixing.test.ts @@ -0,0 +1,30 @@ +import path from "node:path"; +import { createServer, type ViteDevServer } from "vite"; +import { afterAll, beforeAll, describe, expect, it } from "vitest"; + +// The dev server is the only place this is observable: CI's e2e run serves a +// production build, and vitest.config.ts never loads vite.config.js, so a +// dropped `css.transformer` would leave every other check green. +describe("dev server CSS", () => { + let server: ViteDevServer; + + beforeAll(async () => { + server = await createServer({ + configFile: path.resolve(process.cwd(), "vite.config.js"), + server: { middlewareMode: true }, + logLevel: "error", + }); + }, 60_000); + + afterAll(async () => { + await server?.close(); + }); + + it("generates vendor prefixes, not only on the build's minify path", async () => { + const result = await server.transformRequest( + "/test/fixtures/prefix-probe.css", + ); + expect(result?.code).toMatch(/-webkit-backdrop-filter:\s*blur\(1px\)/); + expect(result?.code).toMatch(/[^-]backdrop-filter:\s*blur\(1px\)/); + }); +}); diff --git a/frontend/test/fixtures/prefix-probe.css b/frontend/test/fixtures/prefix-probe.css new file mode 100644 index 000000000..c68eb67ad --- /dev/null +++ b/frontend/test/fixtures/prefix-probe.css @@ -0,0 +1,5 @@ +/* Probed by test/devCssPrefixing.test.ts. `backdrop-filter` needs a + `-webkit-` prefix below Safari 18.4, and the build targets cover it. */ +.prefix-probe { + backdrop-filter: blur(1px); +} diff --git a/frontend/vite.config.js b/frontend/vite.config.js index fe971f7d3..6d36eb58c 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -113,13 +113,8 @@ export default defineConfig(({ mode }) => { hosts: ["localhost", "127.0.0.1", "romm.dev"], }), ], - // Lightning CSS transforms dev and build alike, so the vendor prefixes it - // generates from Vite's baseline targets reach the dev server too. With - // Vite's default postcss transformer they only appear on the build's - // minify path, and Safari below 18.4 loses every backdrop-filter surface - // while developing. Never hand-write a `-webkit-` twin to paper over that: - // Lightning CSS keeps only the last of the pair, dropping the standard - // property from the bundle. + // Prefixes dev too, not just the build's minify path. Never hand-write a + // `-webkit-` twin: Lightning CSS keeps only the last of the pair. css: { transformer: "lightningcss", },