chore: makes tests pass.
This commit is contained in:
14
tests/fixture/test-tasks.json
Normal file
14
tests/fixture/test-tasks.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"dependencies": [],
|
||||||
|
"subtasks": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"dependencies": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -211,6 +211,9 @@ describe('AI Client Utilities', () => {
|
|||||||
|
|
||||||
it('should return Claude when Perplexity is not available and Claude is not overloaded', async () => {
|
it('should return Claude when Perplexity is not available and Claude is not overloaded', async () => {
|
||||||
// Setup
|
// Setup
|
||||||
|
const originalPerplexityKey = process.env.PERPLEXITY_API_KEY;
|
||||||
|
delete process.env.PERPLEXITY_API_KEY; // Make sure Perplexity is not available in process.env
|
||||||
|
|
||||||
const session = {
|
const session = {
|
||||||
env: {
|
env: {
|
||||||
ANTHROPIC_API_KEY: 'test-anthropic-key'
|
ANTHROPIC_API_KEY: 'test-anthropic-key'
|
||||||
@@ -219,15 +222,22 @@ describe('AI Client Utilities', () => {
|
|||||||
};
|
};
|
||||||
const mockLog = { warn: jest.fn(), info: jest.fn(), error: jest.fn() };
|
const mockLog = { warn: jest.fn(), info: jest.fn(), error: jest.fn() };
|
||||||
|
|
||||||
// Execute
|
try {
|
||||||
const result = await getBestAvailableAIModel(session, { requiresResearch: true }, mockLog);
|
// Execute
|
||||||
|
const result = await getBestAvailableAIModel(session, { requiresResearch: true }, mockLog);
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
// In our implementation, we prioritize research capability through Perplexity
|
// In our implementation, we prioritize research capability through Perplexity
|
||||||
// so if we're testing research but Perplexity isn't available, Claude is used
|
// so if we're testing research but Perplexity isn't available, Claude is used
|
||||||
expect(result.type).toBe('perplexity');
|
expect(result.type).toBe('claude');
|
||||||
expect(result.client).toBeDefined();
|
expect(result.client).toBeDefined();
|
||||||
expect(mockLog.warn).not.toHaveBeenCalled(); // No warning since implementation succeeds
|
expect(mockLog.warn).toHaveBeenCalled(); // Warning about using Claude instead of Perplexity
|
||||||
|
} finally {
|
||||||
|
// Restore original env variables
|
||||||
|
if (originalPerplexityKey) {
|
||||||
|
process.env.PERPLEXITY_API_KEY = originalPerplexityKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fall back to Claude as last resort when overloaded', async () => {
|
it('should fall back to Claude as last resort when overloaded', async () => {
|
||||||
|
|||||||
@@ -236,7 +236,8 @@ describe('Utils Module', () => {
|
|||||||
|
|
||||||
expect(fsWriteFileSyncSpy).toHaveBeenCalledWith(
|
expect(fsWriteFileSyncSpy).toHaveBeenCalledWith(
|
||||||
'output.json',
|
'output.json',
|
||||||
JSON.stringify(testData, null, 2)
|
JSON.stringify(testData, null, 2),
|
||||||
|
'utf8'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user