Merge remote-tracking branch 'origin/master' into gitea/feature/end
Resolved conflicts taking origin/master (v0.5.55) as canonical, with local features re-applied: - runtime log level (LOG_LEVEL env + dashboard Settings → Logging, applied immediately and persisted across restarts) - free/noAuth provider enable/disable toggle via providerStrategies.enabled - parallel model testing (Test All Models / Test Selected Keys)
This commit is contained in:
66
tests/unit/standalone-assets.test.js
Normal file
66
tests/unit/standalone-assets.test.js
Normal file
@@ -0,0 +1,66 @@
|
||||
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { mkdtempSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { copyStandaloneAssets } from "../../scripts/copy-standalone-assets.mjs";
|
||||
|
||||
function createBuildFixture(distDir) {
|
||||
const projectRoot = mkdtempSync(join(tmpdir(), "9router-standalone-assets-"));
|
||||
const buildRoot = join(projectRoot, distDir);
|
||||
mkdirSync(join(buildRoot, "standalone"), { recursive: true });
|
||||
mkdirSync(join(buildRoot, "static", "chunks"), { recursive: true });
|
||||
mkdirSync(join(projectRoot, "public"), { recursive: true });
|
||||
writeFileSync(join(buildRoot, "static", "chunks", "app.js"), "static asset");
|
||||
writeFileSync(join(projectRoot, "public", "favicon.svg"), "public asset");
|
||||
return projectRoot;
|
||||
}
|
||||
|
||||
describe("standalone build assets", () => {
|
||||
it("copies static and public assets into the default standalone layout", () => {
|
||||
const projectRoot = createBuildFixture(".next");
|
||||
|
||||
copyStandaloneAssets({ projectRoot, distDir: ".next" });
|
||||
|
||||
expect(readFileSync(join(projectRoot, ".next", "standalone", ".next", "static", "chunks", "app.js"), "utf8"))
|
||||
.toBe("static asset");
|
||||
expect(readFileSync(join(projectRoot, ".next", "standalone", "public", "favicon.svg"), "utf8"))
|
||||
.toBe("public asset");
|
||||
});
|
||||
|
||||
it("uses a custom Next dist directory", () => {
|
||||
const projectRoot = createBuildFixture(".next-cli-build");
|
||||
|
||||
copyStandaloneAssets({ projectRoot, distDir: ".next-cli-build" });
|
||||
|
||||
expect(readFileSync(join(projectRoot, ".next-cli-build", "standalone", ".next-cli-build", "static", "chunks", "app.js"), "utf8"))
|
||||
.toBe("static asset");
|
||||
});
|
||||
|
||||
// Without the wrapper beside server.js nothing can prove a request is local.
|
||||
it("copies the request-sanitizing server wrapper into the standalone output", () => {
|
||||
const projectRoot = createBuildFixture(".next");
|
||||
writeFileSync(join(projectRoot, "custom-server.js"), "wrapper");
|
||||
|
||||
copyStandaloneAssets({ projectRoot, distDir: ".next" });
|
||||
|
||||
expect(readFileSync(join(projectRoot, ".next", "standalone", "custom-server.js"), "utf8"))
|
||||
.toBe("wrapper");
|
||||
});
|
||||
|
||||
it("does not modify workspace-traced CLI builds", () => {
|
||||
const projectRoot = createBuildFixture(".next-cli-build");
|
||||
const previousMode = process.env.NEXT_TRACING_ROOT_MODE;
|
||||
process.env.NEXT_TRACING_ROOT_MODE = "workspace";
|
||||
|
||||
try {
|
||||
copyStandaloneAssets({ projectRoot, distDir: ".next-cli-build" });
|
||||
} finally {
|
||||
if (previousMode === undefined) delete process.env.NEXT_TRACING_ROOT_MODE;
|
||||
else process.env.NEXT_TRACING_ROOT_MODE = previousMode;
|
||||
}
|
||||
|
||||
expect(() => readFileSync(join(projectRoot, ".next-cli-build", "standalone", ".next-cli-build", "static", "chunks", "app.js")))
|
||||
.toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user