Repository navigation
fix(ToggleSwitch): correct onChange handler for response pane - #8520
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
WalkthroughToggleSwitch and MenuDropdown change event handling, ChangesUI event wiring and test harness updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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.
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-app/src/components/ToggleSwitch/index.js`:
- Around line 8-19: The toggle logic in ToggleSwitch should not live on the
outer Switch click handler because label clicks can bubble twice and trigger
handleToggle twice. Move the state change to a single source of truth in
ToggleSwitch/Checkbox, or stop the label-originated click before it reaches
Switch so handleToggle is only invoked once. Use the existing handleToggle,
Switch, and Checkbox wiring to locate and adjust the event handling.
🪄 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: a68208f9-44df-4510-aacd-0ea5d7ccb355
📒 Files selected for processing (1)
packages/bruno-app/src/components/ToggleSwitch/index.js
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates ToggleSwitch so toggling is triggered by clicking the outer Switch wrapper rather than the checkbox’s onChange.
Changes:
- Add
onClick={handleToggle}to theSwitchwrapper. - Replace checkbox
onChange={handleToggle}with a no-op handler.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…better toggle interaction fix(tests): update response pane click action to ensure proper interaction with dropdown
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/utils/page/actions.ts (1)
1364-1387: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winGuard runs after
targetRowis already computed with the un-clamped index.
rowIndexis clamped to0only aftertargetRowis built from it, so ifcount()is0(rowIndex = -1),targetRowstill resolves via.nth(-1), which the guard was meant to prevent.🐛 Proposed fix
- let rowIndex = (await table.allRows().count()) - 1; - const targetRow = table.allRows().nth(rowIndex); - - if (rowIndex < 0) { - rowIndex = 0; - } + let rowIndex = (await table.allRows().count()) - 1; + if (rowIndex < 0) { + rowIndex = 0; + } + const targetRow = table.allRows().nth(rowIndex);🤖 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 `@tests/utils/page/actions.ts` around lines 1364 - 1387, In addMultipartFileToLastRow, the empty-table guard is applied too late because targetRow is created before rowIndex is clamped, so a zero-row table can still use .nth(-1). Move the rowIndex normalization to happen before deriving targetRow, then use the clamped index for both the visibility check and the later specificRow lookup to keep the multipart upload flow safe when the table is empty.
🧹 Nitpick comments (1)
tests/utils/page/actions.ts (1)
1905-1914: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSets CodeMirror value via internal API instead of simulating real input.
Reaching into
.CodeMirrorand callingsetValue()directly bypasses actual user typing, which the Playwright guide favors avoiding except for controlled fixture setup. If this is meant purely as a fast fixture-seeding helper (not simulating the behavior under test), consider naming/comment to make that intent explicit; otherwise prefer.click()+page.keyboard.type()likeaddRowToActiveTabdoes elsewhere in this file.As per path instructions, "Do not reach into app internals unless absolutely necessary for setup or controlled test fixtures."
🤖 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 `@tests/utils/page/actions.ts` around lines 1905 - 1914, The helper setTableRowDescriptionValue bypasses real user input by reaching into the CodeMirror internals and calling setValue directly. If this is only for controlled fixture setup, make that intent explicit in the function name or nearby comment; otherwise update the test flow to use user-like interactions such as clicking the description cell and typing through Playwright, similar to addRowToActiveTab, and avoid accessing .CodeMirror/CodeMirror.setValue unless strictly necessary.Source: Path instructions
🤖 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 `@playwright/index.ts`:
- Around line 337-350: The clipboard stub init script is duplicated in both the
page and pageWithUserData fixtures, so extract the shared navigator.clipboard
setup into a single helper and call it from both places. Keep the logic in one
reusable function near the fixture setup in playwright/index.ts, and update both
fixture definitions to use that helper so the stub stays consistent and avoids
drift.
- Around line 337-350: The clipboard stub is being injected too late in the page
fixture, so `navigator.clipboard` is not patched for the initial renderer load.
Move the `page.addInitScript()` setup so it runs before the first page is
created or loaded, and reuse the same stub logic in both fixtures instead of
duplicating it. Use the `page` fixture and
`usePageWithTracing`/`waitForReadyPage` as the key entry points when
refactoring.
---
Outside diff comments:
In `@tests/utils/page/actions.ts`:
- Around line 1364-1387: In addMultipartFileToLastRow, the empty-table guard is
applied too late because targetRow is created before rowIndex is clamped, so a
zero-row table can still use .nth(-1). Move the rowIndex normalization to happen
before deriving targetRow, then use the clamped index for both the visibility
check and the later specificRow lookup to keep the multipart upload flow safe
when the table is empty.
---
Nitpick comments:
In `@tests/utils/page/actions.ts`:
- Around line 1905-1914: The helper setTableRowDescriptionValue bypasses real
user input by reaching into the CodeMirror internals and calling setValue
directly. If this is only for controlled fixture setup, make that intent
explicit in the function name or nearby comment; otherwise update the test flow
to use user-like interactions such as clicking the description cell and typing
through Playwright, similar to addRowToActiveTab, and avoid accessing
.CodeMirror/CodeMirror.setValue unless strictly necessary.
🪄 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: af7b51e2-3a1c-4702-b3a9-f1cf1e57e81a
📒 Files selected for processing (3)
packages/bruno-app/src/components/ToggleSwitch/index.jsplaywright/index.tstests/utils/page/actions.ts
…no#8520) * fix(ToggleSwitch): correct onChange handler to prevent unintended toggling * fix(ToggleSwitch): update onChange handler to correctly trigger toggle action * fix(tests): enhance clipboard handling and improve response pane interactions * fix(ToggleSwitch): change event handler from onChange to onInput for better toggle interaction fix(tests): update response pane click action to ensure proper interaction with dropdown * fix(tests): remove clipboard initialization from test setup
Description
Fixes the current failing tests because of #8453
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