🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
import { describe, expect, it } from 'vitest';
import { formatModifyNodesResult } from '../formatModifyNodesResult';
describe('formatModifyNodesResult', () => {
it('summarises a fully applied batch', () => {
expect(
formatModifyNodesResult({
results: [
{ action: 'insert', success: true },
{ action: 'insert', success: true },
],
successCount: 2,
totalCount: 2,
}),
).toBe('Successfully executed 2 inserts (2/2 operations succeeded).');
});
it('does not report a partially applied batch as a success', () => {
const content = formatModifyNodesResult({
results: [
{ action: 'modify', error: 'node "zzzz" not found in the document', success: false },
{ action: 'insert', success: true },
],
successCount: 1,
totalCount: 2,
});
expect(content).not.toContain('Successfully');
expect(content).toMatchInlineSnapshot(`
"Only 1/2 operations succeeded (1 modify, 1 insert requested). Failed operations were not applied:
- Operation 1 (modify): node "zzzz" not found in the document
Re-read /doc.xml to get the current node ids before retrying the failed edits."
`);
});
it('flags an operation that failed after part of it was applied', () => {
const content = formatModifyNodesResult({
results: [
{
action: 'modify',
error: 'node "zzzz" not found in the document',
partiallyApplied: true,
success: false,
},
],
successCount: 0,
totalCount: 1,
});
expect(content).toContain('except those marked PARTIALLY APPLIED');
expect(content).toContain('- Operation 1 (modify): PARTIALLY APPLIED');
expect(content).toContain('Re-read /doc.xml');
expect(content).not.toContain('getPageContent');
});
});