## Summary - consolidate internal platform naming from `Tenant` to `Environment` / `ManagedEnvironment` across models, controllers, services, and Filament resources - rename environment-scoped UI surfaces such as dashboards, chooser flows, navigation, and related widgets to match the updated environment-first domain language - align middleware, onboarding/review lifecycle services, jobs, and route/context controllers with the new environment-scoped architecture ## Validation - not rerun as part of this commit/push/PR request ## Notes - branch is 1 commit ahead of `platform-dev` - main commit: `refactor: consolidate internal tenant model naming` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #355
46 lines
1.4 KiB
PHP
46 lines
1.4 KiB
PHP
<?php
|
|
|
|
use App\Filament\Pages\ChooseEnvironment;
|
|
use App\Filament\Pages\EnvironmentDashboard;
|
|
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(ChooseEnvironment::class)
|
|
->call('selectEnvironment', $second->getKey())
|
|
->assertRedirect(EnvironmentDashboard::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();
|
|
});
|