-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: resolve process.env variables in global environment level #7600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bijin-bruno
merged 4 commits into
usebruno:main
from
abhishek-bruno:fix/global-env-process-env-resolution
Apr 4, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3d26362
feat: enhance environment variable resolution in EnvironmentVariables…
abhishek-bruno 7e9d049
refactor: improve state selection and add test IDs for better testing
abhishek-bruno e6aa1e8
feat: add test IDs to EnvironmentList for improved testability
abhishek-bruno f834aa2
refactor: simplify global environment test setup
abhishek-bruno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
tests/environments/global-env-process-env-resolution/fixtures/collection/bruno.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "version": "1", | ||
| "name": "process-env-global-test", | ||
| "type": "collection" | ||
| } |
17 changes: 17 additions & 0 deletions
17
tests/environments/global-env-process-env-resolution/fixtures/collection/echo-post.bru
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| meta { | ||
| name: echo-post | ||
| type: http | ||
| seq: 1 | ||
| } | ||
|
|
||
| post { | ||
| url: https://echo.usebruno.com | ||
| body: json | ||
| auth: none | ||
| } | ||
|
|
||
| body:json { | ||
| { | ||
| "value": "{{testVar}}" | ||
| } | ||
| } |
63 changes: 63 additions & 0 deletions
63
.../environments/global-env-process-env-resolution/global-env-process-env-resolution.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { test, expect } from '../../../playwright'; | ||
| import { | ||
| openCollection, | ||
| openEnvironmentSelector, | ||
| openRequest, | ||
| sendRequest, | ||
| expectResponseContains | ||
| } from '../../utils/page'; | ||
|
|
||
| test.describe('Global Environment process.env Resolution', () => { | ||
| test('should resolve process.env variables referenced in global environment', async ({ | ||
| pageWithUserData: page | ||
| }) => { | ||
| await test.step('Open collection', async () => { | ||
| await openCollection(page, 'process-env-global-test'); | ||
| }); | ||
|
|
||
| await test.step('Create .env file with variable via UI', async () => { | ||
| // Open global environment configuration | ||
| await openEnvironmentSelector(page, 'global'); | ||
| await page.getByTestId('configure-env').click(); | ||
|
|
||
| // Expand the .env Files section | ||
| const dotEnvSection = page.getByTestId('dotenv-files-section'); | ||
| await dotEnvSection.waitFor({ state: 'visible' }); | ||
| await dotEnvSection.click(); | ||
|
|
||
| // Click + to create a new .env file | ||
| await page.getByTestId('create-dotenv-file').click(); | ||
|
|
||
| // Accept the default name (.env) and press Enter | ||
| await page.getByTestId('dotenv-name-input').press('Enter'); | ||
| await expect(page.getByText('.env file created!')).toBeVisible(); | ||
|
|
||
| // Switch to Raw mode to type the variable | ||
| await page.getByTestId('dotenv-view-raw').click(); | ||
|
|
||
| // Type the variable into the raw editor | ||
| const rawEditor = page.getByTestId('dotenv-raw-editor').locator('.CodeMirror'); | ||
| await rawEditor.click(); | ||
| await page.keyboard.type('MY_SECRET=hello-from-dotenv'); | ||
|
|
||
| // Save the .env file | ||
| await page.getByTestId('save-dotenv-raw').click(); | ||
| }); | ||
|
|
||
| await test.step('Verify global environment is active', async () => { | ||
| await expect(page.locator('.current-environment')).toContainText('ProcessEnv Test'); | ||
| }); | ||
|
|
||
| await test.step('Open request', async () => { | ||
| await openRequest(page, 'process-env-global-test', 'echo-post'); | ||
| }); | ||
|
|
||
| await test.step('Send request and verify process.env resolved', async () => { | ||
| await sendRequest(page, 200); | ||
| }); | ||
|
|
||
| await test.step('Verify response contains resolved value from .env file', async () => { | ||
| await expectResponseContains(page, ['hello-from-dotenv']); | ||
| }); | ||
| }); | ||
| }); |
10 changes: 10 additions & 0 deletions
10
tests/environments/global-env-process-env-resolution/init-user-data/collection-security.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "collections": [ | ||
| { | ||
| "path": "{{collectionPath}}", | ||
| "securityConfig": { | ||
| "jsSandboxMode": "safe" | ||
| } | ||
| } | ||
| ] | ||
| } |
19 changes: 19 additions & 0 deletions
19
tests/environments/global-env-process-env-resolution/init-user-data/global-environments.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "environments": [ | ||
| { | ||
| "uid": "pEnvTestGlobalEnvUi01", | ||
| "name": "ProcessEnv Test", | ||
| "variables": [ | ||
| { | ||
| "uid": "pEnvTestVarUid0000001", | ||
| "name": "testVar", | ||
| "value": "{{process.env.MY_SECRET}}", | ||
| "type": "text", | ||
| "secret": false, | ||
| "enabled": true | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "activeGlobalEnvironmentUid": "pEnvTestGlobalEnvUi01" | ||
| } |
12 changes: 12 additions & 0 deletions
12
tests/environments/global-env-process-env-resolution/init-user-data/preferences.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "maximized": false, | ||
| "lastOpenedCollections": [ | ||
| "{{collectionPath}}" | ||
| ], | ||
| "preferences": { | ||
| "onboarding": { | ||
| "hasLaunchedBefore": true, | ||
| "hasSeenWelcomeModal": true | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.