ReviewOS

also looking at this

stacks/buddy

test(pr-body): set the APP_ENV this file needs instead of inheriting it from another

#1455
Merged glennmichael123 wants to merge fix/pr-body-major-updates-app-env into main
1 file +25 -1

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

test/pr-body-major-updates.test.tsmodified+25-1
Changes to test/pr-body-major-updates.test.ts
@@ -1,10 +1,34 @@
11import type { UpdateGroup } from '../src/types'
2import { describe, expect, it } from 'bun:test'
2import { afterAll, beforeAll, describe, expect, it } from 'bun:test'
33import { PullRequestGenerator } from '../src/pr/pr-generator'
44
55describe('PR Body Generation for Major Updates', () => {
66 const generator = new PullRequestGenerator()
77
8 // `ReleaseNotesFetcher.fetchPackageInfo` returns fixed metadata when
9 // `APP_ENV` is `test`, which is how the assertions below get a github.com
10 // repository URL for stripe without touching the network.
11 //
12 // This file never set it. It passed only when one of the five other test
13 // files that assign `process.env.APP_ENV` happened to run first and leave it
14 // set in the shared process, so the result depended on file order: green
15 // locally, red in CI, where the run reached the wire and the preload's
16 // network guard blocked it. Set the precondition here, and restore it so
17 // this file does not do the leaking in turn.
18 let previousAppEnv: string | undefined
19
20 beforeAll(() => {
21 previousAppEnv = process.env.APP_ENV
22 process.env.APP_ENV = 'test'
23 })
24
25 afterAll(() => {
26 if (previousAppEnv === undefined)
27 delete process.env.APP_ENV
28 else
29 process.env.APP_ENV = previousAppEnv
30 })
31
832 describe('single major update issue reproduction', () => {
933 it('should generate complete PR body for major stripe update (original issue)', async () => {
1034 // This test reproduces the exact scenario from the user's issue