Skip to content

Commit d67b5ba

Browse files
committed
Narrow down supported HMR cases
1 parent b48426a commit d67b5ba

File tree

1 file changed

+45
-28
lines changed

1 file changed

+45
-28
lines changed

integration/vite-css-test.ts

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -548,35 +548,52 @@ async function hmrWorkflow({
548548
"NEW_PADDING_INJECTED_VIA_POSTCSS",
549549
);
550550

551-
await Promise.all([
552-
edit(`app/routes/${routeBase}/styles-bundled.css`, modifyCss),
553-
edit(`app/routes/${routeBase}/styles.module.css`, modifyCss),
554-
edit(`app/routes/${routeBase}/styles-vanilla-global.css.ts`, modifyCss),
555-
edit(`app/routes/${routeBase}/styles-vanilla-local.css.ts`, modifyCss),
556-
edit(`app/routes/${routeBase}/styles-postcss-linked.css`, modifyCss),
557-
]);
558-
559-
await Promise.all(
560-
[
561-
"#css-bundled",
562-
"#css-modules",
563-
...(!templateName.includes("rsc")
564-
? // TODO: Fix these in RSC Framework Mode
565-
["#css-postcss-linked", "#css-vanilla-global", "#css-vanilla-local"]
566-
: []),
567-
].map(
568-
async (selector) =>
569-
await expect(page.locator(selector)).toHaveCSS(
570-
"padding",
571-
NEW_PADDING,
572-
),
573-
),
574-
);
551+
const testCases = [
552+
{ file: "styles-bundled.css", selector: "#css-bundled" },
553+
// TODO: Fix HMR for CSS Modules in server-first routes in RSC Framework mode
554+
...(routeBase === "rsc-server-first-route"
555+
? []
556+
: [{ file: "styles.module.css", selector: "#css-modules" }]),
557+
// TODO: Fix HMR for `?url` CSS imports in RSC Framework mode: https://github.com/vitejs/vite-plugin-react/issues/772
558+
// Once fixed, check if this also fixes HMR for Vanilla Extract
559+
...(templateName.includes("rsc")
560+
? []
561+
: [
562+
{
563+
file: "styles-postcss-linked.css",
564+
selector: "#css-postcss-linked",
565+
},
566+
{
567+
file: "styles-vanilla-global.css.ts",
568+
selector: "#css-vanilla-global",
569+
},
570+
{
571+
file: "styles-vanilla-local.css.ts",
572+
selector: "#css-vanilla-local",
573+
},
574+
]),
575+
] as const satisfies Array<{
576+
file: string;
577+
selector: string;
578+
}>;
579+
580+
for (const { file, selector } of testCases) {
581+
const routeFile = `app/routes/${routeBase}/${file}`;
582+
await edit(routeFile, modifyCss);
583+
await expect(
584+
page.locator(selector),
585+
`CSS update for ${routeFile}`,
586+
).toHaveCSS("padding", NEW_PADDING);
587+
588+
// TODO: Fix state preservation when changing CSS Modules in RSC Framework mode
589+
if (templateName.includes("rsc") && file === "styles.module.css") {
590+
continue;
591+
}
575592

576-
// Ensure CSS updates were handled by HMR
577-
// TODO: Fix state preservation in RSC Framework mode
578-
if (!templateName.includes("rsc")) {
579-
await expect(input).toHaveValue("stateful");
593+
// Ensure CSS updates were handled by HMR
594+
await expect(input, `State preservation for ${routeFile}`).toHaveValue(
595+
"stateful",
596+
);
580597
}
581598

582599
// RSC Framework mode doesn't support custom entries yet

0 commit comments

Comments
 (0)