actingAs($user); Filament::setTenant($tenant, true); $scopeKey = hash('sha256', 'scope-dispatch'); $baseline = InventorySyncRun::factory()->for($tenant)->create([ 'selection_hash' => $scopeKey, 'status' => InventorySyncRun::STATUS_SUCCESS, 'finished_at' => now()->subDays(2), ]); $current = InventorySyncRun::factory()->for($tenant)->create([ 'selection_hash' => $scopeKey, 'status' => InventorySyncRun::STATUS_SUCCESS, 'finished_at' => now()->subDay(), ]); Livewire::test(DriftLanding::class); Queue::assertPushed(GenerateDriftFindingsJob::class, function (GenerateDriftFindingsJob $job) use ($tenant, $user, $baseline, $current, $scopeKey): bool { return $job->tenantId === (int) $tenant->getKey() && $job->userId === (int) $user->getKey() && $job->baselineRunId === (int) $baseline->getKey() && $job->currentRunId === (int) $current->getKey() && $job->scopeKey === $scopeKey; }); }); test('opening Drift does not dispatch generation when fewer than two successful runs exist', function () { Queue::fake(); [$user, $tenant] = createUserWithTenant(role: 'manager'); $this->actingAs($user); Filament::setTenant($tenant, true); $scopeKey = hash('sha256', 'scope-blocked'); InventorySyncRun::factory()->for($tenant)->create([ 'selection_hash' => $scopeKey, 'status' => InventorySyncRun::STATUS_SUCCESS, 'finished_at' => now()->subDay(), ]); Livewire::test(DriftLanding::class); Queue::assertNothingPushed(); });