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.

1.2 KB
Raw Blame
import { cleanup, render, screen } from '@solidjs/testing-library';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { AlertEmailDestinationsSection } from './AlertEmailDestinationsSection';
import type { UIEmailConfig } from './types';

vi.mock('@/api/notifications', () => ({
  NotificationsAPI: {
    getEmailProviders: vi.fn().mockResolvedValue([]),
  },
}));

function makeConfig(overrides: Partial<UIEmailConfig> = {}): UIEmailConfig {
  return {
    enabled: false,
    provider: '',
    server: '',
    port: 587,
    username: '',
    password: '',
    from: '',
    to: [],
    tls: false,
    startTLS: true,
    rateLimit: 10,
    ...overrides,
  };
}

describe('AlertEmailDestinationsSection', () => {
  afterEach(() => {
    cleanup();
  });

  it('associates the visible panel heading with its status toggle', () => {
    render(() => (
      <AlertEmailDestinationsSection
        config={makeConfig()}
        setConfig={vi.fn()}
        setHasUnsavedChanges={vi.fn()}
        onTest={vi.fn()}
        testing={false}
      />
    ));

    expect(screen.getByRole('button', { name: 'Email notifications Disabled' })).toHaveAttribute(
      'aria-pressed',
      'false',
    );
  });
});