From de45fa0da9d1345dff5871a71af7bbedb235076f Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Sat, 20 Dec 2025 19:50:40 -0500 Subject: [PATCH] test(npm): update tests for preset-based profile creation - update postinstall tests to expect empty profiles - add test verifying GLM/GLMT/Kimi not auto-created - update CLI profile tests to handle optional profiles - remove hardcoded GLM profile expectations --- tests/npm/cli.test.js | 23 ++++++++++++++++------- tests/npm/postinstall.test.js | 18 ++++++++++-------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/tests/npm/cli.test.js b/tests/npm/cli.test.js index ac807bf8..a05675e3 100644 --- a/tests/npm/cli.test.js +++ b/tests/npm/cli.test.js @@ -77,12 +77,21 @@ describe('npm CLI', () => { }); describe('Profile handling', () => { - it('loads glm profile', function() { + // Note: GLM/GLMT/Kimi profiles are no longer auto-created (v6.0) + // Users create these via UI presets or CLI: ccs api create --preset glm + + it('shows helpful error for non-existent profile', function() { try { runCli('glm --help', { stdio: 'pipe' }); + // If GLM profile exists from previous setup, this is fine too } catch (e) { - const output = e.stderr?.toString() || ''; - assert(!output.includes("Profile 'glm' not found"), 'GLM profile should exist'); + const output = e.stderr?.toString() || e.stdout?.toString() || ''; + // Either profile exists and works, or shows helpful "not found" message + // Both are valid behaviors depending on user's setup + const isValid = !output.includes("Profile 'glm' not found") || + output.includes("not found") || + output.includes("ccs api create"); + assert(isValid, 'Should either find profile or show helpful message'); } }); @@ -96,13 +105,13 @@ describe('npm CLI', () => { } }); - it('handles profile with flags', function() { + it('handles profile with flags correctly', function() { try { - runCli('glm -c', { stdio: 'pipe', timeout: 3000 }); + // Use a known command instead of profile that may not exist + runCli('api --help', { stdio: 'pipe', timeout: 3000 }); } catch (e) { const output = e.stderr?.toString() || ''; - assert(!output.includes("Profile 'glm' not found"), 'GLM profile should exist'); - assert(!output.includes("Profile '-c' not found"), 'Should not treat -c as profile'); + assert(!output.includes("Profile '-c' not found"), 'Should not treat flags as profiles'); } }); }); diff --git a/tests/npm/postinstall.test.js b/tests/npm/postinstall.test.js index 0032e117..07572362 100644 --- a/tests/npm/postinstall.test.js +++ b/tests/npm/postinstall.test.js @@ -30,20 +30,21 @@ describe('npm postinstall', () => { const config = testEnv.readFile('config.json', true); assert(config.profiles, 'config.json should have profiles'); assert(typeof config.profiles === 'object', 'profiles should be an object'); + // Profiles are now empty by default - users create via presets + assert.deepStrictEqual(config.profiles, {}, 'profiles should be empty by default'); }); - it('creates glm.settings.json', () => { + it('does NOT auto-create glm.settings.json (v6.0 - use presets instead)', () => { execSync(`node "${postinstallScript}"`, { stdio: 'ignore', env: { ...process.env, CCS_HOME: testEnv.testHome } }); - assert(testEnv.fileExists('glm.settings.json'), 'glm.settings.json should be created'); - - const glmSettings = testEnv.readFile('glm.settings.json', true); - assert(glmSettings.env, 'glm.settings.json should have env section'); - assert(glmSettings.env.ANTHROPIC_MODEL, 'should have ANTHROPIC_MODEL set'); - assert.strictEqual(glmSettings.env.ANTHROPIC_MODEL, 'glm-4.6'); + // GLM/GLMT/Kimi profiles are NO LONGER auto-created during install + // Users create these via UI presets or CLI: ccs api create --preset glm + assert(!testEnv.fileExists('glm.settings.json'), 'glm.settings.json should NOT be auto-created'); + assert(!testEnv.fileExists('glmt.settings.json'), 'glmt.settings.json should NOT be auto-created'); + assert(!testEnv.fileExists('kimi.settings.json'), 'kimi.settings.json should NOT be auto-created'); }); it('is idempotent', () => { @@ -97,7 +98,8 @@ describe('npm postinstall', () => { // Verify existing file still exists and new files are created assert(testEnv.fileExists('existing.txt'), 'Existing files should be preserved'); assert(testEnv.fileExists('config.json'), 'config.json should be created'); - assert(testEnv.fileExists('glm.settings.json'), 'glm.settings.json should be created'); + // GLM/GLMT/Kimi are no longer auto-created + assert(!testEnv.fileExists('glm.settings.json'), 'glm.settings.json should NOT be auto-created'); }); it('does not create VERSION file', () => {