mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 14:35:03 +00:00
added copy button to copy response (#6131)
* added copy button to copy response * add: response action component * fix: lint error * add: playwright test --------- Co-authored-by: Shashank Shekhar <48152748+sha5-git@users.noreply.github.com> Co-authored-by: Sid <siddharth@usebruno.com>
This commit is contained in:
51
tests/response/response-actions.spec.ts
Normal file
51
tests/response/response-actions.spec.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { test, expect } from '../../playwright';
|
||||
import { closeAllCollections, createCollection } from '../utils/page/actions';
|
||||
|
||||
test.describe('Response Pane Actions', () => {
|
||||
test.afterAll(async ({ page }) => {
|
||||
// cleanup: close all collections
|
||||
await closeAllCollections(page);
|
||||
});
|
||||
|
||||
test('should copy response to clipboard', async ({ page, createTmpDir }) => {
|
||||
const collectionName = 'response-copy-test';
|
||||
|
||||
await test.step('Create collection and request', async () => {
|
||||
// Create collection
|
||||
await createCollection(page, collectionName, await createTmpDir(collectionName), { openWithSandboxMode: 'safe' });
|
||||
|
||||
// Create request
|
||||
const collection = page.locator('.collection-name').filter({ hasText: collectionName });
|
||||
await collection.locator('.collection-actions').hover();
|
||||
await collection.locator('.collection-actions .icon').click();
|
||||
await page.locator('.dropdown-item').filter({ hasText: 'New Request' }).click();
|
||||
|
||||
await page.getByPlaceholder('Request Name').fill('copy-test');
|
||||
await page.locator('#new-request-url .CodeMirror').click();
|
||||
// Using httpbin.org for a simple JSON response
|
||||
await page.locator('textarea').fill('https://httpbin.org/json');
|
||||
await page.getByRole('button', { name: 'Create' }).click();
|
||||
});
|
||||
|
||||
await test.step('Send request and wait for response', async () => {
|
||||
// Send request
|
||||
const sendButton = page.getByTestId('send-arrow-icon');
|
||||
await sendButton.click();
|
||||
|
||||
// Wait for response
|
||||
await expect(page.getByTestId('response-status-code')).toContainText('200', { timeout: 30000 });
|
||||
});
|
||||
|
||||
await test.step('should copy response to clipboard', async () => {
|
||||
// Find the copy button
|
||||
const copyButton = page.locator('button[title="Copy response to clipboard"]');
|
||||
await expect(copyButton).toBeVisible();
|
||||
|
||||
// Click the copy button
|
||||
await copyButton.click();
|
||||
|
||||
// Verify toast notification appears
|
||||
await expect(page.getByText('Response copied to clipboard')).toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user