40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Models\User;
|
|
use App\Models\Workspace;
|
|
use App\Models\WorkspaceMembership;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Filament\Facades\Filament;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('shows "Switch workspace" navigation when no tenant is selected', function (): void {
|
|
$user = User::factory()->create();
|
|
|
|
$workspace = Workspace::factory()->create();
|
|
WorkspaceMembership::factory()->create([
|
|
'workspace_id' => $workspace->getKey(),
|
|
'user_id' => $user->getKey(),
|
|
'role' => 'owner',
|
|
]);
|
|
|
|
Filament::setTenant(null, true);
|
|
|
|
$this->actingAs($user)
|
|
->withSession([WorkspaceContext::SESSION_KEY => (int) $workspace->getKey()])
|
|
->get('/admin/operations')
|
|
->assertOk();
|
|
|
|
$panel = Filament::getCurrentOrDefaultPanel();
|
|
|
|
$labels = collect($panel->getNavigationItems())
|
|
->map(static fn ($item): string => $item->getLabel())
|
|
->all();
|
|
|
|
expect($labels)->toContain('Switch workspace');
|
|
expect($labels)->not->toContain('Workspaces');
|
|
});
|