Repository navigation
fix: send-request shortcut - #7853
Conversation
WalkthroughAdds Cmd/Ctrl+Enter “run” shortcuts to CodeEditor and MultiLineEditor, updates RequestTabPanel’s sendRequest handler to prevent default/stop propagation, and extends tests to verify default and remapped sendRequest keybindings across editor contexts. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tests/shortcuts/bound-actions.spec.ts (2)
1898-1901: Consider moving keybinding reset into anafterEach.If any assertion before the reset block fails, the remapped
sendRequest → Shift+Enterleaks into the next test. Subsequent customized tests re-remap so they self-heal, but any follow-up test added later that relies on the default binding could silently break. Atest.afterEach(ortest.step('reset keybindings', ...)) for this describe block would make it fail-safe.Also applies to: 1955-1958, 2008-2011
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/shortcuts/bound-actions.spec.ts` around lines 1898 - 1901, Move the keybinding reset logic out of individual tests and into a teardown so remapped bindings (like the custom sendRequest → Shift+Enter) can't leak; add a test.afterEach (or a test.step called in afterEach) for the describe block that calls openKeybindingsTab(page) and clicks the 'reset-all-keybindings-btn' test id to restore defaults, and remove the duplicated reset blocks currently inside tests (the occurrences around the existing openKeybindingsTab(...); await page.getByTestId('reset-all-keybindings-btn').click(...) blocks).
1862-1876: Use the existingremapKeybindinghelper to dedupe.The three customized Shift+Enter tests repeat the same 15-line remap dance (open tab → hover row → click edit → Backspace → press Shift+Enter → close prefs). There's already a
remapKeybindinghelper at line 95 that does exactly this, and thecustomized Alt+Z reopens last closed tabtest at line 830 uses it. Swapping to it would cut ~45 lines and keep the "happy path" noise down.♻️ Proposed fix (applied to the first customized block; same pattern for the other two)
- // Remap sendRequest to Shift+Enter - await openKeybindingsTab(page); - const row = page.getByTestId(`keybinding-row-sendRequest`); - await row.hover(); - await page.getByTestId(`keybinding-edit-sendRequest`).click(); - await expect(page.getByTestId(`keybinding-input-sendRequest`)).toBeVisible({ timeout: 2000 }); - - await page.keyboard.down('Backspace'); - - await page.keyboard.down('Shift'); - await page.keyboard.down('Enter'); - await page.keyboard.up('Enter'); - await page.keyboard.up('Shift'); - - await closePreferencesTab(page); + await remapKeybinding(page, 'sendRequest', async () => { + await page.keyboard.press('Shift+Enter'); + });Also applies to: 1910-1924, 1967-1981
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/shortcuts/bound-actions.spec.ts` around lines 1862 - 1876, Replace the repeated manual remap sequence with the existing helper remapKeybinding to dedupe; specifically, in the blocks that perform the openKeybindingsTab → hover on keybinding-row-sendRequest → click keybinding-edit-sendRequest → Backspace → press Shift+Enter → closePreferencesTab sequence, call remapKeybinding(page, 'sendRequest', 'Shift+Enter') (and the analogous calls for the other two tests) so the tests use the centralized remapKeybinding helper instead of duplicating the 15-line interaction sequence.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/shortcuts/bound-actions.spec.ts`:
- Around line 1898-1901: Move the keybinding reset logic out of individual tests
and into a teardown so remapped bindings (like the custom sendRequest →
Shift+Enter) can't leak; add a test.afterEach (or a test.step called in
afterEach) for the describe block that calls openKeybindingsTab(page) and clicks
the 'reset-all-keybindings-btn' test id to restore defaults, and remove the
duplicated reset blocks currently inside tests (the occurrences around the
existing openKeybindingsTab(...); await
page.getByTestId('reset-all-keybindings-btn').click(...) blocks).
- Around line 1862-1876: Replace the repeated manual remap sequence with the
existing helper remapKeybinding to dedupe; specifically, in the blocks that
perform the openKeybindingsTab → hover on keybinding-row-sendRequest → click
keybinding-edit-sendRequest → Backspace → press Shift+Enter →
closePreferencesTab sequence, call remapKeybinding(page, 'sendRequest',
'Shift+Enter') (and the analogous calls for the other two tests) so the tests
use the centralized remapKeybinding helper instead of duplicating the 15-line
interaction sequence.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 74111e6f-96de-4396-afc7-cf8033687012
📒 Files selected for processing (4)
packages/bruno-app/src/components/CodeEditor/index.jspackages/bruno-app/src/components/MultiLineEditor/index.jspackages/bruno-app/src/components/RequestTabPanel/index.jstests/shortcuts/bound-actions.spec.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
tests/shortcuts/bound-actions.spec.ts (4)
1743-2012: Wrap the multi-step flows intest.stepfor readable reports.Per the project's Playwright guideline ("Promote the use of
test.stepas much as possible so the generated reports are easier to read"), each of these tests has 4-5 distinct phases (close tabs → remap (where applicable) → create+open request → focus editor → send → assert). Wrapping each phase intest.step('...', async () => { ... })will make trace reports far easier to triage when one of these flaky network tests fails on CI.As per coding guidelines: "Promote the use of test.step as much as possible so the generated reports are easier to read".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/shortcuts/bound-actions.spec.ts` around lines 1743 - 2012, The tests in this file lack test.step wrappers around distinct phases, making reports hard to read; update each relevant test (e.g., tests that call createRequest, openRequest, selectRequestPaneTab, openKeybindingsTab, and the CodeMirror interactions) to wrap the logical phases (close tabs, remap keys when present, create/open request, focus/type in editor, send request and assert response) in test.step('phase name', async () => { ... }) blocks so each phase appears as a separate step in Playwright reports; apply this to all tests in the "SHORTCUT: Send Request..." and "SHORTCUT: Send Request (customized Shift+Enter)" suites, keeping existing awaits and function calls inside the step callbacks.
1854-2011: Heavy duplication across the threeShift+Entertests — reuse the existingremapKeybindinghelper.The three customized tests repeat the same ~20-line remap block (open keybindings → hover row → click edit → backspace → press Shift+Enter). The file already exposes
remapKeybinding(line 95) which neighbouring tests use. Same goes for the trailing "Reset Default" pair — extract a tinyresetAllKeybindings(page)helper.♻️ Sketch
- // Remap sendRequest to Shift+Enter - await openKeybindingsTab(page); - const row = page.getByTestId('keybinding-row-sendRequest'); - await row.hover(); - await page.getByTestId('keybinding-edit-sendRequest').click(); - await expect(page.getByTestId('keybinding-input-sendRequest')).toBeVisible({ timeout: 2000 }); - - await page.keyboard.down('Backspace'); - - await page.keyboard.down('Shift'); - await page.keyboard.down('Enter'); - await page.keyboard.up('Enter'); - await page.keyboard.up('Shift'); + await remapKeybinding(page, 'sendRequest', async () => { + await page.keyboard.press('Shift+Enter'); + });Note:
remapKeybindingends withclosePreferencesTab— which is what the commented-out lines (1876/1925/1981) suggest you actually wanted. Win-win.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/shortcuts/bound-actions.spec.ts` around lines 1854 - 2011, Replace the repeated 20-line keybinding remap block in the three tests with the existing remapKeybinding helper (call remapKeybinding(page, 'sendRequest', 'Shift+Enter') or appropriate args used elsewhere) so the tests reuse the centralized logic (remapKeybinding already closes preferences via closePreferencesTab), and extract the repeated "Reset Default" actions into a small resetAllKeybindings(page) helper that clicks the reset button (call it from each test). Update the three tests to call remapKeybinding(...) at the start and resetAllKeybindings(page) at the end to remove duplication.
1838-1851: Comment promises a behaviour that isn't asserted.The inline comment says "should NOT insert a newline; should fire sendRequest" — but only the second half is asserted (the 200 response). If a future regression makes Cmd/Ctrl+Enter both insert a newline and send, this test still passes. Cheap fix:
await page.keyboard.press(`${modifier}+Enter`); + // Confirm the editor did not also receive a newline insertion + await expect(valueEditor).toContainText('val-1'); + await expect(valueEditor).not.toContainText('val-1\nval-2\n'); // Verify a 200 response came back await expect(page.getByTestId('response-status-code')).toContainText('200', { timeout: 15000 });Same applies to the Shift+Enter Vars test at lines 1996-2005.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/shortcuts/bound-actions.spec.ts` around lines 1838 - 1851, The test comment states Cmd/Ctrl+Enter should not insert a newline but the test only asserts the request sent; update the test to also assert the CodeMirror value hasn't gained an extra newline after pressing `${modifier}+Enter` by reading the value from the same valueEditor locator (the '.CodeMirror' first() used here) and asserting it still equals the expected two-line string (e.g. 'val-1\nval-2'); apply the same additional assertion to the Shift+Enter Vars test that uses the Vars editor so the tests fail if the key both inserts a newline and sends.
1876-1876: Dead commented-out code — decide and delete.
// await closePreferencesTab(page);appears at lines 1876, 1925, and 1981. Either the prefs tab needs closing (in which case restore the call — recommended, sinceremapKeybindingdoes this for a reason) or it doesn't (delete the comment). Leaving it in invites cargo-culting later.Worth confirming locally: with the prefs tab still focused after recording, does the subsequent
createRequestflow actually behave the same as when the prefs tab is closed? If runs are green only becauseopenRequesttabs over the prefs view, that's incidental and brittle.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/shortcuts/bound-actions.spec.ts` at line 1876, The commented-out calls to closePreferencesTab(page) are dead code—either remove them or restore the call; since remapKeybinding expects the prefs tab to be closed, the recommended fix is to uncomment/restore closePreferencesTab(page) in the three spots where `// await closePreferencesTab(page);` appears in tests/shortcuts/bound-actions.spec.ts (ensure they run after the recording step and before createRequest/openRequest flows), then run the tests locally to verify createRequest behaves the same; if you instead delete the comments, remove all three occurrences and add a brief test comment explaining why closing the prefs tab is not needed and confirm tests remain green.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/shortcuts/bound-actions.spec.ts`:
- Around line 1745-2010: The tests currently depend on the external host
https://echo.usebruno.com; replace that dependency by intercepting or stubbing
the network so the tests assert the shortcut triggers sendRequest rather than
relying on an external round-trip. Concretely, in the tests that call
createRequest/openRequest and then expect getByTestId('response-status-code') to
contain '200' (tests named like "sends request when cursor is in JSON body
editor", "...response body editor", and the Shift+Enter variants), add a
page.route(...) or a local fixture server to intercept requests to
https://echo.usebruno.com and return a deterministic 200 response (including any
body needed by response-preview), or change createRequest to point at a local
test server; ensure the interception runs before any UI actions that trigger the
request so the sendRequest flow (the keyboard.press calls) receives the mocked
200 response reliably.
---
Nitpick comments:
In `@tests/shortcuts/bound-actions.spec.ts`:
- Around line 1743-2012: The tests in this file lack test.step wrappers around
distinct phases, making reports hard to read; update each relevant test (e.g.,
tests that call createRequest, openRequest, selectRequestPaneTab,
openKeybindingsTab, and the CodeMirror interactions) to wrap the logical phases
(close tabs, remap keys when present, create/open request, focus/type in editor,
send request and assert response) in test.step('phase name', async () => { ...
}) blocks so each phase appears as a separate step in Playwright reports; apply
this to all tests in the "SHORTCUT: Send Request..." and "SHORTCUT: Send Request
(customized Shift+Enter)" suites, keeping existing awaits and function calls
inside the step callbacks.
- Around line 1854-2011: Replace the repeated 20-line keybinding remap block in
the three tests with the existing remapKeybinding helper (call
remapKeybinding(page, 'sendRequest', 'Shift+Enter') or appropriate args used
elsewhere) so the tests reuse the centralized logic (remapKeybinding already
closes preferences via closePreferencesTab), and extract the repeated "Reset
Default" actions into a small resetAllKeybindings(page) helper that clicks the
reset button (call it from each test). Update the three tests to call
remapKeybinding(...) at the start and resetAllKeybindings(page) at the end to
remove duplication.
- Around line 1838-1851: The test comment states Cmd/Ctrl+Enter should not
insert a newline but the test only asserts the request sent; update the test to
also assert the CodeMirror value hasn't gained an extra newline after pressing
`${modifier}+Enter` by reading the value from the same valueEditor locator (the
'.CodeMirror' first() used here) and asserting it still equals the expected
two-line string (e.g. 'val-1\nval-2'); apply the same additional assertion to
the Shift+Enter Vars test that uses the Vars editor so the tests fail if the key
both inserts a newline and sends.
- Line 1876: The commented-out calls to closePreferencesTab(page) are dead
code—either remove them or restore the call; since remapKeybinding expects the
prefs tab to be closed, the recommended fix is to uncomment/restore
closePreferencesTab(page) in the three spots where `// await
closePreferencesTab(page);` appears in tests/shortcuts/bound-actions.spec.ts
(ensure they run after the recording step and before createRequest/openRequest
flows), then run the tests locally to verify createRequest behaves the same; if
you instead delete the comments, remove all three occurrences and add a brief
test comment explaining why closing the prefs tab is not needed and confirm
tests remain green.
🪄 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: 7a9fc4a2-9858-445e-bf48-b693c5d3348a
📒 Files selected for processing (1)
tests/shortcuts/bound-actions.spec.ts
|
Credits to #7845 by @phubadeepjs for the original implementation |
Description
JIRA
Fixes : #7846
Contribution Checklist:
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
Bug Fixes
Tests