TenantAtlas/apps/platform/tests/Unit/DirectoryGroups/EntraGroupLabelResolverTest.php
ahmido 3bbea1bd00 feat: productize restore wizard preview safety gates and process flow (#399)
## Summary
- productize the restore wizard preview safety gates and process-flow guidance for Spec 332
- add the restore create presenter plus new process-flow, proof, scope, and safety partials
- extend restore wizard feature, smoke, screenshot, and presenter coverage
- include the Spec 332 artifacts for spec, plan, and tasks

## Notes
- branch head was already pushed before PR creation
- working tree was clean when this PR was opened

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #399
2026-05-26 00:08:25 +00:00

51 lines
1.5 KiB
PHP

<?php
use App\Models\EntraGroup;
use App\Models\ManagedEnvironment;
use App\Services\Directory\EntraGroupLabelResolver;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('formats unknown labels using an ellipsis + last 8 chars', function () {
$id = '11111111-2222-3333-4444-555555555555';
expect(EntraGroupLabelResolver::formatLabel(null, $id))
->toBe('Unknown group (…55555555)');
});
it('resolves labels from the tenant cache (tenant-scoped)', function () {
$tenantA = ManagedEnvironment::factory()->create();
$tenantB = ManagedEnvironment::factory()->create();
$entraId = '11111111-2222-3333-4444-555555555555';
EntraGroup::factory()->create([
'managed_environment_id' => $tenantA->getKey(),
'entra_id' => $entraId,
'display_name' => 'Alpha Team',
]);
EntraGroup::factory()->create([
'managed_environment_id' => $tenantB->getKey(),
'entra_id' => $entraId,
'display_name' => 'Beta Team',
]);
$resolver = app(EntraGroupLabelResolver::class);
expect($resolver->resolveOne($tenantA, $entraId))
->toBe('Alpha Team (…55555555)')
->and($resolver->resolveOne($tenantB, $entraId))
->toBe('Beta Team (…55555555)');
});
it('returns a fallback without querying invalid UUIDs', function () {
$tenant = ManagedEnvironment::factory()->create();
$resolver = app(EntraGroupLabelResolver::class);
expect($resolver->resolveOne($tenant, 'group-123'))
->toBe('Unknown group (group123)');
});