sitesmith: take the upgrade link from the panel (summary.upgrade_url)

The panel now sends upgrade_url in the entitlement summary, derived from
its billing_url setting. The banner uses it for the upgrade link and
renders no link when it is empty or absent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXiDeTw5Hbvm5fCmEsH
This commit is contained in:
shadowdaoandClaude Opus 5.5 committed 2026-12-02 17:52:16 -08:00
1 parent 8ff0e01c45
commit 77814e6bb3
3 files changed
+40 -4

No files matched your search

@@ -0,0 +1,32 @@
import { describe, test, expect, beforeEach, afterEach } from 'vitest';
import React from 'react';
import { createRoot, Root } from 'react-dom/client';
import { act } from 'react-dom/test-utils';
import { UpgradeBanner } from './UpgradeBanner';
import { SitesmithSummary } from '../../types/sitesmith';
let root: Root; let box: HTMLDivElement;
beforeEach(() => { box = document.createElement('div'); document.body.appendChild(box); root = createRoot(box); });
afterEach(() => { act(() => root.unmount()); box.remove(); });
const render = (el: React.ReactElement) => act(async () => { root.render(el); });
const summary = (extra: Partial<SitesmithSummary> = {}): SitesmithSummary => ({
enabled: false, monthly_cap: 0, monthly_used: 0, bonus_credits: 0, resets_on: '', status: 'DISABLED', ...extra,
});
describe('UpgradeBanner upgrade link', () => {
test('renders the link with the url from the panel', async () => {
await render(<UpgradeBanner summary={summary({ upgrade_url: 'https://billing.example/upgrade' })} />);
const a = box.querySelector('a') as HTMLAnchorElement;
expect(a).not.toBeNull();
expect(a.getAttribute('href')).toBe('https://billing.example/upgrade');
expect(a.textContent).toContain('Upgrade your plan');
});
test('renders no link when upgrade_url is empty or absent', async () => {
await render(<UpgradeBanner summary={summary({ upgrade_url: '' })} />);
expect(box.querySelector('a')).toBeNull();
expect(box.textContent).toContain('Sitesmith is a paid addon');
await render(<UpgradeBanner summary={summary()} />);
expect(box.querySelector('a')).toBeNull();
});
});
+6 -4
View File
@@ -19,10 +19,12 @@ export const UpgradeBanner: React.FC<Props> = ({ summary }) => {
<div style={{ fontSize: 13, marginBottom: 10 }}>
Describe the site you want and our AI builds it. You can edit everything afterward.
</div>
<a href="https://anhonesthost.com/clientarea.php?action=services" target="_blank" rel="noopener noreferrer"
style={{ color: '#fff', background: '#7c3aed', padding: '8px 14px', borderRadius: 6, textDecoration: 'none' }}>
Upgrade your plan →
</a>
{summary.upgrade_url && (
<a href={summary.upgrade_url} target="_blank" rel="noopener noreferrer"
style={{ color: '#fff', background: '#7c3aed', padding: '8px 14px', borderRadius: 6, textDecoration: 'none' }}>
Upgrade your plan →
</a>
)}
</>)}
{isCapped && (<>
<div style={{ fontWeight: 600, marginBottom: 6 }}>Monthly cap reached</div>
+2
View File
@@ -47,6 +47,8 @@ export interface SitesmithSummary {
bonus_credits: number;
resets_on: string;
status: SitesmithStatus;
/** Billing upgrade link from the panel's billing_url setting; empty = no link. */
upgrade_url?: string;
}
export interface SitesmithMessage {