create(); $tenant->makeCurrent(); $user = User::factory()->create(); $backupSet = BackupSet::factory()->create([ 'tenant_id' => $tenant->id, 'name' => 'Test backup', ]); $policies = Policy::factory()->count(2)->create([ 'tenant_id' => $tenant->id, 'ignored_at' => null, 'last_synced_at' => now(), ]); $this->mock(BackupService::class, function (MockInterface $mock) use ($tenant, $backupSet, $policies, $user) { $mock->shouldReceive('addPoliciesToSet') ->once() ->withArgs(function ($tenantArg, $backupSetArg, $policyIds, $actorEmail, $actorName, $includeAssignments, $includeScopeTags, $includeFoundations) use ($tenant, $backupSet, $policies, $user) { expect($tenantArg->id)->toBe($tenant->id); expect($backupSetArg->id)->toBe($backupSet->id); expect($policyIds)->toBe($policies->pluck('id')->all()); expect($actorEmail)->toBe($user->email); expect($actorName)->toBe($user->name); expect($includeAssignments)->toBeTrue(); expect($includeScopeTags)->toBeTrue(); expect($includeFoundations)->toBeTrue(); return true; }); }); Livewire::actingAs($user) ->test(BackupSetPolicyPickerTable::class, [ 'backupSetId' => $backupSet->id, ]) ->callTableBulkAction('add_selected_to_backup_set', $policies) ->assertHasNoTableBulkActionErrors(); }); test('policy picker table can filter by has versions', function () { $tenant = Tenant::factory()->create(); $tenant->makeCurrent(); $user = User::factory()->create(); $backupSet = BackupSet::factory()->create([ 'tenant_id' => $tenant->id, 'name' => 'Test backup', ]); $withVersions = Policy::factory()->create([ 'tenant_id' => $tenant->id, 'display_name' => 'With Versions', 'ignored_at' => null, 'last_synced_at' => now(), ]); PolicyVersion::factory()->create([ 'tenant_id' => $tenant->id, 'policy_id' => $withVersions->id, 'policy_type' => $withVersions->policy_type, 'platform' => $withVersions->platform, ]); $withoutVersions = Policy::factory()->create([ 'tenant_id' => $tenant->id, 'display_name' => 'Without Versions', 'ignored_at' => null, 'last_synced_at' => now(), ]); Livewire::actingAs($user) ->test(BackupSetPolicyPickerTable::class, [ 'backupSetId' => $backupSet->id, ]) ->filterTable('has_versions', '1') ->assertSee('With Versions') ->assertDontSee('Without Versions'); });