Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

3.9 KB
Raw Blame
import { cleanup, render, screen } from '@solidjs/testing-library';
import { createSignal } from 'solid-js';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { RecoverySettingsPanel } from '../RecoverySettingsPanel';
import { UpdatesSettingsPanel } from '../UpdatesSettingsPanel';

describe('settings switch labels', () => {
  afterEach(() => {
    cleanup();
  });

  it('associates the auto-update switch with its visible label', () => {
    const [updateChannel, setUpdateChannel] = createSignal<'stable' | 'rc'>('stable');
    const [autoUpdateEnabled, setAutoUpdateEnabled] = createSignal(false);

    render(() => (
      <UpdatesSettingsPanel
        versionInfo={() => null}
        updateInfo={() => null}
        checkingForUpdates={() => false}
        updateChannel={updateChannel}
        setUpdateChannel={setUpdateChannel}
        autoUpdateEnabled={autoUpdateEnabled}
        setAutoUpdateEnabled={setAutoUpdateEnabled}
        checkForUpdates={vi.fn().mockResolvedValue(undefined)}
        setHasUnsavedChanges={vi.fn()}
        updatePlan={() => null}
        onInstallUpdate={vi.fn()}
        isInstalling={() => false}
      />
    ));

    expect(screen.getByRole('checkbox', { name: 'Automatic Stable Updates' })).toBeInTheDocument();
  });

  it('keeps the running release notes available from update settings', () => {
    const [updateChannel, setUpdateChannel] = createSignal<'stable' | 'rc'>('stable');
    const [autoUpdateEnabled, setAutoUpdateEnabled] = createSignal(false);

    render(() => (
      <UpdatesSettingsPanel
        versionInfo={() => ({
          version: '6.4.0',
          build: 'community',
          runtime: 'server',
          isDocker: false,
          isSourceBuild: false,
          isDevelopment: false,
        })}
        updateInfo={() => null}
        checkingForUpdates={() => false}
        updateChannel={updateChannel}
        setUpdateChannel={setUpdateChannel}
        autoUpdateEnabled={autoUpdateEnabled}
        setAutoUpdateEnabled={setAutoUpdateEnabled}
        checkForUpdates={vi.fn().mockResolvedValue(undefined)}
        setHasUnsavedChanges={vi.fn()}
        updatePlan={() => null}
        onInstallUpdate={vi.fn()}
        isInstalling={() => false}
      />
    ));

    expect(screen.getByRole('link', { name: 'Current release notes' })).toHaveAttribute(
      'href',
      'https://github.com/rcourtman/Pulse/releases/tag/v6.4.0',
    );
  });

  it('associates the backup polling switch with its visible label', () => {
    const [backupPollingEnabled, setBackupPollingEnabled] = createSignal(true);
    const [backupPollingInterval, setBackupPollingInterval] = createSignal(3600);
    const [backupPollingCustomMinutes, setBackupPollingCustomMinutes] = createSignal(60);
    const [backupPollingUseCustom, setBackupPollingUseCustom] = createSignal(false);
    const [showExportDialog, setShowExportDialog] = createSignal(false);
    const [showImportDialog, setShowImportDialog] = createSignal(false);

    render(() => (
      <RecoverySettingsPanel
        backupPollingEnabled={backupPollingEnabled}
        setBackupPollingEnabled={setBackupPollingEnabled}
        backupPollingInterval={backupPollingInterval}
        setBackupPollingInterval={setBackupPollingInterval}
        backupPollingCustomMinutes={backupPollingCustomMinutes}
        setBackupPollingCustomMinutes={setBackupPollingCustomMinutes}
        backupPollingUseCustom={backupPollingUseCustom}
        setBackupPollingUseCustom={setBackupPollingUseCustom}
        backupPollingEnvLocked={() => false}
        backupIntervalSelectValue={() => '3600'}
        backupIntervalSummary={() => 'Every hour'}
        setHasUnsavedChanges={vi.fn()}
        showExportDialog={showExportDialog}
        setShowExportDialog={setShowExportDialog}
        showImportDialog={showImportDialog}
        setShowImportDialog={setShowImportDialog}
      />
    ));

    expect(screen.getByRole('checkbox', { name: 'Enable backup polling' })).toBeChecked();
  });
});