Files
Genarrative/src/services/storyEngine/factionTensionState.test.ts
高物 ddcb5d5c8c
Some checks failed
CI / verify (push) Has been cancelled
Rework story engine flow and reorganize project docs
2026-04-06 23:19:00 +08:00

71 lines
2.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { type CustomWorldProfile,WorldType } from '../../types';
import { buildFactionTensionState } from './factionTensionState';
describe('factionTensionState', () => {
it('builds faction temperatures from active threads', () => {
const profile = {
id: 'world-1',
settingText: '裂潮边城',
name: '裂潮边城',
subtitle: '旧案回响',
summary: '一座在裂潮和旧案之间摇摇欲坠的边城。',
tone: '紧张、克制、暗流涌动',
playerGoal: '查清封桥旧令',
templateWorldType: WorldType.WUXIA,
majorFactions: ['巡边司'],
coreConflicts: ['封桥旧案再起'],
attributeSchema: {
id: 'schema',
worldId: 'world-1',
schemaVersion: 1,
generatedFrom: {
worldType: WorldType.CUSTOM,
worldName: '裂潮边城',
settingSummary: '裂潮边城',
tone: '紧张、克制、暗流涌动',
conflictCore: '封桥旧案再起',
},
slots: [],
},
playableNpcs: [],
storyNpcs: [],
items: [],
landmarks: [],
themePack: null,
storyGraph: {
visibleThreads: [
{
id: 'thread-1',
title: '巡边司的封桥旧案',
visibility: 'visible',
summary: '巡边司正在被封桥旧案拖住。',
conflictType: '调查',
stakes: '边城安稳',
involvedFactionIds: ['巡边司'],
involvedActorIds: [],
relatedLocationIds: [],
},
],
hiddenThreads: [],
scars: [],
motifs: [],
},
knowledgeFacts: null,
threadContracts: null,
} satisfies CustomWorldProfile;
const tensions = buildFactionTensionState(profile, {
discoveredFactIds: [],
inferredFactIds: [],
activeThreadIds: ['thread-1'],
resolvedScarIds: [],
recentCarrierIds: [],
});
expect(tensions[0]?.temperature).toBeGreaterThan(40);
expect(tensions[0]?.pressureSummary).toContain('巡边司');
});
});