From 646510ebe93537d7448e3abd93f9caef016052ee Mon Sep 17 00:00:00 2001 From: Ahmed Darrazi Date: Sat, 10 Jan 2026 21:13:31 +0100 Subject: [PATCH] test: persist include_foundations false --- .../Inventory/InventorySyncButtonTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/Feature/Inventory/InventorySyncButtonTest.php b/tests/Feature/Inventory/InventorySyncButtonTest.php index 0369083..6e11ec1 100644 --- a/tests/Feature/Inventory/InventorySyncButtonTest.php +++ b/tests/Feature/Inventory/InventorySyncButtonTest.php @@ -120,6 +120,31 @@ expect((bool) ($run->selection_payload['include_foundations'] ?? false))->toBeTrue(); }); +it('persists include foundations toggle into the run selection payload', function () { + Queue::fake(); + + [$user, $tenant] = createUserWithTenant(role: 'owner'); + $this->actingAs($user); + + $tenant->makeCurrent(); + Filament::setTenant($tenant, true); + + $sync = app(InventorySyncService::class); + $allTypes = $sync->defaultSelectionPayload()['policy_types']; + $selectedTypes = array_slice($allTypes, 0, min(2, count($allTypes))); + + Livewire::test(InventoryLanding::class) + ->callAction('run_inventory_sync', data: [ + 'policy_types' => $selectedTypes, + 'include_foundations' => false, + ]) + ->assertHasNoActionErrors(); + + $run = InventorySyncRun::query()->where('tenant_id', $tenant->id)->latest('id')->first(); + expect($run)->not->toBeNull(); + expect((bool) ($run->selection_payload['include_foundations'] ?? true))->toBeFalse(); +}); + it('rejects cross-tenant initiation attempts (403) with no side effects', function () { Queue::fake();