instance(); if ($instance->getCachedHeaderActions() === []) { $instance->cacheInteractsWithHeaderActions(); } return $instance->getCachedHeaderActions(); } function tenantReviewHeaderPrimaryNames(Testable $component): array { return collect(tenantReviewHeaderActions($component)) ->reject(static fn ($action): bool => $action instanceof ActionGroup) ->map(static fn ($action): ?string => $action instanceof Action ? $action->getName() : null) ->filter() ->values() ->all(); } function tenantReviewHeaderGroupLabels(Testable $component): array { return collect(tenantReviewHeaderActions($component)) ->filter(static fn ($action): bool => $action instanceof ActionGroup) ->map(static fn (ActionGroup $action): string => (string) $action->getLabel()) ->values() ->all(); } it('keeps ready reviews to one primary action and renders related navigation in the summary context', function (): void { [$user, $tenant] = createUserWithTenant(role: 'owner'); $review = composeTenantReviewForTest($tenant, $user); setTenantPanelContext($tenant); $component = Livewire::actingAs($user) ->test(ViewTenantReview::class, ['record' => $review->getKey()]) ->assertSee('Related context') ->assertSee('Evidence snapshot'); expect(tenantReviewHeaderPrimaryNames($component))->toBe(['publish_review']) ->and(tenantReviewHeaderGroupLabels($component))->toBe(['More', 'Danger']); }); it('promotes executive-pack export as the only visible primary action after publication', function (): void { [$user, $tenant] = createUserWithTenant(role: 'owner'); $review = composeTenantReviewForTest($tenant, $user); $review->forceFill([ 'status' => TenantReviewStatus::Published->value, 'published_at' => now(), 'published_by_user_id' => (int) $user->getKey(), ])->save(); setTenantPanelContext($tenant); $component = Livewire::actingAs($user) ->test(ViewTenantReview::class, ['record' => $review->getKey()]) ->assertActionVisible('export_executive_pack') ->assertActionEnabled('export_executive_pack'); expect(tenantReviewHeaderPrimaryNames($component))->toBe(['export_executive_pack']) ->and(tenantReviewHeaderGroupLabels($component))->toContain('More') ->and(tenantReviewHeaderPrimaryNames($component))->not->toContain('refresh_review', 'publish_review'); });