51 lines
2.3 KiB
PHP
51 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Pages\EnvironmentDashboard;
|
|
use App\Models\ManagedEnvironment;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('shows an explicit workspace scope indicator in the sidebar on workspace-owned pages', function (): void {
|
|
$environment = ManagedEnvironment::factory()->active()->create(['name' => 'Spec338 Sidebar Workspace Environment']);
|
|
[$user, $environment] = createUserWithTenant(tenant: $environment, role: 'owner', workspaceRole: 'owner');
|
|
|
|
$workspace = $environment->workspace()->firstOrFail();
|
|
|
|
ManagedEnvironment::factory()->active()->create([
|
|
'name' => 'Spec338 Sidebar Inaccessible Environment',
|
|
'workspace_id' => (int) $workspace->getKey(),
|
|
]);
|
|
|
|
$accessibleEnvironmentCount = 1;
|
|
|
|
$this->actingAs($user)
|
|
->withSession([WorkspaceContext::SESSION_KEY => (int) $workspace->getKey()])
|
|
->get(route('admin.workspace.home', ['workspace' => $workspace]))
|
|
->assertOk()
|
|
->assertSee('data-testid="admin-sidebar-scope-indicator"', false)
|
|
->assertSee(__('localization.shell.workspace_scope_short'))
|
|
->assertSee($workspace->name)
|
|
->assertSee(trans_choice('localization.shell.environment_count', $accessibleEnvironmentCount, ['count' => $accessibleEnvironmentCount]))
|
|
->assertDontSee(trans_choice('localization.shell.environment_count', 2, ['count' => 2]));
|
|
});
|
|
|
|
it('shows an explicit environment scope indicator in the sidebar on environment-owned pages', function (): void {
|
|
$environment = ManagedEnvironment::factory()->active()->create(['name' => 'Spec338 Sidebar Environment']);
|
|
[$user, $environment] = createUserWithTenant(tenant: $environment, role: 'owner', workspaceRole: 'owner');
|
|
|
|
$workspace = $environment->workspace()->firstOrFail();
|
|
|
|
$this->actingAs($user)
|
|
->withSession([WorkspaceContext::SESSION_KEY => (int) $workspace->getKey()])
|
|
->get(EnvironmentDashboard::getUrl(panel: 'admin', tenant: $environment))
|
|
->assertOk()
|
|
->assertSee('data-testid="admin-sidebar-scope-indicator"', false)
|
|
->assertSee(__('localization.shell.environment_scope_short'))
|
|
->assertSee($environment->name)
|
|
->assertSee(__('localization.shell.workspace_context_label', ['workspace' => $workspace->name]));
|
|
});
|