TenantAtlas/apps/platform/tests/Feature/Filament/TenantMakeCurrentTest.php
ahmido 38523814c2 fix: restore full-suite green signals across platform workflows (#351)
## Summary
- restore broad full-suite green-signal coverage across platform governance, operations, onboarding, dashboard/productization, and customer review flows
- align related platform tests and supporting behavior with the current expected state for this restoration pass
- update the spec-candidates queue as part of the same suite-restoration sweep

## Validation
- `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Browser/Dashboard/TenantDashboardProductizationSmokeTest.php tests/Browser/Reviews/CustomerReviewWorkspaceSmokeTest.php tests/Browser/Spec194GovernanceFrictionSmokeTest.php tests/Browser/Spec265DecisionRegisterSmokeTest.php`

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #351
2026-05-12 18:50:40 +00:00

46 lines
1.4 KiB
PHP

<?php
use App\Filament\Pages\ChooseTenant;
use App\Filament\Pages\TenantDashboard;
use App\Models\ManagedEnvironment;
use App\Models\User;
use App\Models\UserTenantPreference;
use App\Support\Workspaces\WorkspaceContext;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
uses(RefreshDatabase::class);
test('choosing a tenant persists last used tenant preference', function () {
$first = ManagedEnvironment::factory()->create([
'status' => 'active',
]);
$second = ManagedEnvironment::factory()->create([
'workspace_id' => (int) $first->workspace_id,
'status' => 'active',
]);
$user = User::factory()->create();
$this->actingAs($user);
createUserWithTenant(tenant: $first, user: $user, role: 'owner');
createUserWithTenant(tenant: $second, user: $user, role: 'owner');
setAdminPanelContext($first);
session()->put(WorkspaceContext::SESSION_KEY, (int) $first->workspace_id);
Livewire::test(ChooseTenant::class)
->call('selectTenant', $second->getKey())
->assertRedirect(TenantDashboard::getUrl(panel: 'admin', tenant: $second));
$preference = UserTenantPreference::query()
->where('user_id', $user->getKey())
->where('managed_environment_id', $second->getKey())
->first();
expect($preference)->not->toBeNull();
expect($preference?->last_used_at)->not->toBeNull();
});