Skip to content

feat(converters): re-enable variable scripting translations#8388

Open
sanish-bruno wants to merge 1 commit into
usebruno:mainfrom
sanish-bruno:feat/enable-api-translations
Open

feat(converters): re-enable variable scripting translations#8388
sanish-bruno wants to merge 1 commit into
usebruno:mainfrom
sanish-bruno:feat/enable-api-translations

Conversation

@sanish-bruno

@sanish-bruno sanish-bruno commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Description

Re-enables Postman ↔ Bruno script translations that were previously commented out because the underlying runtime APIs would not propagate variable mutations to the UI tables. With variable persistence landing in #8315, these APIs now update both the request lifecycle and the UI, so the translations can be turned back on.

JIRA: BRU-3096

Important

Depends on #8315 — that PR must be merged first, otherwise the re-enabled translations will silently fail to update the UI.

Re-enabled translations

Postman API Bruno API
pm.globals.unset bru.deleteGlobalEnvVar
pm.globals.clear bru.deleteAllGlobalEnvVars
pm.collectionVariables.set bru.setCollectionVar
pm.collectionVariables.unset bru.deleteCollectionVar
pm.collectionVariables.clear bru.deleteAllCollectionVars
pm.collectionVariables.toObject bru.getAllCollectionVars

Applied in both directions and to both transformer paths:

  • packages/bruno-converters/src/utils/postman-to-bruno-translator.js (AST/jscodeshift)
  • packages/bruno-converters/src/postman/postman-translations.js (regex fallback)
  • packages/bruno-converters/src/utils/bruno-to-postman-translator.js (AST/jscodeshift)

Tests

  • Unskipped 13 it.skip / test.skip blocks across 8 spec files covering the collection-variable APIs.
  • Added 11 new tests for previously uncovered APIs (pm.globals.unset, pm.globals.clear, pm.collectionVariables.clear, pm.collectionVariables.toObject, and their bru.* reverse mappings).
  • npm run test --workspace=packages/bruno-converters → 71/71 suites pass, 1104 tests pass.

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • New Features

    • Expanded variable translation support for global and collection variables, including set, unset, clear, and export-to-object actions.
    • Enabled additional translation paths in both Postman-to-Bruno and Bruno-to-Postman flows.
  • Tests

    • Re-enabled and added coverage for previously skipped variable translation cases.
    • Added validation for multiline, nested, alias-based, and test-function scenarios.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Postman and Bruno variable translation tables now cover additional global and collection helper calls in both directions. Matching tests were re-enabled and expanded for direct assertions and transpiler scenarios.

Changes

Postman↔Bruno variable translations

