From d17b99793cf0b968359c51624ce7768361fc98b0 Mon Sep 17 00:00:00 2001 From: James Opstad <13586373+jamesopstad@users.noreply.github.com> Date: Tue, 23 Dec 2025 11:42:35 +0000 Subject: [PATCH] Reintroduce CSS tests for Vite 8 --- .../assets/__tests__/assets.spec.ts | 38 +++++++------ .../playground/assets/__tests__/base-tests.ts | 54 +++++++++---------- .../__tests__/no-client-entry/assets.spec.ts | 32 +++++------ 3 files changed, 56 insertions(+), 68 deletions(-) diff --git a/packages/vite-plugin-cloudflare/playground/assets/__tests__/assets.spec.ts b/packages/vite-plugin-cloudflare/playground/assets/__tests__/assets.spec.ts index 02632953d0..f8088a9bc6 100644 --- a/packages/vite-plugin-cloudflare/playground/assets/__tests__/assets.spec.ts +++ b/packages/vite-plugin-cloudflare/playground/assets/__tests__/assets.spec.ts @@ -1,25 +1,23 @@ -import { describe, expect, test } from "vitest"; -import { getResponse, isVite8, page, viteTestUrl } from "../../__test-utils__"; +import { expect, test } from "vitest"; +import { getResponse, page, viteTestUrl } from "../../__test-utils__"; import "./base-tests"; -describe.skipIf(isVite8)("Assets", () => { - test("fetches transformed HTML asset", async () => { - await page.goto(`${viteTestUrl}/transformed-html-asset`); - const content = await page.textContent("h1"); - expect(content).toBe("Modified content"); - }); +test("fetches transformed HTML asset", async () => { + await page.goto(`${viteTestUrl}/transformed-html-asset`); + const content = await page.textContent("h1"); + expect(content).toBe("Modified content"); +}); - test("fetches original public directory asset if requested directly", async () => { - const response = await getResponse("/public-image.svg"); - const contentType = await response.headerValue("content-type"); - const additionalHeader = await response.headerValue("additional-header"); - expect(contentType).toBe("image/svg+xml"); - expect(additionalHeader).toBe(null); - }); +test("fetches original public directory asset if requested directly", async () => { + const response = await getResponse("/public-image.svg"); + const contentType = await response.headerValue("content-type"); + const additionalHeader = await response.headerValue("additional-header"); + expect(contentType).toBe("image/svg+xml"); + expect(additionalHeader).toBe(null); +}); - test("fetches original HTML asset if requested directly", async () => { - await page.goto(`${viteTestUrl}/html-page`); - const content = await page.textContent("h1"); - expect(content).toBe("Original content"); - }); +test("fetches original HTML asset if requested directly", async () => { + await page.goto(`${viteTestUrl}/html-page`); + const content = await page.textContent("h1"); + expect(content).toBe("Original content"); }); diff --git a/packages/vite-plugin-cloudflare/playground/assets/__tests__/base-tests.ts b/packages/vite-plugin-cloudflare/playground/assets/__tests__/base-tests.ts index 3eb09819b0..570f8950ce 100644 --- a/packages/vite-plugin-cloudflare/playground/assets/__tests__/base-tests.ts +++ b/packages/vite-plugin-cloudflare/playground/assets/__tests__/base-tests.ts @@ -1,33 +1,31 @@ -import { describe, expect, test } from "vitest"; -import { getResponse, getTextResponse, isVite8 } from "../../__test-utils__"; +import { expect, test } from "vitest"; +import { getResponse, getTextResponse } from "../../__test-utils__"; -describe.skipIf(isVite8)("Base tests", () => { - test("fetches public directory asset", async () => { - const response = await getResponse("/public-directory-asset"); - const contentType = await response.headerValue("content-type"); - const additionalHeader = await response.headerValue("additional-header"); - expect(contentType).toBe("image/svg+xml"); - expect(additionalHeader).toBe("public-directory-asset"); - }); +test("fetches public directory asset", async () => { + const response = await getResponse("/public-directory-asset"); + const contentType = await response.headerValue("content-type"); + const additionalHeader = await response.headerValue("additional-header"); + expect(contentType).toBe("image/svg+xml"); + expect(additionalHeader).toBe("public-directory-asset"); +}); - test("fetches imported asset", async () => { - const response = await getResponse("/imported-asset"); - const contentType = await response.headerValue("content-type"); - const additionalHeader = await response.headerValue("additional-header"); - expect(contentType).toBe("image/svg+xml"); - expect(additionalHeader).toBe("imported-asset"); - }); +test("fetches imported asset", async () => { + const response = await getResponse("/imported-asset"); + const contentType = await response.headerValue("content-type"); + const additionalHeader = await response.headerValue("additional-header"); + expect(contentType).toBe("image/svg+xml"); + expect(additionalHeader).toBe("imported-asset"); +}); - test("fetches imported asset with url suffix", async () => { - const text = await getTextResponse("/imported-asset-url-suffix"); - expect(text).toBe(`The text content is "Text content"`); - }); +test("fetches imported asset with url suffix", async () => { + const text = await getTextResponse("/imported-asset-url-suffix"); + expect(text).toBe(`The text content is "Text content"`); +}); - test("fetches inline asset", async () => { - const response = await getResponse("/inline-asset"); - const contentType = await response.headerValue("content-type"); - const additionalHeader = await response.headerValue("additional-header"); - expect(contentType).toBe("image/svg+xml"); - expect(additionalHeader).toBe("inline-asset"); - }); +test("fetches inline asset", async () => { + const response = await getResponse("/inline-asset"); + const contentType = await response.headerValue("content-type"); + const additionalHeader = await response.headerValue("additional-header"); + expect(contentType).toBe("image/svg+xml"); + expect(additionalHeader).toBe("inline-asset"); }); diff --git a/packages/vite-plugin-cloudflare/playground/assets/__tests__/no-client-entry/assets.spec.ts b/packages/vite-plugin-cloudflare/playground/assets/__tests__/no-client-entry/assets.spec.ts index 13dc046e0b..9a460e8d0c 100644 --- a/packages/vite-plugin-cloudflare/playground/assets/__tests__/no-client-entry/assets.spec.ts +++ b/packages/vite-plugin-cloudflare/playground/assets/__tests__/no-client-entry/assets.spec.ts @@ -1,26 +1,18 @@ import * as fs from "node:fs"; import * as path from "node:path"; import { expect, test, vi } from "vitest"; -import { - isBuild, - isVite8, - testDir, - WAIT_FOR_OPTIONS, -} from "../../../__test-utils__"; +import { isBuild, testDir, WAIT_FOR_OPTIONS } from "../../../__test-utils__"; import "../base-tests"; -test.runIf(isBuild && !isVite8)( - "deletes fallback client entry file", - async () => { - const fallbackEntryPath = path.join( - testDir, - "dist", - "client", - "__cloudflare_fallback_entry__" - ); +test.runIf(isBuild)("deletes fallback client entry file", async () => { + const fallbackEntryPath = path.join( + testDir, + "dist", + "client", + "__cloudflare_fallback_entry__" + ); - await vi.waitFor(() => { - expect(fs.existsSync(fallbackEntryPath)).toBe(false); - }, WAIT_FOR_OPTIONS); - } -); + await vi.waitFor(() => { + expect(fs.existsSync(fallbackEntryPath)).toBe(false); + }, WAIT_FOR_OPTIONS); +});