Skip to content

Commit

Permalink
Updated the frontend function to pass the param.
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinW committed Jan 30, 2025
1 parent 81584c6 commit 1043a13
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
9 changes: 6 additions & 3 deletions resources/js/render-exception.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// Thanks to Caleb Porzio and Jonathan Reinink
// Reference: https://github.com/livewire/livewire/blob/1.x/js/connection/drivers/http.js
export default {
retrieveLastError() {
retrieveLastError(clear = true) {
const url = `/api/visual-exceptions/latest?clear=${clear ? 'true' : 'false'}`;

// Adjust this to the url that is defined in your config
fetch('/api/visual-exceptions/latest', {
fetch(url, {
method: 'GET',
// This enables "cookies".
credentials: 'same-origin',
Expand All @@ -14,7 +15,9 @@ export default {
},
}).then(response => {
response.text().then(content => {
this.showHtmlModal(content);
if (content) {
this.showHtmlModal(content);
}
});
});
},
Expand Down
14 changes: 14 additions & 0 deletions tests/Feature/Http/Controllers/VisualExceptionControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,18 @@ public function test_it_can_delete_the_exception_file_after_returning_it_with_cl

Storage::assertMissing(config('visual-exceptions.storage'));
}

public function test_it_will_not_delete_the_exception_file_after_returning_it_without_clear_query_param()
{
Storage::fake('local');

Config::set('visual-exceptions.clear_on_retrieve', 'upon-request');

Storage::put(config('visual-exceptions.storage'), 'Test Exception Response');

$this->get('api/visual-exceptions/latest')->assertSuccessful()->assertSee('Test Exception Response');
$this->get('api/visual-exceptions/latest?clear=false')->assertSuccessful()->assertSee('Test Exception Response');

Storage::assertExists(config('visual-exceptions.storage'));
}
}

0 comments on commit 1043a13

Please sign in to comment.