Files
Badri Narayanan S 683ca41480 fix: strip cache_control fields from content blocks (#189)
Claude Code CLI sends cache_control on text, thinking, tool_use, and
tool_result blocks for prompt caching. Cloud Code API rejects these
with "Extra inputs are not permitted".

- Add cleanCacheControl() to proactively strip cache_control at pipeline entry
- Add sanitizeTextBlock() and sanitizeToolUseBlock() for defense-in-depth
- Update reorderAssistantContent() to use block sanitizers
- Add test-cache-control.cjs with multi-model test coverage
- Update frontend dashboard tests to match current UI design
- Update strategy tests to match v2.4.0 fallback behavior
- Update CLAUDE.md and README.md with recent features

Inspired by Antigravity-Manager's clean_cache_control_from_messages() pattern.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-25 03:27:05 +05:30

109 lines
4.8 KiB
JavaScript

#!/usr/bin/env node
/**
* Test Runner
*
* Runs all tests in sequence and reports results.
* Usage: node tests/run-all.cjs
*/
const { spawn } = require('child_process');
const path = require('path');
const tests = [
{ name: 'Account Selection Strategies', file: 'test-strategies.cjs' },
{ name: 'Cache Control Stripping', file: 'test-cache-control.cjs' },
{ name: 'Thinking Signatures', file: 'test-thinking-signatures.cjs' },
{ name: 'Multi-turn Tools (Non-Streaming)', file: 'test-multiturn-thinking-tools.cjs' },
{ name: 'Multi-turn Tools (Streaming)', file: 'test-multiturn-thinking-tools-streaming.cjs' },
{ name: 'Interleaved Thinking', file: 'test-interleaved-thinking.cjs' },
{ name: 'Image Support', file: 'test-images.cjs' },
{ name: 'Prompt Caching', file: 'test-caching-streaming.cjs' },
{ name: 'Cross-Model Thinking', file: 'test-cross-model-thinking.cjs' },
{ name: 'OAuth No-Browser Mode', file: 'test-oauth-no-browser.cjs' },
{ name: 'Empty Response Retry', file: 'test-empty-response-retry.cjs' },
{ name: 'Schema Sanitizer', file: 'test-schema-sanitizer.cjs' },
{ name: 'Streaming Whitespace', file: 'test-streaming-whitespace.cjs' }
];
async function runTest(test) {
return new Promise((resolve) => {
const testPath = path.join(__dirname, test.file);
const child = spawn('node', [testPath], {
stdio: 'inherit'
});
child.on('close', (code) => {
resolve({ ...test, passed: code === 0 });
});
child.on('error', (err) => {
console.error(`Error running ${test.name}:`, err);
resolve({ ...test, passed: false });
});
});
}
async function main() {
console.log('╔══════════════════════════════════════════════════════════════╗');
console.log('║ ANTIGRAVITY PROXY TEST SUITE ║');
console.log('╚══════════════════════════════════════════════════════════════╝');
console.log('');
console.log('Make sure the server is running on port 8080 before running tests.');
console.log('');
// Check if running specific test
const specificTest = process.argv[2];
let testsToRun = tests;
if (specificTest) {
testsToRun = tests.filter(t =>
t.file.includes(specificTest) || t.name.toLowerCase().includes(specificTest.toLowerCase())
);
if (testsToRun.length === 0) {
console.log(`No test found matching: ${specificTest}`);
console.log('\nAvailable tests:');
tests.forEach(t => console.log(` - ${t.name} (${t.file})`));
process.exit(1);
}
}
const results = [];
for (const test of testsToRun) {
console.log('\n');
console.log('╔' + '═'.repeat(60) + '╗');
console.log('║ Running: ' + test.name.padEnd(50) + '║');
console.log('╚' + '═'.repeat(60) + '╝');
console.log('');
const result = await runTest(test);
results.push(result);
console.log('\n');
}
// Summary
console.log('╔══════════════════════════════════════════════════════════════╗');
console.log('║ FINAL RESULTS ║');
console.log('╠══════════════════════════════════════════════════════════════╣');
let allPassed = true;
for (const result of results) {
const status = result.passed ? '✓ PASS' : '✗ FAIL';
const statusColor = result.passed ? '' : '';
console.log(`${status.padEnd(8)} ${result.name.padEnd(50)}`);
if (!result.passed) allPassed = false;
}
console.log('╠══════════════════════════════════════════════════════════════╣');
const overallStatus = allPassed ? '✓ ALL TESTS PASSED' : '✗ SOME TESTS FAILED';
console.log(`${overallStatus.padEnd(60)}`);
console.log('╚══════════════════════════════════════════════════════════════╝');
process.exit(allPassed ? 0 : 1);
}
main().catch(err => {
console.error('Test runner failed:', err);
process.exit(1);
});