Skip to content
18 changes: 18 additions & 0 deletions frontend/src/__tests__/api-insurance.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { getInsuranceComparison, getInsuranceStatus } from '../api/insurance';
import { apiRequest } from '../api/client';

jest.mock('../api/client', () => ({ apiRequest: jest.fn() }));

describe('insurance api', () => {
beforeEach(() => jest.resetAllMocks());

it('status is a plain GET with no query or body', async () => {
await getInsuranceStatus();
expect(apiRequest).toHaveBeenCalledWith('/insurance/status');
});

it('comparison is a plain GET with no query or body', async () => {
await getInsuranceComparison();
expect(apiRequest).toHaveBeenCalledWith('/insurance/comparison');
});
});
677 changes: 677 additions & 0 deletions frontend/src/__tests__/archera-comparison.test.ts

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions frontend/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,9 @@ export {
setPlanAccounts,
getFederationIaC
} from './accounts';

// Re-export Archera comparison functions
export {
getInsuranceStatus,
getInsuranceComparison
} from './insurance';
16 changes: 16 additions & 0 deletions frontend/src/api/insurance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Archera comparison API functions (read-only, explicit user action).
*/

import { apiRequest } from './client';
import type { ArcheraComparison, InsuranceStatus } from './types';

/** Reports whether the comparison is configured. Makes no vendor call. */
export async function getInsuranceStatus(): Promise<InsuranceStatus> {
return apiRequest<InsuranceStatus>('/insurance/status');
}

/** Fetches the Archera comparison now. One vendor request per call, no caching. */
export async function getInsuranceComparison(): Promise<ArcheraComparison> {
return apiRequest<ArcheraComparison>('/insurance/comparison');
}
102 changes: 102 additions & 0 deletions frontend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -948,3 +948,105 @@ export interface RequestOptions extends RequestInit {
*/
timeoutMs?: number;
}

// ---------------------------------------------------------------------------
// Archera comparison (GET /api/insurance/*). Mirrors internal/archera/dto.go
// field for field; money is an exact decimal string or null (unknown, never 0).
// ---------------------------------------------------------------------------

export interface InsuranceStatus {
configured: boolean;
missing: string[];
}

export interface ArcheraProductSupport {
status: string;
source?: string;
evidence?: string;
underwriting_allowance: string;
customer_eligibility: string;
}

export interface ArcheraFinancials {
monthly_730h_commitment_cost_total: string | null;
monthly_730h_cloud_provider_cost: string | null;
monthly_730h_archera_premium: string | null;
monthly_730h_gross_savings: string | null;
monthly_730h_net_savings: string | null;
monthly_730h_covered_on_demand_cost: string | null;
}

export interface ArcheraTotals extends ArcheraFinancials {
upfront_one_time_cost: string | null;
}

export interface ArcheraOfferDelta {
monthly_730h_net_savings: string | null;
upfront_one_time_cost: string | null;
discount_rate: string | null;
breakeven_days: string | null;
}

export interface ArcheraHypotheticalDelta {
monthly_730h_net_savings: string | null;
monthly_730h_commitment_cost: string | null;
upfront_one_time_cost: string | null;
}

export interface ArcheraLineItem {
line_item_id: string;
reason: string;
actual_term: string | null;
actual_payment_option: string | null;
actual_commitment_type: string | null;
}

export interface ArcheraHypothetical {
contract_term: string | null;
payment_option: string;
totals: ArcheraTotals;
delta_vs_current: ArcheraHypotheticalDelta;
line_items: ArcheraLineItem[];
}

export interface ArcheraOffer {
offer_id: string;
is_current: boolean;
provider: string;
commitment_type: string;
region: string | null;
contract_term: string | null;
payment_option: string | null;
lease_attached: boolean;
lease_menu_item_id: string | null;
archera_offer_name?: string | null;
archera_offer_name_note?: string;
archera_product_support: ArcheraProductSupport;
discount_rate: string | null;
breakeven_days: string | null;
monthly: ArcheraFinancials;
upfront_one_time_cost: string | null;
delta_vs_current: ArcheraOfferDelta;
}

export interface ArcheraRow {
line_item_id: string;
current: ArcheraOffer;
candidates: ArcheraOffer[];
}

export interface ArcheraComparison {
title: string;
plan_id: string;
fetched_at: string;
currency: string | null;
currency_note: string;
premium_included: boolean;
basis_note: string;
delta_basis_note: string;
current: ArcheraTotals;
hypotheticals: ArcheraHypothetical[];
rows: ArcheraRow[];
non_gating_disclosure: string;
sponsorship_disclosure: string;
}
Loading
Loading