Write conversation package manifests
This commit is contained in:
@@ -89,3 +89,39 @@ test('MindSpace service facade builds manifests from package artifacts', async (
|
||||
'https://m.tkmind.cn/MindSpace/user-1/public/report.html',
|
||||
);
|
||||
});
|
||||
|
||||
test('MindSpace service facade writes manifest.json inside the conversation package', async () => {
|
||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'mindspace-service-'));
|
||||
const service = createMindSpaceServiceFacade({
|
||||
storageAdapter: createLocalMindSpaceStorageAdapter(root),
|
||||
publicBaseUrl: 'https://m.tkmind.cn',
|
||||
});
|
||||
const packageRecord = service.createConversationPackage({
|
||||
id: 'cp_session-1',
|
||||
userId: 'user-1',
|
||||
sessionId: 'session-1',
|
||||
now: 1000,
|
||||
});
|
||||
const artifact = service.createConversationArtifact({
|
||||
id: 'ca_report',
|
||||
packageId: packageRecord.id,
|
||||
artifactKind: 'public_html',
|
||||
displayName: 'report.html',
|
||||
sortOrder: 1,
|
||||
now: 2000,
|
||||
});
|
||||
|
||||
const result = await service.putConversationManifest({
|
||||
packageRecord,
|
||||
artifacts: [artifact],
|
||||
});
|
||||
|
||||
assert.equal(result.storageKey, 'users/user-1/conversations/session-1/manifest.json');
|
||||
const manifestJson = await service.getPackageObject({ packageRecord, relativePath: 'manifest.json' });
|
||||
const manifest = JSON.parse(manifestJson.toString('utf8'));
|
||||
assert.equal(manifest.packageId, 'cp_session-1');
|
||||
assert.deepEqual(
|
||||
manifest.artifacts.map((item) => item.artifactId),
|
||||
['ca_report'],
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user