Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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");
});
Original file line number Diff line number Diff line change
@@ -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");
});
Original file line number Diff line number Diff line change
@@ -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);
});
Loading