Skip to content

fix(ToggleSwitch): correct onChange handler for response pane - #8520

Merged
bijin-bruno merged 7 commits into
usebruno:mainfrom
sid-bruno:fix/response-pane-tests
Jul 7, 2026
Merged

bijin-bruno merged 7 commits into
usebruno:mainfrom
sid-bruno:fix/response-pane-tests

Conversation

@sid-bruno

@sid-bruno sid-bruno commented Jul 7, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes the current failing tests because of #8453

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

  • Bug Fixes
    • Prevented dropdown auto-closing when interacting inside the dropdown header.
    • Improved toggle switch responsiveness so user input triggers the expected state change.
  • Refactor / Style
    • Reformatted toggle switch markup for a clearer, multi-line prop layout (no intended visual change).
  • Tests
    • Updated the Playwright fixture to initialize tracing for consistent test execution.
    • Improved response preview/editor toggle automation reliability when the format dropdown is open.

Copilot AI review requested due to automatic review settings July 7, 2026 11:45
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dc520ac1-5f3b-45b4-ab3a-83f6dfe0954a

📥 Commits

Reviewing files that changed from the base of the PR and between 0fd27cb and ae6e668.

📒 Files selected for processing (1)
  • playwright/index.ts
💤 Files with no reviewable changes (1)
  • playwright/index.ts

Walkthrough

ToggleSwitch and MenuDropdown change event handling, setResponsePreviewMode now targets the open dropdown and clears it explicitly, and the Playwright user-data fixture enables tracing initialization.

Changes

UI event wiring and test harness updates

Layer / File(s) Summary
UI event wiring
packages/bruno-app/src/components/ToggleSwitch/index.js, packages/bruno-app/src/ui/MenuDropdown/index.js
ToggleSwitch switches its checkbox handler from onChange to onInput, and the dropdown header container no longer calls the outside-click close handler on click.
Response preview helper
tests/utils/page/actions.ts
setResponsePreviewMode resolves the preview toggle within the open response-format dropdown and clicks the response pane before waiting for the dropdown to hide.
Tracing fixture setup
playwright/index.ts
The pageWithUserData fixture now calls usePageWithTracing(...) with { initTracing: true }.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • usebruno/bruno#6100: Related response-format selector flow that uses the same UI interaction path updated in setResponsePreviewMode.
  • usebruno/bruno#6490: Related preview/editor switching behavior that matches the updated dropdown-based test interaction.

Suggested labels: size/S

Suggested reviewers: bijin-bruno, lohit-bruno, naman-bruno

Poem

A switch now listens in a new way,
A dropdown hushes its own doorway.
Tests tap the pane, then let it drift,
And tracing gets a little lift.

🚥 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 is specific and related to the ToggleSwitch event handler fix, which is one of the changes in this PR.
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.

@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-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

📥 Commits

Reviewing files that changed from the base of the PR and between 4592d2c and 7d2f563.

📒 Files selected for processing (1)
  • packages/bruno-app/src/components/ToggleSwitch/index.js

Copilot AI 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.

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 the Switch wrapper.
  • Replace checkbox onChange={handleToggle} with a no-op handler.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pull-request-size pull-request-size Bot added size/M and removed size/XS labels Jul 7, 2026

@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: 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 win

Guard runs after targetRow is already computed with the un-clamped index.

rowIndex is clamped to 0 only after targetRow is built from it, so if count() is 0 (rowIndex = -1), targetRow still 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 value

Sets CodeMirror value via internal API instead of simulating real input.

Reaching into .CodeMirror and calling setValue() 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() like addRowToActiveTab does 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1909953 and 0fd27cb.

📒 Files selected for processing (3)
  • packages/bruno-app/src/components/ToggleSwitch/index.js
  • playwright/index.ts
  • tests/utils/page/actions.ts

Comment thread playwright/index.ts Resolved
@pull-request-size pull-request-size Bot added size/S and removed size/M labels Jul 7, 2026
@bijin-bruno
bijin-bruno merged commit 86e4dc0 into usebruno:main Jul 7, 2026
14 of 16 checks passed
ravindra-bruno pushed a commit to ravindra-bruno/bruno that referenced this pull request Jul 9, 2026
…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
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.

3 participants