From 2553e9e9b011b6cbc9003b96257652aa448dc45f Mon Sep 17 00:00:00 2001 From: Pooja Belaramani Date: Wed, 15 Jul 2026 16:57:28 +0530 Subject: [PATCH 1/5] fix(ws): keep body-mode dropdown above collapsed sticky headers --- .../RequestPane/WsBody/BodyMode/index.js | 9 ++- .../WsBody/SingleWSMessage/StyledWrapper.js | 6 ++ tests/utils/page/locators.ts | 33 +-------- tests/utils/page/websocket.ts | 38 ++++++++++ tests/websockets/ws-header.spec.ts | 71 +++++++++++++++++++ 5 files changed, 123 insertions(+), 34 deletions(-) create mode 100644 tests/utils/page/websocket.ts create mode 100644 tests/websockets/ws-header.spec.ts diff --git a/packages/bruno-app/src/components/RequestPane/WsBody/BodyMode/index.js b/packages/bruno-app/src/components/RequestPane/WsBody/BodyMode/index.js index 36e759b41f8..a372749034b 100644 --- a/packages/bruno-app/src/components/RequestPane/WsBody/BodyMode/index.js +++ b/packages/bruno-app/src/components/RequestPane/WsBody/BodyMode/index.js @@ -25,7 +25,11 @@ const WSRequestBodyMode = ({ mode, onModeChange }) => { const Icon = forwardRef((props, ref) => { return ( -
+
{humanizeRequestBodyMode(mode)} {' '} @@ -35,12 +39,13 @@ const WSRequestBodyMode = ({ mode, onModeChange }) => { return ( -
+
} placement="bottom-end">
Raw
{RAW_MODES.map((d) => (
{ dropdownTippyRef.current.hide(); diff --git a/packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/StyledWrapper.js b/packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/StyledWrapper.js index 1520f73c352..3d636aee84f 100644 --- a/packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/StyledWrapper.js +++ b/packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/StyledWrapper.js @@ -28,6 +28,12 @@ const StyledWrapper = styled.div` top: 0; z-index: 1; background: ${(props) => props.theme.bg}; + + &:hover, + &:focus-within { + z-index: 2; + } + display: flex; align-items: center; justify-content: space-between; diff --git a/tests/utils/page/locators.ts b/tests/utils/page/locators.ts index 31bcaad0786..2f6d4993bbf 100644 --- a/tests/utils/page/locators.ts +++ b/tests/utils/page/locators.ts @@ -3,6 +3,7 @@ import { buildApiSpecPanelLocators } from './openapi/render-spec'; import { buildFileModeLocators } from './file-mode'; import { buildPreferencesLocators } from './preferences'; import { buildAiPreferencesLocators } from './ai'; +import { buildWebsocketCommonLocators } from './websocket'; export const buildCommonLocators = (page: Page) => ({ runner: () => page.getByTestId('run-button'), @@ -367,38 +368,6 @@ export const buildCommonLocators = (page: Page) => ({ } }); -export const buildWebsocketCommonLocators = (page: Page) => ({ - connectionControls: { - connect: () => page.getByTestId('ws-connect-button'), - disconnect: () => page.getByTestId('ws-disconnect-button') - }, - messages: () => page.locator('.ws-message'), - message: { - container: () => page.getByTestId('ws-messages-container'), - addButton: () => page.getByTestId('ws-add-message'), - headers: () => page.getByTestId(/^ws-message-header-/), - header: (index: number) => page.getByTestId(`ws-message-header-${index}`), - body: (index: number) => page.getByTestId(`ws-message-body-${index}`), - editor: (index: number) => page.getByTestId(`ws-message-body-${index}`).locator('.CodeMirror'), - editorPlaceholder: (index: number) => - page.getByTestId(`ws-message-body-${index}`).locator('.CodeMirror-placeholder'), - editorCode: (index: number) => page.getByTestId(`ws-message-body-${index}`).locator('.CodeMirror-code'), - labels: () => page.getByTestId(/^ws-message-label-/), - label: (index: number) => page.getByTestId(`ws-message-label-${index}`), - nameInputs: () => page.getByTestId(/^ws-message-name-input-/), - nameInput: (index: number) => page.getByTestId(`ws-message-name-input-${index}`), - nameTooltip: () => page.getByTestId('ws-message-name-tooltip'), - prettifyAll: () => page.getByTestId('ws-prettify-all'), - sendButton: (index: number) => page.getByTestId(`ws-send-msg-${index}`), - deleteButton: (index: number) => page.getByTestId(`ws-delete-msg-${index}`) - }, - toolbar: { - latestFirst: () => page.getByRole('button', { name: 'Latest First' }), - latestLast: () => page.getByRole('button', { name: 'Latest Last' }), - clearResponse: () => page.getByTestId('response-clear-btn') - } -}); - export const getTableCell = (row, index) => row.locator('td').nth(index + 1); export const buildGrpcCommonLocators = (page: Page) => ({ diff --git a/tests/utils/page/websocket.ts b/tests/utils/page/websocket.ts new file mode 100644 index 00000000000..8d1060e7549 --- /dev/null +++ b/tests/utils/page/websocket.ts @@ -0,0 +1,38 @@ +import { Page } from '../../../playwright'; + +export const buildWebsocketCommonLocators = (page: Page) => ({ + connectionControls: { + connect: () => page.getByTestId('ws-connect-button'), + disconnect: () => page.getByTestId('ws-disconnect-button') + }, + messages: () => page.locator('.ws-message'), + message: { + container: () => page.getByTestId('ws-messages-container'), + addButton: () => page.getByTestId('ws-add-message'), + headers: () => page.getByTestId(/^ws-message-header-/), + header: (index: number) => page.getByTestId(`ws-message-header-${index}`), + body: (index: number) => page.getByTestId(`ws-message-body-${index}`), + editor: (index: number) => page.getByTestId(`ws-message-body-${index}`).locator('.CodeMirror'), + editorPlaceholder: (index: number) => + page.getByTestId(`ws-message-body-${index}`).locator('.CodeMirror-placeholder'), + editorCode: (index: number) => page.getByTestId(`ws-message-body-${index}`).locator('.CodeMirror-code'), + labels: () => page.getByTestId(/^ws-message-label-/), + label: (index: number) => page.getByTestId(`ws-message-label-${index}`), + nameInputs: () => page.getByTestId(/^ws-message-name-input-/), + nameInput: (index: number) => page.getByTestId(`ws-message-name-input-${index}`), + nameTooltip: () => page.getByTestId('ws-message-name-tooltip'), + prettifyAll: () => page.getByTestId('ws-prettify-all'), + sendButton: (index: number) => page.getByTestId(`ws-send-msg-${index}`), + deleteButton: (index: number) => page.getByTestId(`ws-delete-msg-${index}`), + bodyModeSelector: (index: number) => + page.getByTestId(`ws-message-header-${index}`).getByTestId('ws-body-mode-selector'), + bodyModeLabel: (index: number) => + page.getByTestId(`ws-message-header-${index}`).getByTestId('ws-body-mode-label'), + bodyModeItem: (mode: 'json' | 'xml' | 'text') => page.getByTestId(`ws-body-mode-item-${mode}`) + }, + toolbar: { + latestFirst: () => page.getByRole('button', { name: 'Latest First' }), + latestLast: () => page.getByRole('button', { name: 'Latest Last' }), + clearResponse: () => page.getByTestId('response-clear-btn') + } +}); diff --git a/tests/websockets/ws-header.spec.ts b/tests/websockets/ws-header.spec.ts new file mode 100644 index 00000000000..6a490fe2bbd --- /dev/null +++ b/tests/websockets/ws-header.spec.ts @@ -0,0 +1,71 @@ +import { expect, test } from '../../playwright'; +import { closeAllTabs, createTransientRequest, selectRequestPaneTab } from '../utils/page/actions'; +import { buildCommonLocators } from '../utils/page/locators'; +import type { Locator } from '@playwright/test'; + +test.describe('websocket sticky header dropdown overlap', () => { + test.afterEach(async ({ page }) => { + await closeAllTabs(page); + }); + + // Returns true if the dropdown item is on top at its centre (not hidden behind a header). + const topElementIsInsideDropdown = async (locator: Locator) => { + const box = await locator.boundingBox(); + expect(box, 'dropdown item should have a layout box').not.toBeNull(); + const x = box!.x + box!.width / 2; + const y = box!.y + box!.height / 2; + return locator.page().evaluate( + ({ x, y }) => Boolean(document.elementFromPoint(x, y)?.closest('.tippy-box, .dropdown')), + { x, y } + ); + }; + + test('body-mode dropdown of an upper message renders above the collapsed headers below it', async ({ + page + }) => { + const { websocket } = buildCommonLocators(page); + + await createTransientRequest(page, { requestType: 'WebSocket' }); + await selectRequestPaneTab(page, 'Message'); + + // Build a list of several messages so an upper message's dropdown overlaps + // the headers below it. + await expect(websocket.message.headers()).toHaveCount(1); + for (let i = 0; i < 3; i++) { + const before = await websocket.message.headers().count(); + await websocket.message.addButton().click(); + await expect(websocket.message.headers()).toHaveCount(before + 1); + } + + const total = await websocket.message.headers().count(); + expect(total).toBeGreaterThanOrEqual(4); + + // Collapse every message so all accordions are closed. + for (let i = 0; i < total; i++) { + if (await websocket.message.body(i).isVisible()) { + await websocket.message.header(i).click(); + } + } + for (let i = 0; i < total; i++) { + await expect(websocket.message.body(i)).toBeHidden(); + } + + // Open the first message's body-mode dropdown; its menu opens downward over + // the collapsed headers below it. + await websocket.message.bodyModeSelector(0).click(); + + // The lowest item is the one most likely to overlap the header below, so it + // is the strongest signal that the menu is not covered. + const textItem = websocket.message.bodyModeItem('text'); + await expect(textItem).toBeVisible(); + + // The item must be the topmost element at its own centre. Without the fix a + // lower header paints over it and this resolves to the header instead. + expect(await topElementIsInsideDropdown(textItem)).toBe(true); + + // It must also be clickable — Playwright's actionability check fails if the + // item is obscured by a sticky header — and selecting it applies. + await textItem.click(); + await expect(websocket.message.bodyModeLabel(0)).toContainText('TEXT'); + }); +}); From b0aa7c3a0da9039e91d3a792f2916592f38d8932 Mon Sep 17 00:00:00 2001 From: Pooja Belaramani Date: Wed, 15 Jul 2026 18:38:31 +0530 Subject: [PATCH 2/5] fix --- .../src/components/RequestPane/WsBody/BodyMode/index.js | 7 ++++++- .../RequestPane/WsBody/SingleWSMessage/StyledWrapper.js | 3 +-- .../components/RequestPane/WsBody/SingleWSMessage/index.js | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/bruno-app/src/components/RequestPane/WsBody/BodyMode/index.js b/packages/bruno-app/src/components/RequestPane/WsBody/BodyMode/index.js index a372749034b..9dc46e376cb 100644 --- a/packages/bruno-app/src/components/RequestPane/WsBody/BodyMode/index.js +++ b/packages/bruno-app/src/components/RequestPane/WsBody/BodyMode/index.js @@ -40,7 +40,12 @@ const WSRequestBodyMode = ({ mode, onModeChange }) => { return (
- } placement="bottom-end"> + } + placement="bottom-end" + appendTo={() => document.body} + >
Raw
{RAW_MODES.map((d) => (
props.theme.bg}; - &:hover, - &:focus-within { + &:hover { z-index: 2; } diff --git a/packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js b/packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js index b141d3a2815..5b54c66ece5 100644 --- a/packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js +++ b/packages/bruno-app/src/components/RequestPane/WsBody/SingleWSMessage/index.js @@ -237,13 +237,13 @@ export const SingleWSMessage = ({
e.stopPropagation()}>
- + {(body.ws || []).length > 1 && ( - + From 9f3d7edeb1ca6addb740ac42640c5764d5b7d0af Mon Sep 17 00:00:00 2001 From: Pooja Belaramani Date: Wed, 15 Jul 2026 18:48:35 +0530 Subject: [PATCH 3/5] add: test --- tests/websockets/ws-header.spec.ts | 124 ++++++++++++++++++++--------- 1 file changed, 88 insertions(+), 36 deletions(-) diff --git a/tests/websockets/ws-header.spec.ts b/tests/websockets/ws-header.spec.ts index 6a490fe2bbd..43985497a7d 100644 --- a/tests/websockets/ws-header.spec.ts +++ b/tests/websockets/ws-header.spec.ts @@ -25,47 +25,99 @@ test.describe('websocket sticky header dropdown overlap', () => { }) => { const { websocket } = buildCommonLocators(page); - await createTransientRequest(page, { requestType: 'WebSocket' }); - await selectRequestPaneTab(page, 'Message'); - - // Build a list of several messages so an upper message's dropdown overlaps - // the headers below it. - await expect(websocket.message.headers()).toHaveCount(1); - for (let i = 0; i < 3; i++) { - const before = await websocket.message.headers().count(); - await websocket.message.addButton().click(); - await expect(websocket.message.headers()).toHaveCount(before + 1); - } - - const total = await websocket.message.headers().count(); - expect(total).toBeGreaterThanOrEqual(4); - - // Collapse every message so all accordions are closed. - for (let i = 0; i < total; i++) { - if (await websocket.message.body(i).isVisible()) { - await websocket.message.header(i).click(); + await test.step('Open a websocket request with several collapsed messages', async () => { + await createTransientRequest(page, { requestType: 'WebSocket' }); + await selectRequestPaneTab(page, 'Message'); + + await expect(websocket.message.headers()).toHaveCount(1); + for (let i = 0; i < 3; i++) { + const before = await websocket.message.headers().count(); + await websocket.message.addButton().click(); + await expect(websocket.message.headers()).toHaveCount(before + 1); } - } - for (let i = 0; i < total; i++) { - await expect(websocket.message.body(i)).toBeHidden(); - } - // Open the first message's body-mode dropdown; its menu opens downward over - // the collapsed headers below it. - await websocket.message.bodyModeSelector(0).click(); + const total = await websocket.message.headers().count(); + expect(total).toBeGreaterThanOrEqual(4); + + // Collapse every message so all accordions are closed. + for (let i = 0; i < total; i++) { + if (await websocket.message.body(i).isVisible()) { + await websocket.message.header(i).click(); + } + } + for (let i = 0; i < total; i++) { + await expect(websocket.message.body(i)).toBeHidden(); + } + }); - // The lowest item is the one most likely to overlap the header below, so it - // is the strongest signal that the menu is not covered. const textItem = websocket.message.bodyModeItem('text'); - await expect(textItem).toBeVisible(); - // The item must be the topmost element at its own centre. Without the fix a - // lower header paints over it and this resolves to the header instead. - expect(await topElementIsInsideDropdown(textItem)).toBe(true); + await test.step('Open the first message dropdown over the headers below', async () => { + await websocket.message.bodyModeSelector(0).click(); + + // The lowest item is the one most likely to overlap the header below, so + // it is the strongest signal that the menu is not covered. + await expect(textItem).toBeVisible(); + + // The item must be the topmost element at its own centre. Without the fix + // a lower header paints over it and this resolves to the header instead. + expect(await topElementIsInsideDropdown(textItem)).toBe(true); + }); + + await test.step('Select the item and verify it applies', async () => { + // Playwright's actionability check fails if the item is obscured. + await textItem.click(); + await expect(websocket.message.bodyModeLabel(0)).toContainText('TEXT'); + }); + }); + + test.only('open dropdown stays on top when a lower message header is hovered', async ({ + page + }) => { + const { websocket } = buildCommonLocators(page); + let total = 0; + + await test.step('Open a websocket request with several collapsed messages', async () => { + await createTransientRequest(page, { requestType: 'WebSocket' }); + await selectRequestPaneTab(page, 'Message'); + + await expect(websocket.message.headers()).toHaveCount(1); + for (let i = 0; i < 3; i++) { + const before = await websocket.message.headers().count(); + await websocket.message.addButton().click(); + await expect(websocket.message.headers()).toHaveCount(before + 1); + } + + total = await websocket.message.headers().count(); + expect(total).toBeGreaterThanOrEqual(4); + + // Collapse every message so all accordions are closed. + for (let i = 0; i < total; i++) { + if (await websocket.message.body(i).isVisible()) { + await websocket.message.header(i).click(); + } + } + for (let i = 0; i < total; i++) { + await expect(websocket.message.body(i)).toBeHidden(); + } + }); + + const textItem = websocket.message.bodyModeItem('text'); + + await test.step('Open the first message dropdown, then hover a header below it', async () => { + // The dropdown renders in a portal (appendTo document.body), so hovering a + // lower header must not raise that header over the open menu. + await websocket.message.bodyModeSelector(0).click(); + await expect(textItem).toBeVisible(); + + // Hover the last message's header — the one furthest under the open menu. + await websocket.message.header(total - 1).hover(); + }); - // It must also be clickable — Playwright's actionability check fails if the - // item is obscured by a sticky header — and selecting it applies. - await textItem.click(); - await expect(websocket.message.bodyModeLabel(0)).toContainText('TEXT'); + await test.step('Dropdown stays on top and is still clickable', async () => { + expect(await topElementIsInsideDropdown(textItem)).toBe(true); + await textItem.click(); + await expect(websocket.message.bodyModeLabel(0)).toContainText('TEXT'); + }); }); }); From 085bd8c522cc10250b9e69338af05115c3d3821e Mon Sep 17 00:00:00 2001 From: Pooja Belaramani Date: Wed, 15 Jul 2026 18:48:53 +0530 Subject: [PATCH 4/5] rm: only --- tests/websockets/ws-header.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/websockets/ws-header.spec.ts b/tests/websockets/ws-header.spec.ts index 43985497a7d..9182dbff741 100644 --- a/tests/websockets/ws-header.spec.ts +++ b/tests/websockets/ws-header.spec.ts @@ -71,7 +71,7 @@ test.describe('websocket sticky header dropdown overlap', () => { }); }); - test.only('open dropdown stays on top when a lower message header is hovered', async ({ + test('open dropdown stays on top when a lower message header is hovered', async ({ page }) => { const { websocket } = buildCommonLocators(page); From 828f79cbef827cc226052b3d86b3d5bc8a593499 Mon Sep 17 00:00:00 2001 From: Pooja Belaramani Date: Wed, 15 Jul 2026 19:43:30 +0530 Subject: [PATCH 5/5] improvement --- tests/utils/page/actions.ts | 20 +++++++++++++++++++- tests/websockets/ws-header.spec.ts | 19 +++---------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/tests/utils/page/actions.ts b/tests/utils/page/actions.ts index a2daaf726b1..256eae6fc0c 100644 --- a/tests/utils/page/actions.ts +++ b/tests/utils/page/actions.ts @@ -2455,6 +2455,23 @@ const openUrlVarTooltip = async ( return tooltip; }; +/** + * Returns true if the element is on top at its centre (not hidden behind a header), + * i.e. the topmost element at its centre is inside a dropdown/tippy container. + * @param locator - The dropdown item locator + * @returns Whether the item is the topmost element at its own centre + */ +const elementIsInsideDropdown = async (locator: Locator) => { + const box = await locator.boundingBox(); + expect(box, 'dropdown item should have a layout box').not.toBeNull(); + const x = box!.x + box!.width / 2; + const y = box!.y + box!.height / 2; + return locator.page().evaluate( + ({ x, y }) => Boolean(document.elementFromPoint(x, y)?.closest('.tippy-box, .dropdown')), + { x, y } + ); +}; + export { waitForReadyPage, setRequestUrlAndSave, @@ -2556,7 +2573,8 @@ export { getAppWebviewHtml, createApp, selectAppView, - renameWsMessage + renameWsMessage, + elementIsInsideDropdown }; export type { SandboxMode, EnvironmentType, EnvironmentVariable, ImportCollectionOptions, CreateRequestOptions, CreateUntitledRequestOptions, CreateTransientRequestOptions, AssertionInput }; diff --git a/tests/websockets/ws-header.spec.ts b/tests/websockets/ws-header.spec.ts index 9182dbff741..eff618a9c86 100644 --- a/tests/websockets/ws-header.spec.ts +++ b/tests/websockets/ws-header.spec.ts @@ -1,25 +1,12 @@ import { expect, test } from '../../playwright'; -import { closeAllTabs, createTransientRequest, selectRequestPaneTab } from '../utils/page/actions'; +import { closeAllTabs, createTransientRequest, elementIsInsideDropdown, selectRequestPaneTab } from '../utils/page/actions'; import { buildCommonLocators } from '../utils/page/locators'; -import type { Locator } from '@playwright/test'; test.describe('websocket sticky header dropdown overlap', () => { test.afterEach(async ({ page }) => { await closeAllTabs(page); }); - // Returns true if the dropdown item is on top at its centre (not hidden behind a header). - const topElementIsInsideDropdown = async (locator: Locator) => { - const box = await locator.boundingBox(); - expect(box, 'dropdown item should have a layout box').not.toBeNull(); - const x = box!.x + box!.width / 2; - const y = box!.y + box!.height / 2; - return locator.page().evaluate( - ({ x, y }) => Boolean(document.elementFromPoint(x, y)?.closest('.tippy-box, .dropdown')), - { x, y } - ); - }; - test('body-mode dropdown of an upper message renders above the collapsed headers below it', async ({ page }) => { @@ -61,7 +48,7 @@ test.describe('websocket sticky header dropdown overlap', () => { // The item must be the topmost element at its own centre. Without the fix // a lower header paints over it and this resolves to the header instead. - expect(await topElementIsInsideDropdown(textItem)).toBe(true); + expect(await elementIsInsideDropdown(textItem)).toBe(true); }); await test.step('Select the item and verify it applies', async () => { @@ -115,7 +102,7 @@ test.describe('websocket sticky header dropdown overlap', () => { }); await test.step('Dropdown stays on top and is still clickable', async () => { - expect(await topElementIsInsideDropdown(textItem)).toBe(true); + expect(await elementIsInsideDropdown(textItem)).toBe(true); await textItem.click(); await expect(websocket.message.bodyModeLabel(0)).toContainText('TEXT'); });