mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 02:15:36 +00:00
test(image-analysis): cover runtime auth and fallback
This commit is contained in:
1 parent
813b2dd4d0
commit
f379a4001f
15 files changed
+1077
-52
No files matched your search
@@ -171,15 +171,22 @@ describe('profile lifecycle service', () => {
|
||||
fs.writeFileSync(path.join(ccsDir, 'config.json'), JSON.stringify({ profiles: {} }, null, 2) + '\n');
|
||||
fs.writeFileSync(path.join(ccsDir, 'config.yaml'), 'version: 12\nwebsearch:\n enabled: false\n', 'utf8');
|
||||
|
||||
const copyFileSpy = spyOn(fs, 'copyFileSync').mockImplementation(() => {
|
||||
throw new Error('copy should not run when WebSearch is disabled');
|
||||
const originalCopyFileSync = fs.copyFileSync.bind(fs);
|
||||
const copyFileSpy = spyOn(fs, 'copyFileSync').mockImplementation((source, destination) => {
|
||||
const sourcePath = String(source);
|
||||
const destinationPath = String(destination);
|
||||
if (sourcePath.includes('websearch') || destinationPath.includes('websearch')) {
|
||||
throw new Error('websearch copy should not run when WebSearch is disabled');
|
||||
}
|
||||
return originalCopyFileSync(source, destination);
|
||||
});
|
||||
|
||||
const result = await runInScopedCcsDir(() => registerApiProfileOrphans({ names: ['extra'] }));
|
||||
|
||||
expect(copyFileSpy).not.toHaveBeenCalled();
|
||||
expect(copyFileSpy).toHaveBeenCalled();
|
||||
expect(result.registered).toEqual(['extra']);
|
||||
expect(result.skipped).toEqual([]);
|
||||
expect(fs.existsSync(path.join(ccsDir, 'hooks', 'websearch-transformer.cjs'))).toBe(false);
|
||||
});
|
||||
|
||||
it('registers malformed orphan settings when force bypasses validation', async () => {
|
||||
|
||||
@@ -130,8 +130,14 @@ describe('profile-writer Anthropic direct', () => {
|
||||
'utf8'
|
||||
);
|
||||
|
||||
const copyFileSpy = spyOn(fs, 'copyFileSync').mockImplementation(() => {
|
||||
throw new Error('copy should not run when WebSearch is disabled');
|
||||
const originalCopyFileSync = fs.copyFileSync.bind(fs);
|
||||
const copyFileSpy = spyOn(fs, 'copyFileSync').mockImplementation((source, destination) => {
|
||||
const sourcePath = String(source);
|
||||
const destinationPath = String(destination);
|
||||
if (sourcePath.includes('websearch') || destinationPath.includes('websearch')) {
|
||||
throw new Error('websearch copy should not run when WebSearch is disabled');
|
||||
}
|
||||
return originalCopyFileSync(source, destination);
|
||||
});
|
||||
|
||||
const result = createApiProfile(
|
||||
@@ -142,9 +148,12 @@ describe('profile-writer Anthropic direct', () => {
|
||||
);
|
||||
|
||||
expect(result.success).toBe(true);
|
||||
expect(copyFileSpy).not.toHaveBeenCalled();
|
||||
expect(copyFileSpy).toHaveBeenCalled();
|
||||
expect(fs.existsSync(path.join(tempHome, '.ccs', 'disabled-websearch.settings.json'))).toBe(
|
||||
true
|
||||
);
|
||||
expect(fs.existsSync(path.join(tempHome, '.ccs', 'hooks', 'websearch-transformer.cjs'))).toBe(
|
||||
false
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user