In Laravel Dusk, I want to click a button on a web page that runs Javascript that triggers a download of a PDF file. How can I run a "click" on a button and then assert that a file is getting downloaded?
In Laravel Dusk, I want to click a button on a web page that runs Javascript that triggers a download of a PDF file. How can I run a "click" on a button and then assert that a file is getting downloaded?
Please check this link: https://laracasts.com/discuss/channels/testing/testing-file-download-with-dusk
Summary:
$response = $this->actingAs($user)->get(route('export.report'));
$response->assertStatus(200);
$response->assertHeader('content-disposition', 'attachment; filename="report.csv"');
$file = $response->getFile();
$filename = $file->getPathname();