0]); $this->user = User::factory()->create(); $this->currentTeam = $this->user->teams()->first(); $this->otherTeam = Team::factory()->create(); $this->otherTeam->members()->attach($this->user->id, ['role' => 'owner']); $this->actingAs($this->user); session(['currentTeam' => $this->currentTeam]); }); test('switching teams always redirects to the dashboard', function () { $currentUrl = route('security.api-tokens', ['page' => 2]); Livewire::test(SwitchTeam::class) ->assertDontSee('window.location.href', false) ->call('switch_to', $this->otherTeam->id, $currentUrl) ->assertRedirect(route('dashboard')); expect(session('currentTeam')->is($this->otherTeam))->toBeTrue(); });