diff --git a/tests/unit/pnpm-install-policy.test.ts b/tests/unit/pnpm-install-policy.test.ts new file mode 100644 index 00000000..ee45d517 --- /dev/null +++ b/tests/unit/pnpm-install-policy.test.ts @@ -0,0 +1,37 @@ +import { readFile } from "node:fs/promises"; + +import { describe, expect, it } from "vitest"; + +/** + * 0929/13-08. pnpm 11 reads its install policy from pnpm-workspace.yaml + * (13-09 moved it out of .npmrc, which pnpm 11 ignores). Nothing failed when a + * key was dropped or the release-age delay was shortened, so an unsupported + * Node version could install again, a new dependency could be saved with a ^ + * range, or a version published minutes ago could be installed. + */ +const PNPM_DEFAULT_MINIMUM_RELEASE_AGE_MINUTES = 1_440; + +describe("pnpm install policy (0929/13-08)", () => { + it("keeps engineStrict, exact saves and at least the default release-age delay", async () => { + const workspace = await readFile("pnpm-workspace.yaml", "utf8"); + const setting = (key: string) => + new RegExp(`^${key}:\\s*(\\S+)\\s*$`, "mu").exec(workspace)?.[1]; + + expect(setting("engineStrict")).toBe("true"); + expect(setting("saveExact")).toBe("true"); + const minimumReleaseAge = setting("minimumReleaseAge"); + if (minimumReleaseAge !== undefined) { + expect(Number(minimumReleaseAge)).toBeGreaterThanOrEqual(PNPM_DEFAULT_MINIMUM_RELEASE_AGE_MINUTES); + } + }); + + it("excludes only exact versions from the release-age delay", async () => { + const workspace = await readFile("pnpm-workspace.yaml", "utf8"); + const block = /^minimumReleaseAgeExclude:\n((?:\s+-\s+.+\n?)*)/mu.exec(workspace)?.[1] ?? ""; + const entries = block + .split("\n") + .map((line) => line.replace(/^\s+-\s+/u, "").replaceAll("'", "").trim()) + .filter(Boolean); + for (const entry of entries) expect(entry).toMatch(/^(?:@[^/@]+\/)?[^/@]+@\d+\.\d+\.\d+$/u); + }); +});