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 { describe, expect, it } from 'vitest';
import { createBootstrapDefaults, createPortalRuntime, readPortalRuntimeHandoff } from './runtime';
describe('portal runtime', function() {
it('derives bootstrap defaults from embedded bootstrap data', function() {
var defaults = createBootstrapDefaults({
has_self_hosted_commercial: true,
public_site_url: 'https://cloud.pulserelay.pro',
support_email: '[email protected]',
commercial_api_base_url: '/api/portal/commercial',
portal_path: '/account',
bootstrap_path: '/api/account/bootstrap',
magic_link_request_path: '/api/public/account/magic-link/request',
signup_path: '/join',
logout_path: '/signout',
account_api_base_path: '/api/account-links',
portal_api_base_path: '/api/account',
});
expect(defaults.public_site_url).toBe('https://cloud.pulserelay.pro');
expect(defaults.has_self_hosted_commercial).toBe(true);
expect(defaults.support_email).toBe('[email protected]');
expect(defaults.portal_path).toBe('/account');
expect(defaults.bootstrap_path).toBe('/api/account/bootstrap');
});
it('keeps local preview API roots intact for harness-driven development', function() {
var defaults = createBootstrapDefaults({
has_self_hosted_commercial: false,
commercial_api_base_url: '/__portal_preview/commercial',
bootstrap_path: '/api/portal/bootstrap',
account_api_base_path: '/api/accounts',
portal_api_base_path: '/api/portal',
});
expect(defaults.commercial_api_base_url).toBe('/__portal_preview/commercial');
expect(defaults.bootstrap_path).toBe('/api/portal/bootstrap');
expect(defaults.account_api_base_path).toBe('/api/accounts');
expect(defaults.portal_api_base_path).toBe('/api/portal');
});
it('preserves an explicitly empty signup path', function() {
var defaults = createBootstrapDefaults({
signup_path: '',
});
expect(defaults.signup_path).toBe('');
});
it('creates a store from runtime bootstrap input', function() {
var runtime = createPortalRuntime({
authenticated: true,
email: '[email protected]',
has_self_hosted_commercial: false,
accounts: [],
commercial_api_base_url: '/api/portal/commercial',
});
expect(runtime.store.getBootstrap().authenticated).toBe(true);
expect(runtime.store.getBootstrap().email).toBe('[email protected]');
expect(runtime.bootstrapDefaults.commercial_api_base_url).toBe('/api/portal/commercial');
});
it('derives canonical email and billing handoff from the portal URL', function() {
var handoff = readPortalRuntimeHandoff(
'https://cloud.pulserelay.pro/portal?email=buyer%40example.com&portal_handoff_id=cph_signed',
);
expect(handoff.email).toBe('[email protected]');
expect(handoff.openBillingPanelID).toBe('upgrade-billing-panel');
expect(handoff.upgradePortalHandoffID).toBe('cph_signed');
expect(handoff.upgradeFeatureKey).toBe('');
expect(handoff.upgradeTrialRequested).toBe(false);
});
it('reads a trial request from the handoff arrival query', function() {
var handoff = readPortalRuntimeHandoff(
'https://cloud.pulserelay.pro/portal?portal_handoff_id=cph_signed&feature=self_hosted_plan&trial=1',
);
expect(handoff.upgradeTrialRequested).toBe(true);
var noTrial = readPortalRuntimeHandoff(
'https://cloud.pulserelay.pro/portal?portal_handoff_id=cph_signed&trial=definitely',
);
expect(noTrial.upgradeTrialRequested).toBe(false);
});
it('blocks legacy checkout intent arrivals from acting as a trusted upgrade bootstrap', function() {
var handoff = readPortalRuntimeHandoff(
'https://cloud.pulserelay.pro/portal?service=upgrade&checkout_intent_id=cki_legacy',
);
expect(handoff.openBillingPanelID).toBe('upgrade-billing-panel');
expect(handoff.upgradePortalHandoffID).toBe('');
expect(handoff.upgradeFeatureKey).toBe('');
});
it('applies email and billing handoff to the initial portal store', function() {
var runtime = createPortalRuntime(
{
authenticated: false,
email: '',
has_self_hosted_commercial: false,
accounts: [],
},
{
email: '[email protected]',
openBillingPanelID: 'refund-billing-panel',
upgradePortalHandoffID: '',
upgradeFeatureKey: '',
upgradeTrialRequested: false,
}
);
expect(runtime.handoff.email).toBe('[email protected]');
expect(runtime.store.getLoginState().emailValue).toBe('[email protected]');
expect(runtime.store.getBillingState().refund.emailValue).toBe('[email protected]');
expect(runtime.store.getBillingState().openBillingPanelID).toBe('refund-billing-panel');
});
it('promotes upgrade handoff intents into the billing shell state', function() {
var runtime = createPortalRuntime(
{
authenticated: false,
email: '',
has_self_hosted_commercial: false,
accounts: [],
},
{
email: '',
openBillingPanelID: 'upgrade-billing-panel',
upgradePortalHandoffID: 'cph_signed',
upgradeFeatureKey: '',
upgradeTrialRequested: true,
}
);
expect(runtime.store.getShellState().activeSection).toBe('billing');
expect(runtime.store.getBillingState().openBillingPanelID).toBe('upgrade-billing-panel');
expect(runtime.store.getBillingState().upgradePortalHandoffID).toBe('cph_signed');
expect(runtime.store.getBillingState().upgradeTrialRequested).toBe(true);
expect(runtime.store.getBillingState().upgradeFeatureKey).toBe('');
});
});