seogeneratorserver/tests/llm/retry-logic.test.js
StillHammer dbf1a3de8c Add technical plan for multi-format export system
Added plan.md with complete architecture for format-agnostic content generation:
- Support for Markdown, HTML, Plain Text, JSON formats
- New FormatExporter module with neutral data structure
- Integration strategy with existing ContentAssembly and ArticleStorage
- Bonus features: SEO metadata generation, readability scoring, WordPress Gutenberg format
- Implementation roadmap with 4 phases (6h total estimated)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 16:14:29 +08:00

33 lines
1.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import test from 'node:test';
import assert from 'node:assert';
import { safeImport } from '../_helpers/path.js';
import { MockLLMManager } from '../_helpers/mockLLMManager.js';
test('LLM transient error is retried or bubbled cleanly', async () => {
const mgrRes = safeImport('LLMManager');
if (!mgrRes.ok || typeof mgrRes.mod.callModel !== 'function') {
console.warn('[SKIP] LLMManager.callModel missing');
return;
}
// On teste la nôtre (mock) pour vérifier le comportement désiré,
// puis on appelle la “vraie” et on vérifie au moins la remontée derreur propre.
const mock = new MockLLMManager({ failTimes: 2, failCode: 429 });
const ok = await mock.callModel({ input:'test' }).catch(e => e);
// après 2 fails, la troisième doit passer:
const ok2 = await mock.callModel({ input:'test 2' });
assert.ok(ok2.completion?.startsWith('MOCK'));
// Vraie impl: au minimum, quelle throw une Error avec statusCode si pas de retry
let threw = false;
try {
await mgrRes.mod.callModel({ provider:'X', model:'Y', input:'Z', __forceFail429:true });
} catch (e) {
threw = true;
// Pas obligatoire davoir statusCode, mais on log si présent
if (e?.statusCode) {
assert.ok([429,500,502,503,504].includes(e.statusCode));
}
}
assert.ok(threw, 'real callModel should throw or handle gracefully when forced to fail');
});