- BackupWithAssignmentsTest: Added missing PolicySnapshotService mock for orphaned groups test
- BackupCreationTest: Added PolicySnapshotService mock with twice() expectation, added last_synced_at to test policies, fixed payload assertion (id instead of policyId)
- PolicyListingTest: Added last_synced_at to test policies
Root cause: Policies without last_synced_at within 7 days are filtered out by BackupItemsRelationManager (Feature 005 workaround for deleted policies)
All tests now passing: 155 passed ✅, 5 skipped
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
use App\Models\Policy;
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
|
|
uses(\Illuminate\Foundation\Testing\RefreshDatabase::class);
|
|
|
|
test('policies are listed for the active tenant', function () {
|
|
$tenant = Tenant::create([
|
|
'tenant_id' => env('INTUNE_TENANT_ID', 'local-tenant'),
|
|
'name' => 'Tenant One',
|
|
'metadata' => [],
|
|
]);
|
|
|
|
$tenant->makeCurrent();
|
|
|
|
Policy::create([
|
|
'tenant_id' => $tenant->id,
|
|
'external_id' => 'policy-1',
|
|
'policy_type' => 'deviceConfiguration',
|
|
'display_name' => 'Policy A',
|
|
'platform' => 'windows',
|
|
'last_synced_at' => now(),
|
|
]);
|
|
|
|
$otherTenant = Tenant::create([
|
|
'tenant_id' => 'tenant-2',
|
|
'name' => 'Tenant Two',
|
|
'metadata' => [],
|
|
]);
|
|
|
|
Policy::create([
|
|
'tenant_id' => $otherTenant->id,
|
|
'external_id' => 'policy-2',
|
|
'policy_type' => 'deviceConfiguration',
|
|
'display_name' => 'Policy B',
|
|
'platform' => 'windows',
|
|
'last_synced_at' => now(),
|
|
]);
|
|
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->get(route('filament.admin.resources.policies.index'))
|
|
->assertOk()
|
|
->assertSee('Policy A')
|
|
->assertDontSee('Policy B');
|
|
});
|