Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77814e6bb3 |
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();
|
||||
});
|
||||
});
|
||||
@@ -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>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user