makeCrossTenantCompareFixture(); $this->createPortfolioCompareSubject( tenant: $fixture['sourceTenant'], displayName: 'Run UX Policy', snapshot: ['settings' => [['key' => 'ux', 'value' => 1]]], ); $this->setAdminWorkspaceContext($fixture['user'], $fixture['workspace']); $query = [ 'source_tenant_id' => (int) $fixture['sourceTenant']->getKey(), 'target_tenant_id' => (int) $fixture['targetTenant']->getKey(), 'policy_type' => ['deviceConfiguration'], ]; $component = Livewire::withQueryParams($query) ->actingAs($fixture['user']) ->test(CrossTenantComparePage::class) ->call('generatePromotionPreflight') ->mountAction('executePromotion') ->callMountedAction() ->assertHasNoActionErrors() ->assertNotified('Promotion execution queued'); $run = OperationRun::query()->latest('id')->first(); expect($run)->not->toBeNull() ->and($run?->type)->toBe('promotion.execute') ->and(data_get($run?->context, 'required_capability'))->toBe('tenant.manage') ->and(data_get($run?->context, 'workspace_required_capability'))->toBe('workspace_baselines.manage') ->and(data_get($run?->context, 'target_scope.workspace_id'))->toBe((int) $fixture['workspace']->getKey()) ->and(data_get($run?->context, 'selection.sourceTenantId'))->toBe((int) $fixture['sourceTenant']->getKey()) ->and(data_get($run?->context, 'selection.targetTenantId'))->toBe((int) $fixture['targetTenant']->getKey()); $component ->mountAction('executePromotion') ->callMountedAction() ->assertHasNoActionErrors() ->assertNotified('Promotion execution already running'); expect(OperationRun::query()->where('type', 'promotion.execute')->count())->toBe(1); Queue::assertPushed(CrossTenantPromotionExecutionJob::class, 1); $this->actingAs($fixture['user']) ->withSession([WorkspaceContext::SESSION_KEY => (int) $fixture['workspace']->getKey()]) ->get(OperationRunLinks::tenantlessView($run)) ->assertOk(); });