create(); $workspace = Workspace::factory()->create(['slug' => 'acme']); WorkspaceMembership::factory()->create([ 'workspace_id' => $workspace->getKey(), 'user_id' => $user->getKey(), 'role' => 'owner', ]); $this->actingAs($user) ->withSession([WorkspaceContext::SESSION_KEY => (int) $workspace->getKey()]) ->get('/admin/workspaces') ->assertOk(); }); it('serves the Workspaces view page tenantless at /admin/workspaces/{record}', function (): void { $user = User::factory()->create(); $workspace = Workspace::factory()->create(['slug' => 'acme']); WorkspaceMembership::factory()->create([ 'workspace_id' => $workspace->getKey(), 'user_id' => $user->getKey(), 'role' => 'owner', ]); $this->actingAs($user) ->withSession([WorkspaceContext::SESSION_KEY => (int) $workspace->getKey()]) ->get('/admin/workspaces/'.(int) $workspace->getKey()) ->assertOk(); }); it('does not expose the Workspaces UI under the tenant route prefix', function (): void { $user = User::factory()->create(); $workspace = Workspace::factory()->create(['slug' => 'acme']); WorkspaceMembership::factory()->create([ 'workspace_id' => $workspace->getKey(), 'user_id' => $user->getKey(), 'role' => 'owner', ]); $tenant = Tenant::factory()->create([ 'workspace_id' => (int) $workspace->getKey(), 'external_id' => '11111111-1111-1111-1111-111111111111', 'tenant_id' => '11111111-1111-1111-1111-111111111111', ]); $user->tenants()->syncWithoutDetaching([ $tenant->getKey() => ['role' => 'owner'], ]); $this->actingAs($user) ->withSession([WorkspaceContext::SESSION_KEY => (int) $workspace->getKey()]) ->get('/admin/t/11111111-1111-1111-1111-111111111111/workspaces') ->assertNotFound(); });