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
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { cleanup, render, screen, waitFor } from '@solidjs/testing-library';
import { Route, Router } from '@solidjs/router';
import PricingHandoff from '@/pages/PricingHandoff';
import { DEFAULT_LOCALE, loadLocaleCatalog, setActiveLocale } from '@/i18n';
import {
getSelfHostedPurchaseStartUrl,
SELF_HOSTED_PRO_BILLING_PLAN_ROUTE,
} from '@/utils/pricingHandoff';
const handoffToExternalPricingMock = vi.fn();
vi.mock('@/utils/pricingHandoff', async () => {
const actual =
await vi.importActual<typeof import('@/utils/pricingHandoff')>('@/utils/pricingHandoff');
return {
...actual,
handoffToExternalPricing: (...args: unknown[]) => handoffToExternalPricingMock(...args),
};
});
describe('PricingHandoff', () => {
beforeEach(() => {
handoffToExternalPricingMock.mockReset();
setActiveLocale(DEFAULT_LOCALE);
window.scrollTo = vi.fn();
});
afterEach(() => {
cleanup();
setActiveLocale(DEFAULT_LOCALE);
window.history.replaceState({}, '', '/');
});
it('hands unknown feature requests off to Pulse Account', async () => {
window.history.replaceState({}, '', '/pricing?feature=unknown_pro_feature');
const expectedDestination = getSelfHostedPurchaseStartUrl(
'unknown_pro_feature',
new URLSearchParams('feature=unknown_pro_feature'),
);
render(() => (
<Router>
<Route path="/pricing" component={PricingHandoff} />
</Router>
));
await waitFor(() => {
expect(handoffToExternalPricingMock).toHaveBeenCalledWith(expectedDestination);
});
expect(
screen.getByRole('heading', { name: 'Redirecting to Pulse Account' }),
).toBeInTheDocument();
expect(screen.getByRole('link', { name: /continue to Pulse Account/i })).toHaveAttribute(
'href',
expectedDestination,
);
});
it('localizes the Pulse Account handoff without translating the destination name', async () => {
await loadLocaleCatalog('de');
setActiveLocale('de');
window.history.replaceState({}, '', '/pricing?feature=unknown_pro_feature');
const expectedDestination = getSelfHostedPurchaseStartUrl(
'unknown_pro_feature',
new URLSearchParams('feature=unknown_pro_feature'),
);
render(() => (
<Router>
<Route path="/pricing" component={PricingHandoff} />
</Router>
));
expect(
await screen.findByRole('heading', { name: 'Weiterleitung zu Pulse Account' }),
).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'weiter zu Pulse Account' })).toHaveAttribute(
'href',
expectedDestination,
);
});
it('keeps the manual-redirect link visible on phones', () => {
window.history.replaceState({}, '', '/pricing?feature=unknown_pro_feature');
render(() => (
<Router>
<Route path="/pricing" component={PricingHandoff} />
</Router>
));
// PageHeader hides its description below the sm breakpoint unless the
// caller asks for it always; this paragraph holds the only way to continue
// when the automatic redirect does not happen.
const link = screen.getByRole('link', { name: /continue to Pulse Account/i });
const description = link.closest('p');
expect(description).not.toBeNull();
expect(description).not.toHaveClass('hidden');
});
// The earlier 'retired monitored-system pricing handoffs' case has been
// removed: max_monitored_systems is no longer in
// RETIRED_TRIAL_PRICING_FEATURES (the set was narrowed to trial features
// only). It is now a live paid-feature key that routes to the
// self-hosted purchase-start flow rather than the neutral Plans surface.
// The trial_expired case below still exercises the retired-feature path.
it('keeps retired trial pricing handoffs on the neutral Plans surface', async () => {
window.history.replaceState({}, '', '/pricing?feature=trial_expired');
render(() => (
<Router>
<Route path="/pricing" component={PricingHandoff} />
<Route
path={SELF_HOSTED_PRO_BILLING_PLAN_ROUTE}
component={() => <div>Plans destination</div>}
/>
</Router>
));
expect(await screen.findByText('Plans destination')).toBeInTheDocument();
expect(handoffToExternalPricingMock).not.toHaveBeenCalled();
});
});