Skip to content

Commit 41e9e70

Browse files
test(release): cover main-only release gate and preview-only prerelease shape
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
1 parent 8e3d58c commit 41e9e70

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

tests/release-helper.test.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ describe("release helper", () => {
247247
expect(findCallIndex(calls, "git", call => call.args[0] === "push")).toBe(-1);
248248
});
249249

250-
test("preview branch still defaults to preview tag and dry-run dispatch", () => {
251-
const { calls, result } = runRelease("9.9.9-preview.1", { branch: "preview" });
250+
test("a prerelease on main defaults to preview tag and dry-run dispatch", () => {
251+
const { calls, result } = runRelease("9.9.9-preview.1");
252252

253253
expect(result.status).toBe(0);
254254
expect(findCallIndex(calls, "gh", call =>
@@ -260,6 +260,27 @@ describe("release helper", () => {
260260
)).toBeGreaterThanOrEqual(0);
261261
});
262262

263+
// release.yml only accepts refs/heads/main, so the helper must refuse anything else
264+
// instead of dispatching a run the workflow will reject.
265+
test("releasing from a branch other than main aborts before the bump", () => {
266+
const { calls, result } = runRelease("9.9.9-preview.1", { branch: "preview" });
267+
268+
expect(result.status).not.toBe(0);
269+
expect(result.stderr + result.stdout).toContain("must be on main");
270+
expect(findCallIndex(calls, "npm", call => call.args[0] === "version")).toBe(-1);
271+
expect(findCallIndex(calls, "gh", call => call.args[0] === "workflow" && call.args[1] === "run")).toBe(-1);
272+
});
273+
274+
// The update client only parses X.Y.Z-preview.N, so any other prerelease shape would
275+
// publish to the preview dist-tag and then never be seen as an available update.
276+
test("prerelease versions outside X.Y.Z-preview.N abort before the bump", () => {
277+
const { calls, result } = runRelease("9.9.9-alpha.1");
278+
279+
expect(result.status).not.toBe(0);
280+
expect(result.stderr + result.stdout).toContain("must be X.Y.Z-preview.N");
281+
expect(findCallIndex(calls, "npm", call => call.args[0] === "version")).toBe(-1);
282+
});
283+
263284
test("dispatch pins the audited release SHA via expected-sha", () => {
264285
const { calls, result } = runRelease("9.9.9", { headSha: "deadbeefcafe1234" });
265286

0 commit comments

Comments
 (0)