Files
bruno/tests/request/multipart-form/multipart-form-file-select.spec.ts
Sid 0bba66a590 feat: variable descriptions (#8269)
* feat: add description column to various tables and enhance UI interactions
- Introduced a description column in Headers, VarsTable, and other components to allow multi-line descriptions.
- Added toggle buttons to show/hide the description column in relevant tables.
- Updated EditableTable component to support dynamic row addition with customizable labels.
- Enhanced UI for better user experience with consistent button styles and spacing adjustments.

* chore: resize fix handles

* fix: restrict column check for last index

* refactor: remove unwanted style and fix bottom padding of the last child in the table row

* tests: improve testability and fix impacted locators

* tests: fix locators for value fields

* fix: improve newline handling in description prefix

* fix: ts changes

* chore: remove redundant code and fix description roundtrip

* chore: remove redundant check

* tests(bru-lang): tests for description and annotation

* test: improve locators and tests

* tests: descriptions

* chore: re-add description setup

* fix: re-add description cols

* chore: fix the double click reset

* fix: account for hidden sidebar in request pane width calculation

* refactor: ui/ux fixes for data type toggle

* chore: inline common deps into bruno-lang and bruno-schema

* chore: tests

* chore: fix ux for descriptions

* fix: layout for environment vars table

* fix: ensure correct row selection for multipart file upload in tests

* feat: enhance UID assignment for request headers and variables in collections

* chore: simplify

* chore: update pkg

* chore: abstract the e2e utils

* chore: fix exports

* tests: fix locators for datatype vars

* fix: ux issue with secrets in environment table

* tests: update locators for collection headers and vars descriptions

* tests: update locators to use data attributes for datatype selectors

* chore: update default css width for actions column

* chore: remove tooltip for string type warnings

* fix: reduce name widths

* refactor: update annotation serialization to use single-quote delimiters for descriptions

* refactor(tests): simplify description formatting in jsonToEnv tests

* feat: add multiline description escaping and unescaping functions with tests

* refactor: clean up imports and improve multiline text block handling

* refactor: update locators to use new test IDs for environment variable editors

* refactor: streamline header input handling and improve environment variable row access

* refactor: update e2e-test job to support self-hosted runners

* refactor: update E2E test runner configuration to include e2e and macOS environments

---------

Co-authored-by: Pragadesh-45 <temporaryg7904@gmail.com>
2026-07-07 21:43:39 +05:30

91 lines
3.5 KiB
TypeScript

import { test, expect } from '../../../playwright';
import { closeAllCollections, createCollection, createRequest, openCollection, openRequest, saveRequest, selectRequestPaneTab } from '../../utils/page';
import { buildCommonLocators } from '../../utils/page/locators';
import * as fs from 'fs';
import * as path from 'path';
test.describe.serial('Multipart Form - File Select Without Key', () => {
let tmpDir: string;
let testFilePath: string;
test.afterAll(async ({ page, electronApp }) => {
await electronApp.evaluate(({ dialog }) => {
if ((dialog as any).__originalShowOpenDialog) {
dialog.showOpenDialog = (dialog as any).__originalShowOpenDialog;
delete (dialog as any).__originalShowOpenDialog;
}
});
await closeAllCollections(page);
});
test.beforeAll(async ({ page, electronApp, createTmpDir }) => {
tmpDir = await createTmpDir('multipart-file-select');
// Create a temp file that the mocked dialog will "select"
testFilePath = path.join(tmpDir, 'test-file.txt');
await fs.promises.writeFile(testFilePath, 'hello world');
expect(fs.existsSync(testFilePath)).toBe(true);
await electronApp.evaluate(({ dialog }, filePath: string) => {
(dialog as any).__originalShowOpenDialog = dialog.showOpenDialog;
dialog.showOpenDialog = async () => ({
canceled: false,
filePaths: [filePath]
});
}, testFilePath);
await test.step('Create collection and request', async () => {
await createCollection(page, 'multipart-file-select', tmpDir);
await createRequest(page, 'test-file-select', '', {
url: 'https://testbench-sanity.usebruno.com/api/echo/json',
method: 'POST',
inFolder: false
});
});
await test.step('Open the request', async () => {
await openCollection(page, 'multipart-file-select');
await openRequest(page, 'multipart-file-select', 'test-file-select', { persist: true });
});
await test.step('Switch body mode to Multipart Form', async () => {
await selectRequestPaneTab(page, 'Body');
const locators = buildCommonLocators(page);
await locators.request.bodyModeSelector().click();
await page.locator('.dropdown-item').filter({ hasText: 'Multipart Form' }).click();
});
});
test('file select should work on empty row without a key', async ({ page }) => {
const table = buildCommonLocators(page).table('multipart-form-table');
await test.step('Click upload on empty last row (no key entered)', async () => {
const lastRow = table.allRows().last();
const uploadBtn = lastRow.getByTestId('multipart-file-upload');
await expect(uploadBtn).toBeVisible();
await uploadBtn.click();
});
await test.step('Verify the file name appears in the row', async () => {
const fileCell = table.allRows().locator('.file-value-cell').first();
await expect(fileCell).toBeVisible();
const inlineChip = fileCell.getByTestId('multipart-file-chip');
const summary = fileCell.getByTestId('multipart-file-summary');
if (await inlineChip.count() > 0) {
await expect(inlineChip.first()).toContainText('test-file.txt');
} else {
await expect(summary).toBeVisible();
await summary.click();
const overflowRow = page.getByTestId('multipart-file-overflow-row').first();
await expect(overflowRow).toBeVisible();
await expect(overflowRow).toContainText('test-file.txt');
await summary.click();
}
});
// Save the request to clear draft state
await saveRequest(page);
});
});