-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: 3144 - Unable to Select Multiple Files for Upload in Multipart Form #7873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sharan-bruno
wants to merge
3
commits into
usebruno:main
Choose a base branch
from
sharan-bruno:fix/unable-to-select-multiple-files-for-upload-in-multipart-form
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
19c0f74
fix: 3144 - Unable to Select Multiple Files for Upload in Multipart Form
sharan-bruno ba32137
fix: restore original dialog behavior for file selection in multipart…
sharan-bruno 4440aa6
fix: enable selection of multiple files for upload in multipart form
sharan-bruno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
tests/request/multipart-form/multipart-form-multi-file-select.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| 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 - Multi-File Selection', () => { | ||
| let tmpDir: string; | ||
| let testFile1Path: string; | ||
| let testFile2Path: string; | ||
| let testFile3Path: string; | ||
|
|
||
| test.afterEach(async ({ electronApp }) => { | ||
| await electronApp.evaluate(({ dialog }) => { | ||
| if ((dialog as any).__originalShowOpenDialog) { | ||
| dialog.showOpenDialog = (dialog as any).__originalShowOpenDialog; | ||
| } | ||
| }); | ||
| }); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| test.afterAll(async ({ page }) => { | ||
| await closeAllCollections(page); | ||
| }); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| test.beforeAll(async ({ page, electronApp, createTmpDir }) => { | ||
| tmpDir = await createTmpDir('multipart-multi-file-select'); | ||
|
|
||
| testFile1Path = path.join(tmpDir, 'file1.txt'); | ||
| testFile2Path = path.join(tmpDir, 'file2.txt'); | ||
| testFile3Path = path.join(tmpDir, 'file3.pdf'); | ||
|
|
||
| await fs.promises.writeFile(testFile1Path, '1'); | ||
| await fs.promises.writeFile(testFile2Path, '2'); | ||
| await fs.promises.writeFile(testFile3Path, '3'); | ||
|
|
||
| await electronApp.evaluate(({ dialog }, filePaths: string[]) => { | ||
| (dialog as any).__originalShowOpenDialog = dialog.showOpenDialog; | ||
| dialog.showOpenDialog = async () => ({ | ||
| canceled: false, | ||
| filePaths | ||
| }); | ||
| }, [testFile1Path, testFile2Path, testFile3Path]); | ||
|
|
||
| await test.step('Create collection and request', async () => { | ||
| await createCollection(page, 'multipart-multi-file', tmpDir); | ||
| await createRequest(page, 'test-multi-file', 'multipart-multi-file', { | ||
| url: 'https://testbench-sanity.usebruno.com/api/echo/json', | ||
| method: 'POST', | ||
| inFolder: false | ||
| }); | ||
| }); | ||
|
|
||
| await test.step('Open request and set multipart', async () => { | ||
| await openCollection(page, 'multipart-multi-file'); | ||
| await openRequest(page, 'multipart-multi-file', 'test-multi-file', { persist: true }); | ||
|
|
||
| await selectRequestPaneTab(page, 'Body'); | ||
| const locators = buildCommonLocators(page); | ||
| await locators.request.bodyModeSelector().click(); | ||
| await page.locator('.dropdown-item').filter({ hasText: 'Multipart Form' }).click(); | ||
| }); | ||
| }); | ||
|
|
||
| test('should select multiple files', async ({ page }) => { | ||
| const table = buildCommonLocators(page).table('editable-table'); | ||
| const row = table.allRows().first(); | ||
|
|
||
| await test.step('Enter key and upload', async () => { | ||
| await row.locator('td').nth(1).locator('input').fill('attachments'); | ||
| await page.keyboard.press('Tab'); | ||
|
|
||
| const uploadBtn = row.locator('.upload-btn'); | ||
| await expect(uploadBtn).toBeVisible(); | ||
| await uploadBtn.click(); | ||
| }); | ||
|
|
||
| await test.step('Verify file count', async () => { | ||
| const fileCell = row.locator('.file-value-cell'); | ||
| await expect(fileCell).toContainText('3 file(s)'); | ||
| }); | ||
|
|
||
| await saveRequest(page); | ||
| }); | ||
|
|
||
| test('should show filename for single file', async ({ page, electronApp }) => { | ||
| const table = buildCommonLocators(page).table('editable-table'); | ||
| const row = table.allRows().last(); | ||
|
|
||
| await electronApp.evaluate(({ dialog }, filePath: string) => { | ||
| if ((dialog as any).__originalShowOpenDialog === undefined) { | ||
| (dialog as any).__originalShowOpenDialog = dialog.showOpenDialog; | ||
| } | ||
| dialog.showOpenDialog = async () => ({ | ||
| canceled: false, | ||
| filePaths: [filePath] | ||
| }); | ||
| }, testFile1Path); | ||
|
|
||
| await test.step('Upload single file', async () => { | ||
| await row.locator('td').nth(1).locator('input').fill('single'); | ||
| await page.keyboard.press('Tab'); | ||
|
|
||
| await row.locator('.upload-btn').click(); | ||
| }); | ||
|
|
||
| await test.step('Verify filename', async () => { | ||
| const fileCell = row.locator('.file-value-cell'); | ||
| await expect(fileCell).toContainText('file1.txt'); | ||
| }); | ||
|
|
||
| await saveRequest(page); | ||
| }); | ||
|
|
||
| test('should clear files', async ({ page }) => { | ||
| const table = buildCommonLocators(page).table('editable-table'); | ||
| const row = table.allRows().first(); | ||
|
|
||
| await test.step('Clear files', async () => { | ||
| const clearBtn = row.locator('.clear-file-btn'); | ||
| await expect(clearBtn).toBeVisible(); | ||
| await clearBtn.click(); | ||
| }); | ||
|
|
||
| await test.step('Verify cleared', async () => { | ||
| await expect(row.locator('.upload-btn')).toBeVisible(); | ||
| }); | ||
|
|
||
| await saveRequest(page); | ||
| }); | ||
| }); | ||
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may need to do the same in
ResponseExampleMultipartFormParamsfor consistency sakeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - Added — updated ResponseExampleMultipartFormParams to use browseFiles([], ['multiSelections']) for consistency.