Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ const StyledWrapper = styled.div`
}
}

&:not(.disabled) .accordion-header {
.accordion-header {
position: sticky;
top: 0;
z-index: 1;
background: ${(props) => props.theme.bg};
}

.accordion-header {
display: flex;
align-items: center;
justify-content: space-between;
Expand Down
2 changes: 1 addition & 1 deletion packages/bruno-lang/v2/src/jsonToBru.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ ${indentString(body.sparql)}
}

// Convert content to JSON string if it's an object
let contentValue = typeof content === 'object' ? JSON.stringify(content, null, 2) : content || '{}';
let contentValue = typeof content === 'object' ? JSON.stringify(content, null, 2) : content || '';

// Wrap content with triple quotes for multiline support, without extra indentation
bru += `${indentString(`content: '''\n${indentString(contentValue)}\n'''`)}\n`;
Expand Down
20 changes: 20 additions & 0 deletions packages/bruno-lang/v2/tests/jsonToBru.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@ describe('jsonToBru stringify', () => {
expect(output).toMatch(new RegExp(`keepAliveInterval: ${input.settings.keepAliveInterval}`));
expect(output).toMatch(new RegExp(`timeout: ${input.settings.timeout}`));
});

it('serializes falsy content to an empty content block', () => {
const input = {
body: {
mode: 'ws',
ws: [
{
content: '',
name: 'message 1'
}
]
}
};

const output = stringify(input);

// Content block is emitted but empty (no '{}' fallback).
expect(output).toMatch(/content: '''\s*'''/);
expect(output).not.toContain('{}');
});
});

describe('body:multipart-form file values', () => {
Expand Down
6 changes: 6 additions & 0 deletions tests/utils/page/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@
await test.step(`Import collection from "${filePath}"`, async () => {
const locators = buildCommonLocators(page);

await page.getByTestId('collections-header-add-menu').click();

Check failure on line 490 in tests/utils/page/actions.ts

View workflow job for this annotation

GitHub Actions / Playwright E2E Tests (Linux)

[default] › tests/import/postman/import-many-issues-collection.spec.ts:12:7 › Import Postman Collection with many issues (URL too long warning) › should show URL-too-long warning when include failed request data is checked

5) [default] › tests/import/postman/import-many-issues-collection.spec.ts:12:7 › Import Postman Collection with many issues (URL too long warning) › should show URL-too-long warning when include failed request data is checked › Import collection from "/home/runner/work/bruno/bruno/tests/import/postman/fixtures/postman-with-many-import-issues.json" Error: locator.click: Target page, context or browser has been closed Call log: - waiting for getByTestId('collections-header-add-menu') - locator resolved to <button tabindex="-1" aria-expanded="false" data-tabindex="inline" title="Add new collection" data-testid="collections-header-add-menu" class="StyledWrapper-iYvzMB btWNSr action-icon">…</button> - attempting click action 2 × waiting for element to be visible, enabled and stable - element is visible, enabled and stable - scrolling into view if needed - done scrolling - <div class="bruno-modal-backdrop"></div> from <div class="StyledWrapper__Wrapper-jjqtyM DwvBf">…</div> subtree intercepts pointer events - retrying click action - waiting 20ms 2 × waiting for element to be visible, enabled and stable - element is visible, enabled and stable - scrolling into view if needed - done scrolling - <div class="bruno-modal-backdrop"></div> from <div class="StyledWrapper__Wrapper-jjqtyM DwvBf">…</div> subtree intercepts pointer events - retrying click action - waiting 100ms 58 × waiting for element to be visible, enabled and stable - element is visible, enabled and stable - scrolling into view if needed - done scrolling - <div class="bruno-modal-backdrop"></div> from <div class="StyledWrapper__Wrapper-jjqtyM DwvBf">…</div> subtree intercepts pointer events - retrying click action - waiting 500ms at tests/utils/page/actions.ts:490 488 | const locators = buildCommonLocators(page); 489 | > 490 | await page.getByTestId('collections-header-add-menu').click(); | ^ 491 | await page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Import collection' }).click(); 492 | 493 | // Wait for import modal at /home/runner/work/bruno/bruno/tests/utils/page/actions.ts:490:59 at importCollection (/home/runner/work/bruno/bruno/tests/utils/page/actions.ts:487:14) at /home/runner/work/bruno/bruno/tests/import/postman/import-many-issues-collection.spec.ts:17:27
await page.locator('.tippy-box .dropdown-item').filter({ hasText: 'Import collection' }).click();

// Wait for import modal
Expand Down Expand Up @@ -797,7 +797,7 @@
const addRowToActiveTab = async (page: Page, name: string, value: string) => {
await test.step(`Add row "${name}" to the active environment tab`, async () => {
const nameInput = page.locator('input[placeholder="Name"]').last();
await nameInput.waitFor({ state: 'visible' });

Check failure on line 800 in tests/utils/page/actions.ts

View workflow job for this annotation

GitHub Actions / Playwright E2E Tests (Linux)

[default] › tests/environments/create-environment/global-env-create.spec.ts:23:7 › Global Environment Create Tests › should import collection and create global environment for request usage

4) [default] › tests/environments/create-environment/global-env-create.spec.ts:23:7 › Global Environment Create Tests › should import collection and create global environment for request usage › Create global environment with variables › Add 5 environment variables › Add environment variable "postBody" › Add row "postBody" to the active environment tab TimeoutError: locator.waitFor: Timeout 30000ms exceeded. Call log: - waiting for locator('input[placeholder="Name"]').last() to be visible at tests/utils/page/actions.ts:800 798 | await test.step(`Add row "${name}" to the active environment tab`, async () => { 799 | const nameInput = page.locator('input[placeholder="Name"]').last(); > 800 | await nameInput.waitFor({ state: 'visible' }); | ^ 801 | await nameInput.fill(name); 802 | 803 | const row = page.getByTestId(`env-var-row-${name}`); at /home/runner/work/bruno/bruno/tests/utils/page/actions.ts:800:21 at addRowToActiveTab (/home/runner/work/bruno/bruno/tests/utils/page/actions.ts:798:14) at /home/runner/work/bruno/bruno/tests/utils/page/actions.ts:769:11 at addEnvironmentVariable (/home/runner/work/bruno/bruno/tests/utils/page/actions.ts:762:3) at /home/runner/work/bruno/bruno/tests/utils/page/actions.ts:783:7 at addEnvironmentVariables (/home/runner/work/bruno/bruno/tests/utils/page/actions.ts:781:3) at /home/runner/work/bruno/bruno/tests/environments/create-environment/global-env-create.spec.ts:39:7 at /home/runner/work/bruno/bruno/tests/environments/create-environment/global-env-create.spec.ts:36:5

Check failure on line 800 in tests/utils/page/actions.ts

View workflow job for this annotation

GitHub Actions / Playwright E2E Tests (Linux)

[default] › tests/environments/create-environment/collection-env-create.spec.ts:15:7 › Collection Environment Create Tests › should import collection and create environment for request usage

3) [default] › tests/environments/create-environment/collection-env-create.spec.ts:15:7 › Collection Environment Create Tests › should import collection and create environment for request usage › Create environment with variables › Add 5 environment variables › Add environment variable "postBody" › Add row "postBody" to the active environment tab Error: locator.waitFor: Target page, context or browser has been closed Call log: - waiting for locator('input[placeholder="Name"]').last() to be visible at tests/utils/page/actions.ts:800 798 | await test.step(`Add row "${name}" to the active environment tab`, async () => { 799 | const nameInput = page.locator('input[placeholder="Name"]').last(); > 800 | await nameInput.waitFor({ state: 'visible' }); | ^ 801 | await nameInput.fill(name); 802 | 803 | const row = page.getByTestId(`env-var-row-${name}`); at /home/runner/work/bruno/bruno/tests/utils/page/actions.ts:800:21 at addRowToActiveTab (/home/runner/work/bruno/bruno/tests/utils/page/actions.ts:798:14) at /home/runner/work/bruno/bruno/tests/utils/page/actions.ts:769:11 at addEnvironmentVariable (/home/runner/work/bruno/bruno/tests/utils/page/actions.ts:762:3) at /home/runner/work/bruno/bruno/tests/utils/page/actions.ts:783:7 at addEnvironmentVariables (/home/runner/work/bruno/bruno/tests/utils/page/actions.ts:781:3) at /home/runner/work/bruno/bruno/tests/environments/create-environment/collection-env-create.spec.ts:31:7 at /home/runner/work/bruno/bruno/tests/environments/create-environment/collection-env-create.spec.ts:28:5
await nameInput.fill(name);

const row = page.getByTestId(`env-var-row-${name}`);
Expand Down Expand Up @@ -1658,6 +1658,12 @@
if (await discardAllButton.isVisible({ timeout: 1000 }).catch(() => false)) {
await discardAllButton.click();
}

const saveTransientModal = page.getByTestId('save-transient-request-modal');
if (await saveTransientModal.isVisible({ timeout: 1000 }).catch(() => false)) {
await saveTransientModal.getByRole('button', { name: 'Cancel' }).click();
await expect(saveTransientModal).toBeHidden();
}
});
};

Expand Down
13 changes: 12 additions & 1 deletion tests/utils/page/locators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,20 @@ export const buildWebsocketCommonLocators = (page: Page) => ({
},
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'),
label: (index: number) => page.getByTestId(`ws-message-label-${index}`),
nameInput: (index: number) => page.getByTestId(`ws-message-name-input-${index}`),
nameTooltip: () => page.getByTestId('ws-message-name-tooltip')
nameTooltip: () => page.getByTestId('ws-message-name-tooltip'),
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' }),
Expand Down
50 changes: 32 additions & 18 deletions tests/websockets/message-body-default.spec.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
import { expect, test } from '../../playwright';
import { closeAllCollections } from '../utils/page/actions';

const REQ_NAME = /^ws-default-body-request$/;
import { closeAllTabs, createTransientRequest, selectRequestPaneTab } from '../utils/page/actions';
import { buildWebsocketCommonLocators } from '../utils/page/locators';

test.describe('websocket message default body', () => {
test.afterAll(async ({ pageWithUserData: page }) => {
await closeAllCollections(page);
test.afterEach(async ({ page }) => {
await closeAllTabs(page);
});

test('a newly added message defaults to an empty body showing the placeholder', async ({
pageWithUserData: page
page
}) => {
// Open the preloaded websocket request
await page.getByTestId('sidebar-collection-row').click();
await page.getByTitle(REQ_NAME).click();
const ws = buildWebsocketCommonLocators(page);

await createTransientRequest(page, { requestType: 'WebSocket' });
await selectRequestPaneTab(page, 'Message');

const headers = page.getByTestId(/^ws-message-header-/);
const beforeCount = await headers.count();
const beforeCount = await ws.message.headers().count();

await page.getByTestId('ws-add-message').click();
await expect(headers).toHaveCount(beforeCount + 1);
await ws.message.addButton().click();
await expect(ws.message.headers()).toHaveCount(beforeCount + 1);

// The newly added message is the last one and auto-expands.
const newBody = page.getByTestId(`ws-message-body-${beforeCount}`);
await expect(newBody).toBeVisible();
await expect(ws.message.body(beforeCount)).toBeVisible();

const editor = newBody.locator('.CodeMirror');
// Body should be empty (previously defaulted to '{}'); the editor should
// surface the '...' placeholder instead of any '{}' content.
await expect(editor.locator('.CodeMirror-placeholder')).toHaveText('...');
await expect(editor.locator('.CodeMirror-code')).not.toContainText('{}');
await expect(ws.message.editorPlaceholder(beforeCount)).toHaveText('...');
await expect(ws.message.editorCode(beforeCount)).not.toContainText('{}');
});

test('the default first message of a newly created websocket request has an empty body', async ({
page
}) => {
const ws = buildWebsocketCommonLocators(page);

await createTransientRequest(page, { requestType: 'WebSocket' });
await selectRequestPaneTab(page, 'Message');

// The default first message auto-expands.
await expect(ws.message.body(0)).toBeVisible();

// Body must be empty (previously defaulted to '{}'); the editor should surface
// the '...' placeholder rather than any '{}' content.
await expect(ws.message.editorPlaceholder(0)).toHaveText('...');
await expect(ws.message.editorCode(0)).not.toContainText('{}');
});
});
Loading