Skip to content

[Bug]: File attachment form submission stucks #1575

@thecodeholic

Description

@thecodeholic

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions