Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

1.0 KB
Raw Blame
<?php

use App\Livewire\SwitchTeam;
use App\Models\InstanceSettings;
use App\Models\Team;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;

uses(RefreshDatabase::class);

beforeEach(function () {
    InstanceSettings::forceCreate(['id' => 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();
});