pest icon indicating copy to clipboard operation
pest copied to clipboard

[Bug]: File attachment form submission stucks

Open thecodeholic opened this issue 1 month ago • 1 comments

What Happened

Testing form which has `enctype="multipart-formdata", attaching file and pressing submit freezes form submission.

Expected Behavior

  1. Attach a file to an input
  2. Submit the form
  3. Submission should happend

What happened

  1. Attached a file to an input
  2. Called ->press('Submit')
  3. Test freezes. The request inside chromium browser in stuck in pending state.

How to Reproduce

1. Create new Laravel project with blade starter kit

2. Install pest browser plugin

composer require pestphp/pest-plugin-browser --dev
 
npm install playwright@latest
npx playwright install

3. Create these routes

Route::get('/create', function () {
    return view('create');
})->name('create');

Route::post('/create', function () {
    return redirect('/');
})->name('submit');

4. Create create.blade.php file with this form

<form action="{{ route('create') }}"
      method="post"
      enctype="multipart/form-data">
    @csrf
    <input type="file" name="image">

    <button>Submit</button>
</form>

5. Create a feature test which uses browser testing

test('File upload works', function () {
    visit('/create')
        ->attach('image', realpath(__DIR__ . '/../pest4.png'))
        ->press('Submit')
        ->assertPathIs('/')
        ->assertSee('Let\'s get started')
    ;
});

The test freezes on ->press('Submit') step.

Sample Repository

No response

Pest Version

v4.1.4

PHP Version

8.4

Operation System

Windows, Linux

Notes

No response

thecodeholic avatar Nov 20 '25 10:11 thecodeholic

+1

EdgarsK avatar Dec 06 '25 09:12 EdgarsK