Layer / File(s) Summary
Postman to Bruno mappings
packages/bruno-converters/src/postman/postman-translations.js, packages/bruno-converters/src/utils/postman-to-bruno-translator.js
Postman collection and global variable helper calls now map to Bruno helper calls in both translation tables.
Bruno to Postman mappings
packages/bruno-converters/src/utils/bruno-to-postman-translator.js
Bruno collection and global variable helper calls now map back to Postman helper calls again.
Bruno to Postman tests
packages/bruno-converters/tests/bruno/bruno-to-postman-translations/variables.test.js
Bruno-to-Postman variable tests run for global delete/clear and collection set, unset, get-all, and clear translations.
Postman to Bruno direct tests
packages/bruno-converters/tests/postman/postman-translations/postman-*.spec.js
Postman direct translation assertions now run for collection-variable set and global helper cases.
Postman to Bruno scenario tests
packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/*.test.js
Postman transpiler tests run for collection-variable set, unset, clear, toObject, aliases, multiline code, nested expressions, and test-function cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • usebruno/bruno#7052: Updates the same variable-translation mappings in postman-to-bruno-translator.js for Postman global and collection APIs.
  • usebruno/bruno#7069: Covers the same bidirectional Postman↔Bruno variable helper mappings and matching tests.

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

Variables crossed the bridge today,
From Postman scripts to Bruno’s way.
Set, unset, clear—now all align,
In tests that wake and run just fine.
A tiny map with a tidy glow ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: restoring variable scripting translations in the converters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sanish-bruno sanish-bruno changed the title feat(translations): restore commented-out collection and global varia… feat(converters): re-enable variable scripting translations Jun 26, 2026
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

…ble methods

- Reintroduced translations for `setCollectionVar`, `deleteCollectionVar`, `deleteAllCollectionVars`, and their global counterparts in the Postman to Bruno and Bruno to Postman translators.
- Updated tests to validate the translations for these methods, ensuring accurate functionality and consistency across variable management.
- Removed outdated comments regarding UI updates, reflecting the current state of the implementation.
@sanish-bruno sanish-bruno force-pushed the feat/enable-api-translations branch from 8bf8ff6 to 62ee62e Compare June 26, 2026 17:35

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/variables.test.js`:
- Around line 109-136: Add a regression test for the newly restored
pm.globals.toObject mapping in the variables translation suite. In
variables.test.js, extend the existing translateCode coverage alongside
pm.globals.unset, pm.globals.clear, and pm.collectionVariables.toObject to
assert that pm.globals.toObject() translates to bru.getAllGlobalEnvVars(). This
should exercise the postman-to-bruno-translator.js behavior so the restored
global toObject mapping stays covered.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0530a85f-18fb-47e9-a77e-636a8654d43d

📥 Commits

Reviewing files that changed from the base of the PR and between 87f7426 and 62ee62e.

📒 Files selected for processing (11)
  • packages/bruno-converters/src/postman/postman-translations.js
  • packages/bruno-converters/src/utils/bruno-to-postman-translator.js
  • packages/bruno-converters/src/utils/postman-to-bruno-translator.js
  • packages/bruno-converters/tests/bruno/bruno-to-postman-translations/variables.test.js
  • packages/bruno-converters/tests/postman/postman-translations/postman-comments.spec.js
  • packages/bruno-converters/tests/postman/postman-translations/postman-variables.spec.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/combined.test.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/multiline-syntax.test.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/response.test.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/testing-framework.test.js
  • packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/variables.test.js

Comment on lines +109 to +136
it('should translate pm.globals.unset', () => {
const code = 'pm.globals.unset("token");';
const translatedCode = translateCode(code);

expect(translatedCode).toBe('bru.deleteGlobalEnvVar("token");');
});

it('should translate pm.globals.clear', () => {
const code = 'pm.globals.clear();';
const translatedCode = translateCode(code);

expect(translatedCode).toBe('bru.deleteAllGlobalEnvVars();');
});

it('should translate pm.collectionVariables.clear', () => {
const code = 'pm.collectionVariables.clear();';
const translatedCode = translateCode(code);

expect(translatedCode).toBe('bru.deleteAllCollectionVars();');
});

it('should translate pm.collectionVariables.toObject', () => {
const code = 'const vars = pm.collectionVariables.toObject();';
const translatedCode = translateCode(code);

expect(translatedCode).toBe('const vars = bru.getAllCollectionVars();');
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the missing pm.globals.toObject regression test.

Line 15 in packages/bruno-converters/src/utils/postman-to-bruno-translator.js now restores pm.globals.toObject, but this new block only covers unset and clear for globals. That leaves one newly re-enabled mapping unguarded.

🧪 Suggested test
+  it('should translate pm.globals.toObject', () => {
+    const code = 'const globals = pm.globals.toObject();';
+    const translatedCode = translateCode(code);
+
+    expect(translatedCode).toBe('const globals = bru.getAllGlobalEnvVars();');
+  });

As per coding guidelines, "Add tests for any new functionality or meaningful changes. If code is added, removed, or significantly modified, corresponding tests should be updated or created."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it('should translate pm.globals.unset', () => {
const code = 'pm.globals.unset("token");';
const translatedCode = translateCode(code);
expect(translatedCode).toBe('bru.deleteGlobalEnvVar("token");');
});
it('should translate pm.globals.clear', () => {
const code = 'pm.globals.clear();';
const translatedCode = translateCode(code);
expect(translatedCode).toBe('bru.deleteAllGlobalEnvVars();');
});
it('should translate pm.collectionVariables.clear', () => {
const code = 'pm.collectionVariables.clear();';
const translatedCode = translateCode(code);
expect(translatedCode).toBe('bru.deleteAllCollectionVars();');
});
it('should translate pm.collectionVariables.toObject', () => {
const code = 'const vars = pm.collectionVariables.toObject();';
const translatedCode = translateCode(code);
expect(translatedCode).toBe('const vars = bru.getAllCollectionVars();');
});
it('should translate pm.globals.unset', () => {
const code = 'pm.globals.unset("token");';
const translatedCode = translateCode(code);
expect(translatedCode).toBe('bru.deleteGlobalEnvVar("token");');
});
it('should translate pm.globals.clear', () => {
const code = 'pm.globals.clear();';
const translatedCode = translateCode(code);
expect(translatedCode).toBe('bru.deleteAllGlobalEnvVars();');
});
it('should translate pm.globals.toObject', () => {
const code = 'const globals = pm.globals.toObject();';
const translatedCode = translateCode(code);
expect(translatedCode).toBe('const globals = bru.getAllGlobalEnvVars();');
});
it('should translate pm.collectionVariables.clear', () => {
const code = 'pm.collectionVariables.clear();';
const translatedCode = translateCode(code);
expect(translatedCode).toBe('bru.deleteAllCollectionVars();');
});
it('should translate pm.collectionVariables.toObject', () => {
const code = 'const vars = pm.collectionVariables.toObject();';
const translatedCode = translateCode(code);
expect(translatedCode).toBe('const vars = bru.getAllCollectionVars();');
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/bruno-converters/tests/postman/postman-translations/transpiler-tests/variables.test.js`
around lines 109 - 136, Add a regression test for the newly restored
pm.globals.toObject mapping in the variables translation suite. In
variables.test.js, extend the existing translateCode coverage alongside
pm.globals.unset, pm.globals.clear, and pm.collectionVariables.toObject to
assert that pm.globals.toObject() translates to bru.getAllGlobalEnvVars(). This
should exercise the postman-to-bruno-translator.js behavior so the restored
global toObject mapping stays covered.

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant