Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

1.5 KB
Raw Blame
import { describe, it, expect, vi } from 'vitest';
vi.mock('./repoCleanupObservation.js', () => ({
  readCheckoutPathPresence: vi.fn(async () => false),
  readLocalBranchPresence: vi.fn(async () => false),
}));
import { findGoneInventoryRows } from './branchReconcileInventoryPrune.js';
import { readCheckoutPathPresence } from './repoCleanupObservation.js';

describe('historical checkout inventory', () => {
  it('keeps remote-only holds when their local branch is absent, while pruning missing local branches', async () => {
    const remote = { branch: 'fix/remote-only', reason: 'remote-branch-held' };
    const local = { branch: 'fix/gone', reason: 'actionable' };
    expect(await findGoneInventoryRows('/repo', [remote, local], { includeObligations: true })).toEqual([local]);
  });

  it('reports missing obligation originals only for display, preserving the default pruning contract', async () => {
    const obligation = { path: '/old', branch: 'fix/example', reason: 'retirement-receipt-unverified' };
    const rows = [obligation];
    expect(await findGoneInventoryRows('/repo', rows)).toEqual([]);
    expect(await findGoneInventoryRows('/repo', rows, { includeObligations: true })).toEqual([obligation]);
    readCheckoutPathPresence.mockResolvedValueOnce(true);
    expect(await findGoneInventoryRows('/repo', rows, { includeObligations: true })).toEqual([]);
    readCheckoutPathPresence.mockResolvedValueOnce(null);
    await expect(findGoneInventoryRows('/repo', rows, { includeObligations: true })).rejects.toThrow('checkout-presence-unavailable');
  });
});