-
Notifications
You must be signed in to change notification settings - Fork 824
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
Check for session before attempting to invalidate #750
Conversation
I'm a little late to the party, but this may have code that @calebporzio does not recommend. I just updated my composer dependencies and I now get an error when running Jetstream's
It seems like it's related to this: livewire/livewire#936 I'm running So...sorry for any alarm, but I thought I might raise the issue and see if the experts can better determine whether or not there's any reason to make any changes. Thanks for your time/patience. 🤓 |
@telkins thanks for sharing that issue! There may be something that needs to be fixed in For the time being if you want to stop the spam coming from your CI, you can upgrade Jetstream to |
I just ran into the exact same error you're describing. Replacing |
I'm sorry but I fail to understand why Livewire would cause issues here? |
Hi @driesvints 😄 I'm not sure that it has anything to do with livewire, exactly, but my tests are failing when running the following Jetstream/livewire test ( public function test_user_accounts_can_be_deleted()
{
if (! Features::hasAccountDeletionFeatures()) {
return $this->markTestSkipped('Account deletion is not enabled.');
}
$this->actingAs($user = User::factory()->create());
$component = Livewire::test(DeleteUserForm::class)
->set('password', 'password')
->call('deleteUser');
$this->assertNull($user->fresh());
} When trying to figure out what the problem might be, I came across the livewire issue, livewire/livewire#936, and followed @calebporzio 's advice (changing to That's the connection. Whether it has anything to do with livewire...I don't know. But, I thought I'd bring it up here to see what The Experts™️ had to say about it. My test is now failing and one person has suggested that it's better to use Also, @inmanturbo 's PR might make it all moot. I don't know. But, hopefully you and some of the others who have a better understanding of everything can figure out if there's even a cause for concern in the first place. If so, then maybe it's a livewire issue, maybe it's not...but we can cross that bridge if/when we get there. 🤓 |
@driesvints Just to save you a bit of time, here's the "money quote" from Caleb in the aforementioned Livewire issue:
He doesn't say that |
Ah yeah, this PR exactly fixes that. I think Caleb is talking about a personal preference though. |
Well, for me, Fwiw, I'm 100% with you that it's better "to rely on state passed down through DI instead of accessing it globally"....but these two options aren't the same for some reason, otherwise, we'd get the same results when running the test. 😕 Anyway...again, if the condition, |
@telkins I was maybe trying too hard to be helpful with the second PR. I agree that DI can be better; it is certainly easier (for me) to navigate during development. And yeah |
This is my first PR to a Laravel repo so please let me know if I'm doing anything incorrectly here.
All this pull request is doing is ensuring there is a session (with a single
if
statement) before attempting to destroy it insrc/Http/Livewire/DeleteUserForm.php
.Previously either of these two lines would break the TestableLivewire in stubs/test/livewire/DeleteAccountTest.php:24
This change will keep it from breaking tests in downstream apps that have had Jetstream installed with
php artisan jetstream:install livewire
.This only affect cases where there is no
$request->session()
toinvalidate()
.Since we are simply skipping two lines of code run when there isn't a session, and doing nothing else differently when there is, this should not affect anything anywhere else, nor will it break anything.
This would close the issue I opened here:
#749