Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Cover AI chat fixture abort path and licence presentation fallbacks
rcourtmane8bf181a5779
diff --git a/frontend-modern/src/api/__tests__/aiChatDevStreamFixture.branchcov0723pm.test.ts b/frontend-modern/src/api/__tests__/aiChatDevStreamFixture.branchcov0723pm.test.tsnew file mode 100644index 0000000000..87c4563f1a--- /dev/null+++ b/frontend-modern/src/api/__tests__/aiChatDevStreamFixture.branchcov0723pm.test.ts@@ -0,0 +1,297 @@+import { afterEach, describe, expect, it, vi } from 'vitest';+import {+ maybeRunAIChatDevStreamFixture,+ type AIChatDevStreamFixtureOptions,+} from '@/api/aiChatDevStreamFixture';+import type { AIChatStreamEvent } from '@/api/generated/aiChatEvents';++const flushMicrotasks = async () => {+ for (let attempt = 0; attempt < 20; attempt += 1) {+ await Promise.resolve();+ }+};++const STEP_DELAY_MS = 20;++type TimelineEntry = {+ ms: number;+ type: string;+ phase?: string;+};++const workflowPhase = (event: AIChatStreamEvent): string | undefined =>+ event.type === 'workflow_state' ? (event.data as { phase?: string }).phase : undefined;++const collectPacedTimeline = async (prompt: string, model?: string): Promise<TimelineEntry[]> => {+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });+ const timeline: TimelineEntry[] = [];+ let elapsedMs = 0;+ const options: AIChatDevStreamFixtureOptions = {+ prompt,+ model,+ stepDelayMs: STEP_DELAY_MS,+ onEvent: (event) => {+ timeline.push({ ms: elapsedMs, type: event.type, phase: workflowPhase(event) });+ },+ };++ const streamPromise = maybeRunAIChatDevStreamFixture(options);+ await flushMicrotasks();++ // Advance the fake clock 1ms at a time so each recorded ms-offset reflects the+ // exact hold delay applied after the preceding event. Increment before+ // advancing so the offset is correct at the moment the timer callback fires.+ let guard = 0;+ while (vi.getTimerCount() > 0 && guard < 20000) {+ guard += 1;+ elapsedMs += 1;+ await vi.advanceTimersByTimeAsync(1);+ }++ await expect(streamPromise).resolves.toBe(true);+ return timeline;+};++const gapAfterFirstMatching = (+ timeline: TimelineEntry[],+ predicate: (entry: TimelineEntry) => boolean,+): number => {+ const index = timeline.findIndex(predicate);+ expect(index).toBeGreaterThanOrEqual(0);+ expect(index).toBeLessThan(timeline.length - 1);+ return timeline[index + 1].ms - timeline[index].ms;+};++describe('aiChatDevStreamFixture — branch coverage (0723pm)', () => {+ afterEach(() => {+ vi.useRealTimers();+ vi.restoreAllMocks();+ });++ describe('abortError', () => {+ it('rejects with a DOM-shaped AbortError and emits nothing when the signal is already aborted', async () => {+ const controller = new AbortController();+ controller.abort();+ const onEvent = vi.fn();++ const streamPromise = maybeRunAIChatDevStreamFixture({+ prompt: '/fixture tool-burst',+ onEvent,+ signal: controller.signal,+ });++ await expect(streamPromise).rejects.toMatchObject({+ name: 'AbortError',+ message: 'The operation was aborted.',+ });+ // Early termination: the very first throwIfAborted at the top of the loop+ // fires before any event is dispatched to the consumer.+ expect(onEvent).not.toHaveBeenCalled();+ });++ it('catches an abort raised from inside onEvent at the next waitForFixtureStep gate (zero-delay pacing)', async () => {+ const controller = new AbortController();+ const seen: string[] = [];+ const onEvent = vi.fn((event: AIChatStreamEvent) => {+ seen.push(event.type);+ // Abort once the second event lands; the subsequent waitForFixtureStep+ // entry guard must surface the AbortError before event three.+ if (seen.length === 2) {+ controller.abort();+ }+ });++ const streamPromise = maybeRunAIChatDevStreamFixture({+ prompt: '/fixture send-hold',+ onEvent,+ signal: controller.signal,+ });++ await expect(streamPromise).rejects.toMatchObject({ name: 'AbortError' });+ expect(seen).toEqual(['session', 'workflow_state']);+ });+ });++ describe('handleAbort (mid-stream abort while a paced step is in flight)', () => {+ it('tears down the pending wait, rejects with AbortError, registers the listener once, and emits no further events', async () => {+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });+ const controller = new AbortController();+ const addSpy = vi.spyOn(controller.signal, 'addEventListener');+ const removeSpy = vi.spyOn(controller.signal, 'removeEventListener');+ const onEvent = vi.fn();++ const streamPromise = maybeRunAIChatDevStreamFixture({+ prompt: '/fixture tool-chain',+ stepDelayMs: 100,+ onEvent,+ signal: controller.signal,+ });++ // First event (session) is dispatched synchronously before the first+ // paced wait, so exactly one listener is now attached to a pending timer.+ await flushMicrotasks();+ expect(onEvent.mock.calls.map(([event]) => event.type)).toEqual(['session']);+ expect(vi.getTimerCount()).toBe(1);+ expect(addSpy).toHaveBeenCalledTimes(1);+ expect(addSpy).toHaveBeenCalledWith('abort', expect.any(Function), { once: true });++ // Consumer aborts mid-wait: handleAbort must run, clear the timer,+ // detach its listener, and reject with a fresh abortError.+ controller.abort();++ expect(vi.getTimerCount()).toBe(0);+ expect(removeSpy).toHaveBeenCalledTimes(1);+ expect(removeSpy).toHaveBeenCalledWith('abort', expect.any(Function));++ await expect(streamPromise).rejects.toMatchObject({+ name: 'AbortError',+ message: 'The operation was aborted.',+ });+ // No further events after the abort.+ expect(onEvent.mock.calls.map(([event]) => event.type)).toEqual(['session']);+ });++ it('does not register an abort listener when no signal is supplied, even with pacing enabled', async () => {+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });+ const onEvent = vi.fn();++ const streamPromise = maybeRunAIChatDevStreamFixture({+ prompt: '/fixture tool-burst',+ stepDelayMs: 5,+ onEvent,+ });++ await flushMicrotasks();+ // No signal -> the optional-chaining addEventListener arm is skipped, but+ // a timer is still scheduled for the paced wait.+ expect(vi.getTimerCount()).toBe(1);++ await vi.runAllTimersAsync();+ await expect(streamPromise).resolves.toBe(true);+ expect(onEvent.mock.calls[onEvent.mock.calls.length - 1][0].type).toBe('done');+ });+ });++ describe('command resolution early-outs', () => {+ it('returns false and emits nothing for a non-fixture prompt', async () => {+ const onEvent = vi.fn();+ const ran = await maybeRunAIChatDevStreamFixture({+ prompt: 'show me the latest alerts',+ onEvent,+ });++ expect(ran).toBe(false);+ expect(onEvent).not.toHaveBeenCalled();+ });++ it('treats a bare "/fixture" as a command but an unknown fixture (error arm)', async () => {+ const onEvent = vi.fn();+ const ran = await maybeRunAIChatDevStreamFixture({ prompt: '/fixture', onEvent });++ expect(ran).toBe(true);+ const typesList = onEvent.mock.calls.map(([event]) => event.type);+ expect(typesList).toEqual(['session', 'workflow_state', 'error']);+ const errorEvent = onEvent.mock.calls[2][0];+ expect(errorEvent.type).toBe('error');+ expect((errorEvent.data as { message: string }).message).toContain(+ 'Unknown Assistant fixture',+ );+ });+ });++ describe('fixtureStepDelay pacing arms (uncovered sequencing holds)', () => {+ it('holds the provider_retry workflow_state for 1600ms (provider-retry fixture)', async () => {+ const timeline = await collectPacedTimeline('/fixture provider-retry');+ const gap = gapAfterFirstMatching(+ timeline,+ (entry) => entry.type === 'workflow_state' && entry.phase === 'provider_retry',+ );+ expect(gap).toBe(1600);+ });++ it('holds the pending-tool tool_progress for 2200ms and falls back to the default delay otherwise', async () => {+ const timeline = await collectPacedTimeline('/fixture pending-tool');+ expect(gapAfterFirstMatching(timeline, (entry) => entry.type === 'tool_progress')).toBe(2200);+ // Fallthrough arm: `if (normalizedPrompt === '/fixture pending-tool') return defaultDelayMs;`+ expect(gapAfterFirstMatching(timeline, (entry) => entry.type === 'session')).toBe(+ STEP_DELAY_MS,+ );+ });++ it('holds the send-hold session for 1400ms', async () => {+ const timeline = await collectPacedTimeline('/fixture send-hold');+ expect(gapAfterFirstMatching(timeline, (entry) => entry.type === 'session')).toBe(1400);+ });++ it('holds context-group tool_start for 900ms and tool_end for 180ms', async () => {+ const timeline = await collectPacedTimeline('/fixture context-group');+ expect(gapAfterFirstMatching(timeline, (entry) => entry.type === 'tool_start')).toBe(900);+ expect(gapAfterFirstMatching(timeline, (entry) => entry.type === 'tool_end')).toBe(180);+ });++ it('holds the stream-idle stream_idle workflow_state for 1800ms', async () => {+ const timeline = await collectPacedTimeline('/fixture stream-idle');+ expect(+ gapAfterFirstMatching(+ timeline,+ (entry) => entry.type === 'workflow_state' && entry.phase === 'stream_idle',+ ),+ ).toBe(1800);+ });++ it('holds the queue-hold stream_idle workflow_state for 10000ms', async () => {+ const timeline = await collectPacedTimeline('/fixture queue-hold');+ expect(+ gapAfterFirstMatching(+ timeline,+ (entry) => entry.type === 'workflow_state' && entry.phase === 'stream_idle',+ ),+ ).toBe(10000);+ });++ it('holds the workflow-burst provider_start workflow_state for 2400ms', async () => {+ const timeline = await collectPacedTimeline('/fixture workflow-burst');+ expect(+ gapAfterFirstMatching(+ timeline,+ (entry) => entry.type === 'workflow_state' && entry.phase === 'provider_start',+ ),+ ).toBe(2400);+ });++ it('holds the long-output content event for 1800ms', async () => {+ const timeline = await collectPacedTimeline('/fixture long-output');+ expect(gapAfterFirstMatching(timeline, (entry) => entry.type === 'content')).toBe(1800);+ });+ });++ describe('model/provider resolution fallbacks', () => {+ const collectEvents = async (prompt: string, model?: string) => {+ const onEvent = vi.fn();+ const ran = await maybeRunAIChatDevStreamFixture({ prompt, model, onEvent });+ expect(ran).toBe(true);+ return onEvent.mock.calls.map(([event]) => event) as AIChatStreamEvent[];+ };++ it('falls back to the "dev" provider when the fixture model has no provider separator', async () => {+ // providerFromFixtureModel: indexOf(':') <= 0 -> provider '' -> `|| 'dev'`.+ const events = await collectEvents('/fixture provider-retry', 'standalone-model');+ const retryState = events.find(+ (event) =>+ event.type === 'workflow_state' &&+ (event.data as { phase?: string }).phase === 'provider_retry',+ );+ expect(retryState).toBeDefined();+ expect((retryState!.data as { provider?: string }).provider).toBe('dev');+ const done = events.find((event) => event.type === 'done');+ expect((done!.data as { model?: string }).model).toBe('standalone-model');+ });++ it('falls back to the default fixture model when the supplied model is blank whitespace', async () => {+ // assistantFixtureModel: model?.trim() || 'dev:assistant-stream-fixture'.+ const events = await collectEvents('/fixture provider-retry', ' ');+ const done = events.find((event) => event.type === 'done');+ expect((done!.data as { model?: string }).model).toBe('dev:assistant-stream-fixture');+ });+ });+});diff --git a/frontend-modern/src/utils/__tests__/licensePresentation.branchcov0723pm.test.ts b/frontend-modern/src/utils/__tests__/licensePresentation.branchcov0723pm.test.tsnew file mode 100644index 0000000000..9c3506e1b6--- /dev/null+++ b/frontend-modern/src/utils/__tests__/licensePresentation.branchcov0723pm.test.ts@@ -0,0 +1,305 @@+/**+ * Branch-coverage tests for licensePresentation.ts (0723pm batch).+ *+ * Targets the remaining uncovered licence-state fallback arms:+ * - absent / malformed expiry dates (formatUnixSeconds value <= 0 arm)+ * - zero, negative, and fractional patrol-loop counts (normalizeStatusCount)+ * - alias-subtraction underflow in getFirstPartyPatrolControlCount+ * - resolved-without-value-state verification in hasVerifiedPatrolOperatorOutcome+ * - unknown tier fallbacks in getSelfHostedUnlockedFeatures /+ * getSelfHostedIncludedExtras / getSelfHostedActivePlanSummary+ * - empty-feature skip and 8-item cap in getSelfHostedActivationHighlights+ *+ * Does NOT modify the source module or any existing test file.+ */+import { describe, expect, it } from 'vitest';++import {+ getBillingAdminTrialStatus,+ getSelfHostedActivationSuccessPresentation,+ getSelfHostedCurrentPlanPresentation,+ PATROL_CONTROL_STARTER_URL,+} from '@/utils/licensePresentation';++/* ------------------------------------------------------------------ *+ * formatUnixSeconds — absent / negative expiry dates+ * (exercised through getBillingAdminTrialStatus)+ *+ * The private helper has three arms:+ * if (!value || value <= 0) return 'N/A'; // (A) falsy, (B) <= 0+ * if (Number.isNaN(date.getTime())) return …; // (C)+ * return date.toLocaleString(); // (D)+ *+ * Existing tests cover arm (A) via trial_started_at: 0 and arm (C) via+ * Infinity. A *negative* value is truthy so it skips (A) and lands on+ * arm (B) — a distinct branch.+ * ------------------------------------------------------------------ */++describe('formatUnixSeconds via getBillingAdminTrialStatus - negative timestamp arms', () => {+ it('returns N/A for a negative trial_ends_at on a trial subscription (value <= 0, not falsy)', () => {+ const result = getBillingAdminTrialStatus({+ subscription_state: 'trial',+ trial_ends_at: -1,+ } as never);+ expect(result).toBe('Trial (ends N/A)');+ });++ it('returns N/A for both timestamps when they are negative on a non-trial subscription', () => {+ const result = getBillingAdminTrialStatus({+ subscription_state: 'active',+ trial_started_at: -100,+ trial_ends_at: -200,+ } as never);+ expect(result).toBe('Trial (started N/A, ends N/A)');+ });+});++/* ------------------------------------------------------------------ *+ * normalizeStatusCount — zero, negative, and fractional patrol counts+ * (exercised through getSelfHostedCurrentPlanPresentation)+ * ------------------------------------------------------------------ */++describe('patrol-control counts - fractional completed count truncated to 0', () => {+ it('truncates 0.7 to 0 so the decision stage is skipped and the stage is continue', () => {+ // If 0.7 were not truncated, completedCount would be > 0 and the+ // governed-decision-only outcome branch would fire (stage 'decision').+ // Math.trunc(0.7) === 0 keeps completedCount at 0, so the loop has+ // starters but no completed/resolved work → stage 'continue'.+ const result = getSelfHostedCurrentPlanPresentation({+ entitlements: {+ tier: 'pro',+ subscription_state: 'active',+ capabilities: ['relay', 'mobile_app', 'ai_autofix'],+ limits: [],+ upgrade_reasons: [],+ runtime: { build: 'pro', label: 'Pulse Pro runtime' },+ },+ displayableCapabilities: [+ 'Pulse Relay (Remote Access)',+ 'Patrol Applies Safe Fixes and Verifies the Result',+ ],+ patrolOperatorStatus: {+ patrolControlOperationsLoopStarterCount: 1,+ patrolControlCompletedOperationsLoopCount: 0.7,+ patrolControlResolvedOperationsLoopCount: 0,+ externalAgentReady: false,+ },+ });+ expect(result.patrolControlAction).toEqual({+ actionLabel: 'Open Patrol',+ actionUrl: PATROL_CONTROL_STARTER_URL,+ actionIntent: 'patrol_control',+ });+ });+});++describe('patrol-control counts - negative counts clamped to 0', () => {+ it('clamps all negative counts to 0 so no patrol work is detected (stage set)', () => {+ const result = getSelfHostedCurrentPlanPresentation({+ entitlements: {+ tier: 'pro',+ subscription_state: 'active',+ capabilities: ['relay', 'mobile_app', 'ai_autofix'],+ limits: [],+ upgrade_reasons: [],+ runtime: { build: 'pro', label: 'Pulse Pro runtime' },+ },+ displayableCapabilities: [+ 'Pulse Relay (Remote Access)',+ 'Patrol Applies Safe Fixes and Verifies the Result',+ ],+ patrolOperatorStatus: {+ patrolControlOperationsLoopStarterCount: -3,+ patrolControlCompletedOperationsLoopCount: -1,+ patrolControlResolvedOperationsLoopCount: -2,+ externalAgentReady: false,+ },+ });+ // All counts clamped to 0 → getPatrolControlValueState returns undefined+ // (the counts-all-zero ternary arm) → stage 'set'.+ expect(result.patrolControlAction).toEqual({+ actionLabel: 'Choose Patrol mode',+ actionUrl: PATROL_CONTROL_STARTER_URL,+ actionIntent: 'patrol_control',+ });+ });+});++describe('getFirstPartyPatrolControlCount - alias subtraction underflow', () => {+ it('clamps the net count to 0 when pro-activation aliases exceed the patrol-control count', () => {+ // starter: 2 patrol-control − 5 pro-activation aliases = −3 → clamped to 0.+ // With every count at 0, no patrol work is detected → stage 'set'.+ const result = getSelfHostedCurrentPlanPresentation({+ entitlements: {+ tier: 'pro',+ subscription_state: 'active',+ capabilities: ['relay', 'mobile_app', 'ai_autofix'],+ limits: [],+ upgrade_reasons: [],+ runtime: { build: 'pro', label: 'Pulse Pro runtime' },+ },+ displayableCapabilities: [+ 'Pulse Relay (Remote Access)',+ 'Patrol Applies Safe Fixes and Verifies the Result',+ ],+ patrolOperatorStatus: {+ patrolControlOperationsLoopStarterCount: 2,+ proActivationOperationsLoopStarterCount: 5,+ externalAgentReady: false,+ },+ });+ expect(result.patrolControlAction).toEqual({+ actionLabel: 'Choose Patrol mode',+ actionUrl: PATROL_CONTROL_STARTER_URL,+ actionIntent: 'patrol_control',+ });+ });+});++describe('hasVerifiedPatrolOperatorOutcome - resolved count without explicit value state', () => {+ it('treats a resolved loop with no valueProofState as verified, yielding the set stage', () => {+ // starterCount = 1 → the counts > 0 ternary in getPatrolControlValueState+ // is entered, but both patrolControlValueState and patrolAutonomyValueState+ // are undefined, so valueProofState = undefined.+ //+ // The uncovered arm is: (!valueProofState && resolvedCount > 0) → true.+ // Without this arm, hasVerified would be false and the stage would be+ // 'continue' (Open Patrol). Because the arm fires, stage is 'set'.+ const result = getSelfHostedCurrentPlanPresentation({+ entitlements: {+ tier: 'pro',+ subscription_state: 'active',+ capabilities: ['relay', 'mobile_app', 'ai_autofix'],+ limits: [],+ upgrade_reasons: [],+ runtime: { build: 'pro', label: 'Pulse Pro runtime' },+ },+ displayableCapabilities: [+ 'Pulse Relay (Remote Access)',+ 'Patrol Applies Safe Fixes and Verifies the Result',+ ],+ patrolOperatorStatus: {+ patrolControlOperationsLoopStarterCount: 1,+ patrolControlResolvedOperationsLoopCount: 1,+ externalAgentReady: false,+ },+ });+ expect(result.patrolControlAction).toEqual({+ actionLabel: 'Choose Patrol mode',+ actionUrl: PATROL_CONTROL_STARTER_URL,+ actionIntent: 'patrol_control',+ });+ });+});++/* ------------------------------------------------------------------ *+ * Unknown-tier fallbacks in current-plan presentation+ *+ * Exercises internal branches that the existing tests do not reach+ * because they always supply a recognised tier:+ * - getSelfHostedUnlockedFeatures → else: return displayableCapabilities+ * - getSelfHostedIncludedExtras → planDefinition?.includedExtras ?? []+ * - getSelfHostedActivePlanSummary → if (!planDefinition) return null+ * - getSelfHostedPlanLabel → titleCase fallback+ * ------------------------------------------------------------------ */++describe('getSelfHostedCurrentPlanPresentation - unknown active tier fallbacks', () => {+ it('sources unlocked features from displayable capabilities and returns empty extras', () => {+ const displayable = ['Custom Capability A', 'Custom Capability B'];+ const result = getSelfHostedCurrentPlanPresentation({+ entitlements: {+ tier: 'team_seats',+ subscription_state: 'active',+ capabilities: [],+ limits: [],+ upgrade_reasons: [],+ },+ displayableCapabilities: displayable,+ });+ // planLabel via titleCase fallback+ expect(result.title).toBe('Current plan: Team Seats');+ // getSelfHostedActivePlanSummary returns null (no planDefinition) → || fallback+ expect(result.body).toBe(+ 'Team Seats is active on this instance. These capabilities are available right now.',+ );+ // getSelfHostedUnlockedFeatures else branch: returns displayableCapabilities+ expect(result.unlockedFeatures).toEqual(displayable);+ // getSelfHostedIncludedExtras: planDefinition null → ?? [] fallback+ expect(result.includedExtras).toEqual([]);+ expect(result.includedExtrasLabel).toBeUndefined();+ // Unknown tier ≠ pro → no patrol action+ expect(result.patrolControlAction).toBeUndefined();+ });+});++describe('getSelfHostedCurrentPlanPresentation - unknown trial tier fallbacks', () => {+ it('shows the trial-capabilities-active body when displayable capabilities are present', () => {+ const result = getSelfHostedCurrentPlanPresentation({+ entitlements: {+ tier: 'team_seats',+ subscription_state: 'trial',+ capabilities: [],+ limits: [],+ upgrade_reasons: [],+ },+ displayableCapabilities: ['Custom Capability A'],+ });+ // planDefinition null → unlockedFeatures comes from displayableCapabilities+ // (the else branch). unlockedFeatures.length > 0 → "capabilities are active"+ // body arm (previously only exercised via Relay, which uses the plan-+ // definition highlights path, not the displayableCapabilities path).+ expect(result.title).toBe('Current plan: Team Seats Trial');+ expect(result.body).toBe(+ 'Team Seats trial capabilities are active on this instance right now.',+ );+ expect(result.unlockedFeatures).toEqual(['Custom Capability A']);+ });+});++/* ------------------------------------------------------------------ *+ * getSelfHostedActivationHighlights — empty-feature skip and 8-item cap+ * (exercised through getSelfHostedActivationSuccessPresentation with an+ * unknown tier so that prioritized is empty and unlockedFeatures ==+ * displayableCapabilities, giving full control over the feature list)+ * ------------------------------------------------------------------ */++describe('getSelfHostedActivationHighlights - skips falsy feature entries', () => {+ it('drops empty strings from the highlights list while preserving non-empty entries', () => {+ const result = getSelfHostedActivationSuccessPresentation({+ entitlements: {+ tier: 'team_seats',+ subscription_state: 'active',+ capabilities: [],+ limits: [],+ upgrade_reasons: [],+ },+ displayableCapabilities: ['Real Feature', '', 'Another Feature'],+ source: 'purchase',+ });+ expect(result).not.toBeNull();+ // The '' entry is falsy so `!feature` is true and it is skipped.+ expect(result?.highlights).toEqual(['Real Feature', 'Another Feature']);+ });+});++describe('getSelfHostedActivationHighlights - caps at 8 entries', () => {+ it('stops collecting highlights once 8 unique entries have been gathered', () => {+ const caps = Array.from({ length: 10 }, (_, i) => `Capability ${i + 1}`);+ const result = getSelfHostedActivationSuccessPresentation({+ entitlements: {+ tier: 'team_seats',+ subscription_state: 'active',+ capabilities: [],+ limits: [],+ upgrade_reasons: [],+ },+ displayableCapabilities: caps,+ source: 'purchase',+ });+ expect(result).not.toBeNull();+ expect(result?.highlights).toHaveLength(8);+ expect(result?.highlights).toEqual(caps.slice(0, 8));+ expect(result?.highlights).not.toContain('Capability 9');+ expect(result?.highlights).not.toContain('Capability 10');+ });+});