fix(licensing): resolve Admiral variant detection and lifetime license handling (#376)

* fix(licensing): resolve Admiral variant detection and lifetime license handling

The Lemon Squeezy variant name for Admiral licenses contains "Admiral"
(not "Team"), but getVariant() only checked for "team" and "personal".
This caused Admiral licenses to be misidentified as Skipper, locking all
Admiral-exclusive features.

- Map "admiral" variant names to internal "team" value, "skipper" to "personal"
- Add isLifetime field to LicenseInfo API response
- Hide "Manage Subscription" button for lifetime licenses (no billing portal)
- Show "Duration: Lifetime" instead of empty renewal date
- Hide upgrade cards for active Admiral users
- Add 23 unit tests covering variant resolution, tier computation, and lifetime detection
- Add troubleshooting entries for wrong tier label, locked features, and billing portal errors

* fix(licensing): address code review findings

- Fix nested ternary in LicenseSection JSX; restore conditional rendering
  to avoid showing an empty "N/A" row for non-subscription states
- Clean up test file: use shared svc variable, remove redundant comments,
  add trialDaysRemaining assertions, rename describe block
This commit is contained in:
Anso
2026-04-05 07:00:21 -04:00
committed by GitHub
parent f516275834
commit f841c402b2
8 changed files with 310 additions and 22 deletions
@@ -42,8 +42,9 @@ export function LicenseSection() {
}
};
const isAdmiral = isPaid && license?.variant === 'team' && license?.status === 'active';
const showSkipperCard = !isPaid || license?.status === 'trial';
const showUpgradeCards = showSkipperCard || (license?.variant === 'personal' && license?.status === 'active');
const showUpgradeCards = !isAdmiral && (showSkipperCard || (license?.variant === 'personal' && license?.status === 'active'));
return (
<div className="space-y-6">
@@ -95,10 +96,10 @@ export function LicenseSection() {
<span className="font-mono text-xs">{license.maskedKey}</span>
</div>
)}
{license.validUntil && (
{(license.isLifetime || license.validUntil) && (
<div className="flex justify-between">
<span className="text-muted-foreground">Renews</span>
<span>{new Date(license.validUntil).toLocaleDateString()}</span>
<span className="text-muted-foreground">{license.isLifetime ? 'Duration' : 'Renews'}</span>
<span>{license.isLifetime ? 'Lifetime' : new Date(license.validUntil!).toLocaleDateString()}</span>
</div>
)}
</div>
@@ -122,20 +123,22 @@ export function LicenseSection() {
{/* Manage Subscription (active paid license) */}
{license?.status === 'active' && (
<div className="space-y-3">
<Button
variant="outline"
size="sm"
onClick={openBillingPortal}
disabled={billingLoading}
>
{billingLoading ? (
<Loader2 className="w-4 h-4 mr-2 animate-spin" />
) : (
<CreditCard className="w-4 h-4 mr-2" />
)}
Manage Subscription
<ExternalLink className="w-3 h-3 ml-1.5 opacity-50" />
</Button>
{!license.isLifetime && (
<Button
variant="outline"
size="sm"
onClick={openBillingPortal}
disabled={billingLoading}
>
{billingLoading ? (
<Loader2 className="w-4 h-4 mr-2 animate-spin" />
) : (
<CreditCard className="w-4 h-4 mr-2" />
)}
Manage Subscription
<ExternalLink className="w-3 h-3 ml-1.5 opacity-50" />
</Button>
)}
<div className="flex items-center justify-between">
<p className="text-sm text-muted-foreground">
Deactivating will revert to Community features.
+1
View File
@@ -17,6 +17,7 @@ export interface LicenseInfo {
trialDaysRemaining: number | null;
instanceId: string;
portalUrl: string | null;
isLifetime: boolean;
}
interface LicenseContextType {