fix: copy response based on preview toggle and selected format (#6436)

This commit is contained in:
Pooja
2025-12-22 13:53:08 +05:30
committed by GitHub
parent 9967d863f5
commit 669c99f40a
4 changed files with 69 additions and 18 deletions

View File

@@ -4,9 +4,10 @@ import {
closeAllCollections,
createCollection,
createRequest,
sendRequest
sendRequest,
switchResponseFormat,
switchToEditorTab
} from '../utils/page/actions';
import { buildCommonLocators } from '../utils/page/locators';
test.describe('Response Pane Actions', () => {
test.afterAll(async ({ page }) => {
@@ -15,7 +16,6 @@ test.describe('Response Pane Actions', () => {
test('should copy response to clipboard', async ({ page, createTmpDir }) => {
const collectionName = 'response-copy-test';
const locators = buildCommonLocators(page);
await test.step('Create collection and request', async () => {
await createCollection(page, collectionName, await createTmpDir(collectionName));
@@ -31,4 +31,33 @@ test.describe('Response Pane Actions', () => {
await expect(page.getByText('Response copied to clipboard')).toBeVisible();
});
});
test('should copy Base64 when editor mode and Base64 format selected', async ({ page, createTmpDir }) => {
const collectionName = 'response-copy-base64-test';
await test.step('Create collection and request', async () => {
await createCollection(page, collectionName, await createTmpDir(collectionName));
await createRequest(page, 'base64-copy-test', collectionName, {
url: 'https://testbench-sanity.usebruno.com/ping'
});
});
await test.step('Send request and wait for response', async () => {
await sendRequest(page, 200);
});
await test.step('Switch to Base64 format (editor mode - preview OFF)', async () => {
await switchToEditorTab(page);
await switchResponseFormat(page, 'Base64');
});
await test.step('Copy response and verify clipboard contains Base64', async () => {
await clickResponseAction(page, 'response-copy-btn');
await expect(page.getByText('Response copied to clipboard')).toBeVisible();
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
// "pong" in Base64 is "cG9uZw=="
expect(clipboardText).toBe('cG9uZw==');
});
});
});