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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
import { describe, it, expect, vi, beforeEach } from 'vitest';
vi.mock('../lib/imageCleanDefaults.js', () => ({
resolveImageCleaners: vi.fn(() => ({ cleanC2PA: false, denoise: false })),
}));
const mocks = vi.hoisted(() => ({
getUniverse: vi.fn(),
getSettings: vi.fn(),
enqueueJob: vi.fn(),
getImageModels: vi.fn(),
buildUniverseRunTag: vi.fn(),
claimPendingSheetSlot: vi.fn(),
}));
vi.mock('./universeBuilder.js', () => ({ getUniverse: (...args) => mocks.getUniverse(...args), updateUniverse: vi.fn() }));
vi.mock('./settings.js', () => ({ getSettings: (...args) => mocks.getSettings(...args) }));
vi.mock('./mediaJobQueue/index.js', () => ({
enqueueJob: (...args) => mocks.enqueueJob(...args),
getJob: vi.fn(),
mediaJobEvents: { on: vi.fn(), off: vi.fn() },
}));
vi.mock('./universeRunTag.js', () => ({ buildUniverseRunTag: (...args) => mocks.buildUniverseRunTag(...args) }));
vi.mock('./universeCharacterSheetSlot.js', () => ({
claimPendingSheetSlot: (...args) => mocks.claimPendingSheetSlot(...args),
getPendingSheetSlot: vi.fn(),
releasePendingSheetSlot: vi.fn(),
}));
vi.mock('../lib/mediaModels.js', async (importOriginal) => ({
...(await importOriginal()),
getImageModels: (...args) => mocks.getImageModels(...args),
}));
import { renderCharacterReferenceSheet } from './universeCharacterSheet.js';
const models = [
{ id: 'dev', hardwareCompatibility: { state: 'available' } },
{ id: 'pinned-model', hardwareCompatibility: { state: 'available' } },
{ id: 'incompatible-pin', hardwareCompatibility: { state: 'unavailable' } },
];
beforeEach(() => {
vi.clearAllMocks();
mocks.getUniverse.mockResolvedValue({
id: 'universe-1',
name: 'Example Universe',
influences: { embrace: [] },
characters: [{ id: 'character-1', name: 'Example Character' }],
});
mocks.getSettings.mockResolvedValue({
imageGen: { mode: 'local', local: { pythonPath: '/python', modelId: 'pinned-model' } },
});
mocks.enqueueJob.mockReturnValue({ jobId: 'job-1', position: 1 });
mocks.getImageModels.mockReturnValue(models);
mocks.buildUniverseRunTag.mockResolvedValue(null);
});
describe('renderCharacterReferenceSheet local model selection', () => {
it('queues the install-pinned model when the request has no model override', async () => {
await renderCharacterReferenceSheet('universe-1', 'character-1');
expect(mocks.enqueueJob.mock.calls[0][0].params.modelId).toBe('pinned-model');
});
it('skips an incompatible install pin and queues the compatible default', async () => {
mocks.getSettings.mockResolvedValue({
imageGen: { mode: 'local', local: { pythonPath: '/python', modelId: 'incompatible-pin' } },
});
await renderCharacterReferenceSheet('universe-1', 'character-1');
expect(mocks.enqueueJob.mock.calls[0][0].params.modelId).toBe('dev');
});
});
// Uniquely catches the sheet's universe style reaching the model unlisted, or a
// typed override being labeled with blocks it never carried (#11317).
describe('renderCharacterReferenceSheet prompt additions', () => {
it('lists the universe style and sheet negatives on a template render, and nothing on an override', async () => {
mocks.getUniverse.mockResolvedValue({
id: 'universe-1', name: 'Example Universe',
influences: { embrace: ['ink wash'] },
characters: [{ id: 'character-1', name: 'Example Character' }],
});
await renderCharacterReferenceSheet('universe-1', 'character-1');
const { params } = mocks.enqueueJob.mock.calls[0][0];
expect(params.promptAdditions.map((item) => item.id)).toEqual(['universe-style', 'sheet-negatives']);
expect(params.prompt).toContain(params.promptAdditions[0].text);
await renderCharacterReferenceSheet('universe-1', 'character-1', { overridePrompt: 'my own sheet', overrideNegativePrompt: 'blur' });
expect(mocks.enqueueJob.mock.calls[1][0].params.promptAdditions).toBeUndefined();
});
});