mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-07 14:08:38 +00:00
@@ -1,50 +1,33 @@
|
||||
import { test, expect } from '../../playwright';
|
||||
import { closeAllCollections, createCollection } from '../utils/page/actions';
|
||||
import {
|
||||
closeAllCollections,
|
||||
createCollection,
|
||||
createRequest,
|
||||
sendRequest
|
||||
} from '../utils/page/actions';
|
||||
import { buildCommonLocators } from '../utils/page/locators';
|
||||
|
||||
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';
|
||||
const locators = buildCommonLocators(page);
|
||||
|
||||
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://www.httpfaker.org/api/random/json?size=1kb');
|
||||
await page.getByRole('button', { name: 'Create' }).click();
|
||||
await createRequest(page, 'copy-test', collectionName, { url: 'https://httpbin.org/json' });
|
||||
});
|
||||
|
||||
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 sendRequest(page, 200);
|
||||
});
|
||||
|
||||
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 test.step('Copy response to clipboard', async () => {
|
||||
await expect(locators.response.copyButton()).toBeVisible();
|
||||
await locators.response.copyButton().click();
|
||||
await expect(page.getByText('Response copied to clipboard')).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user