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.

6.6 KB
Raw Blame
import { readFileSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
import { renderDocMarkdown, stripLeadingTitle } from '../docMarkdown';

const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../..');
const shippedDocs = path.join(repoRoot, 'frontend-modern/public/docs');
const readGuide = (name: string) =>
  readFileSync(
    process.env[`PULSE_${name}_GUIDE_TEST_INPUT`] ?? path.join(shippedDocs, `${name}.md`),
    'utf8',
  );
const source = readGuide('AI_TRANSPARENCY');

function renderGuide(name: string, markdown: string): HTMLElement {
  const article = document.createElement('article');
  article.innerHTML = renderDocMarkdown(stripLeadingTitle(markdown), name);
  return article;
}

function followThrough(): HTMLElement {
  const article = renderGuide('AI_TRANSPARENCY', source);
  const heading = article.querySelector('#issue-resolution-and-retesting');
  expect(heading?.tagName).toBe('H2');
  const section = document.createElement('section');
  for (let next = heading!.nextElementSibling; next; next = next.nextElementSibling) {
    if (next.tagName === 'H2') break;
    section.appendChild(next.cloneNode(true));
  }
  return section;
}

const prose = (element: Element): string => (element.textContent ?? '').replace(/\s+/g, ' ').trim();

describe('public issue follow-through guidance', () => {
  it('keeps resolution, stable-release retest and timeout distinct in rendered paragraphs', () => {
    const paragraphs = followThrough().querySelectorAll('p');
    expect(paragraphs).toHaveLength(3);
    expect(prose(paragraphs[0])).toContain('no reported symptom left unresolved');
    expect(prose(paragraphs[0])).toContain('A merged fix or a workaround alone is not enough');
    expect(prose(paragraphs[1])).toContain('Once the fix ships in a stable release');
    expect(prose(paragraphs[1])).toContain('After 14 days with no reply');
    expect(prose(paragraphs[1])).toContain('nobody else reporting the same problem');
    const emphasis = paragraphs[1].querySelector('strong');
    expect(emphasis).not.toBeNull();
    expect(prose(emphasis!)).toBe('not confirmed resolution');
    expect(prose(paragraphs[1])).toContain('unexplained symptoms are never closed this way');
  });

  it('keeps the existing issue and safe evidence route usable without new collection', () => {
    const section = followThrough();
    expect(prose(section)).toContain('original issue rather than filing it again');
    expect(prose(section)).toContain("Don't repeat an outage, update or backup");
    expect(section.querySelector('pre, form, input, button')).toBeNull();
    const link = section.querySelector('a');
    expect(link?.getAttribute('href')).toBe('/docs/TROUBLESHOOTING#collect-diagnostics-safely');
    expect(link?.hasAttribute('data-doc-link')).toBe(true);
    expect(link?.hasAttribute('target')).toBe(false);
    const target = renderGuide(
      'TROUBLESHOOTING',
      readFileSync(path.join(shippedDocs, 'TROUBLESHOOTING.md'), 'utf8'),
    );
    expect(target.querySelector('#collect-diagnostics-safely')?.tagName).toBe('H3');
  });

  it('ships the same explanation at the standing triage footer destination', () => {
    expect(source).toBe(readFileSync(path.join(repoRoot, 'docs/AI_TRANSPARENCY.md'), 'utf8'));
    const article = renderGuide('AI_TRANSPARENCY', source);
    expect(article.querySelector('#how-changes-land-and-ship')).not.toBeNull();
    expect(article.querySelector('#authority-and-responsibility')).not.toBeNull();
  });

  it('keeps the disclosure and its linked release guide on the weekly, no-early-cut policy', () => {
    const article = renderGuide('AI_TRANSPARENCY', source);
    const text = prose(article);
    expect(text).toContain('Releases follow a fixed weekly train');
    expect(text).toContain('soaks for 24 hours and is promoted unchanged to stable');
    expect(text).toContain('unless a release-blocker issue stops it');
    expect(text).not.toContain('Every 14 days');
    expect(text).not.toContain('An early cut can bring');
    expect(
      article.querySelector('a[href="/docs/RELEASE_PROCESS"]')?.hasAttribute('data-doc-link'),
    ).toBe(true);
    const releaseSource = readGuide('RELEASE_PROCESS');
    expect(releaseSource).toBe(
      readFileSync(path.join(repoRoot, 'docs/RELEASE_PROCESS.md'), 'utf8'),
    );
    const release = renderGuide('RELEASE_PROCESS', releaseSource);
    expect(prose(release)).toContain('Nothing brings that cut forward');
    expect(prose(release)).toContain('an important fix ships in the next daily beta');
    expect(prose(release)).toContain('Only a release-blocker requires a fresh candidate');
    expect(prose(release)).not.toContain('can bring');
  });

  it('makes the unavailable patch path explicit in both consumed guides', () => {
    expect(prose(renderGuide('AI_TRANSPARENCY', source))).toContain(
      'Stable patches are not yet available',
    );
    const text = prose(renderGuide('RELEASE_PROCESS', readGuide('RELEASE_PROCESS')));
    expect(text).toContain('As of 27 October 2026, stable patches are not yet available');
    expect(text).toContain('containing minor release');
    expect(text).toContain('eligible repairs already merged to main');
    expect(text).toContain('release metadata and publication support');
    expect(text).toContain('stable-regression');
    expect(text).not.toContain('Patch releases are not scheduled');
  });

  it('links the public triage disclosure to the actual scoped patch guidance', () => {
    const article = renderGuide('AI_TRANSPARENCY', source);
    const link = article.querySelector<HTMLAnchorElement>(
      'a[href="/docs/RELEASE_PROCESS#limited-stable-patches"]',
    );
    expect(link?.textContent).toBe('limited stable patches');
    expect(link?.hasAttribute('data-doc-link')).toBe(true);
    const release = renderGuide('RELEASE_PROCESS', readGuide('RELEASE_PROCESS'));
    const heading = release.querySelector(new URL(link!.href).hash);
    expect(heading?.tagName).toBe('H3');
    const status = heading!.nextElementSibling;
    expect(status?.querySelector('strong')?.textContent).toBe(
      'As of 27 October 2026, stable patches are not yet available.',
    );
    expect(prose(status!)).toContain('is not an available update');
    expect(prose(release)).toContain('A stable patch does not restart this weekly clock');
    expect(prose(release)).toContain('does not move the next minor');
    expect(prose(release)).toContain('patch delivery is not guaranteed for every labelled issue');
    expect(prose(release)).toContain('Do not downgrade, repeat an unsafe operation');
  });
});