Skip to content

Commit 0676075

Browse files
committed
refactor(tests): move font-google-multiple to standalone fixture and improve assertions
Moves the font-google-multiple fixture from a nested location inside app-basic to a standalone fixture at tests/fixtures/font-google-multiple/. This prevents side effects for other tests that build the app-basic fixture. Updates the build test to remove misleading comments about reproducing #751. The overwrittenRanges.push() fix in fonts.ts is a defensive consistency improvement, not a fix for issue #751. - Removes the nested fixture from app-basic/app/font-google-multiple/ - Creates minimal standalone fixture with package.json and vite.config.ts - Updates test comments to clarify this tests general build validation - Removes incorrect claim about reproducing #751
1 parent 73858a1 commit 0676075

File tree

5 files changed

+32
-26
lines changed

5 files changed

+32
-26
lines changed

tests/fixtures/app-basic/app/font-google-multiple/globals.css

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/fixtures/app-basic/app/font-google-multiple/layout.tsx renamed to tests/fixtures/font-google-multiple/app/layout.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { Metadata } from "next";
22
import { Geist, Geist_Mono } from "next/font/google";
3-
import "./globals.css";
43

54
const geistSans = Geist({
65
variable: "--font-geist-sans",
@@ -13,8 +12,7 @@ const geistMono = Geist_Mono({
1312
});
1413

1514
export const metadata: Metadata = {
16-
title: "Create Next App",
17-
description: "Generated by create next app",
15+
title: "Font Google Multiple Test",
1816
};
1917

2018
export default function RootLayout({
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export default function FontGoogleMultiplePage() {
1+
export default function HomePage() {
22
return (
33
<main>
44
<h1>Font Google Multiple Test</h1>
5-
<p>This page tests multiple Google Fonts (Geist + Geist_Mono) in a layout.</p>
5+
<p>This page tests multiple Google Fonts (Geist + Geist_Mono).</p>
66
</main>
77
);
88
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig } from "vite";
2+
import vinext from "vinext";
3+
4+
export default defineConfig({
5+
plugins: [vinext({ appDir: import.meta.dirname })],
6+
});

tests/font-google-build.test.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import os from "node:os";
55
import { createBuilder } from "vite";
66
import vinext from "../packages/vinext/src/index.js";
77

8-
const APP_FIXTURE_DIR = path.resolve(import.meta.dirname, "./fixtures/app-basic");
8+
const APP_FIXTURE_DIR = path.resolve(import.meta.dirname, "./fixtures/font-google-multiple");
99

1010
/**
1111
* Build an App Router fixture's RSC/SSR/client bundles using the actual Vite
1212
* build pipeline (createBuilder + buildApp). This exercises the full build
13-
* pipeline where issue #751 occurs, not just the transform hook in isolation.
13+
* pipeline for font-google transforms.
1414
*/
1515
async function buildFontGoogleMultipleFixture(): Promise<string> {
1616
const outDir = await fs.mkdtemp(path.join(os.tmpdir(), "vinext-font-google-multiple-"));
@@ -35,28 +35,38 @@ async function buildFontGoogleMultipleFixture(): Promise<string> {
3535
});
3636
};
3737

38+
const nodeModulesLink = path.join(APP_FIXTURE_DIR, "node_modules");
39+
3840
try {
41+
// Symlink node_modules before building so imports work
42+
const projectNodeModules = path.resolve(import.meta.dirname, "../node_modules");
43+
await fs.symlink(projectNodeModules, nodeModulesLink);
44+
3945
const builder = await createBuilder({
4046
root: APP_FIXTURE_DIR,
4147
configFile: false,
42-
plugins: [vinext({ appDir: APP_FIXTURE_DIR, rscOutDir, ssrOutDir, clientOutDir })],
48+
plugins: [
49+
vinext({
50+
appDir: APP_FIXTURE_DIR,
51+
rscOutDir,
52+
ssrOutDir,
53+
clientOutDir,
54+
}),
55+
],
4356
logLevel: "silent",
4457
});
4558

46-
// This is where issue #751 occurs - during [1/5] analyze client references
4759
await builder.buildApp();
4860

49-
// Symlink node_modules for external imports
50-
const projectNodeModules = path.resolve(import.meta.dirname, "../node_modules");
51-
await fs.symlink(projectNodeModules, path.join(outDir, "node_modules"));
52-
53-
return path.join(outDir, "server", "index.js");
61+
return path.join(outDir, "server", "index.mjs");
5462
} finally {
5563
globalThis.fetch = originalFetch;
64+
// Cleanup symlink
65+
await fs.unlink(nodeModulesLink).catch(() => {});
5666
}
5767
}
5868

59-
describe("font-google build integration (issue #751)", () => {
69+
describe("font-google build integration", () => {
6070
let buildOutputPath: string;
6171
let outDir: string;
6272

@@ -68,13 +78,9 @@ describe("font-google build integration (issue #751)", () => {
6878
});
6979

7080
it("should build successfully with multiple Google fonts (Geist + Geist_Mono)", async () => {
71-
// This test reproduces issue #751:
72-
// Build fails during [1/5] analyze client references... with:
73-
// Error: Unexpected token in app/layout.tsx at 234..235
74-
//
75-
// The issue occurs when using multiple fonts with the same options pattern:
76-
// const geistSans = Geist({ variable: "--font-geist-sans", subsets: ["latin"] });
77-
// const geistMono = Geist_Mono({ variable: "--font-geist-mono", subsets: ["latin"] });
81+
// This test validates that the build pipeline can handle multiple
82+
// Google font imports without errors. It exercises the font transform
83+
// plugin during the full createBuilder + buildApp() flow.
7884
buildOutputPath = await buildFontGoogleMultipleFixture();
7985
outDir = path.dirname(path.dirname(buildOutputPath));
8086

0 commit comments

Comments
 (0)