claude-task-master/tests/integration/profiles/gemini-init-functionality.test.js

75 lines
3.2 KiB
JavaScript
Raw Normal View History

Unify and streamline profile system architecture (#853) * move claude rules and commands to assets/claude * update claude profile to copy assets/claude to .claude * fix formatting * feat(profiles): Implement unified profile system - Convert Claude and Codex profiles to use createProfile() factory - Remove simple vs complex profile distinction in rule transformer - Unify convertAllRulesToProfileRules() to handle all profiles consistently - Fix mcpConfigPath construction in base-profile.js for null mcpConfigName - Update terminology from 'simpleProfiles' to 'assetOnlyProfiles' throughout - Ensure Claude .claude directory copying works in both CLI and MCP contexts - All profiles now follow same execution flow with proper lifecycle functions Changes: - src/profiles/claude.js: Convert to createProfile() factory pattern - src/profiles/codex.js: Convert to createProfile() factory pattern - src/utils/rule-transformer.js: Unified profile handling logic - src/utils/profiles.js: Remove simple profile categorization - src/profiles/base-profile.js: Fix mcpConfigPath construction - scripts/modules/commands.js: Update variable naming - tests/: Update all tests for unified system and terminology Fixes Claude profile asset copying issue in MCP context. All tests passing (617 passed, 11 skipped). * re-checkin claude files * fix formatting * chore: clean up test Claude rules files * chore: add changeset for unified profile system * add claude files back * add changeset * restore proper gitignore * remove claude agents file from root * remove incorrect doc * simplify profiles and update tests * update changeset * update changeset * remove profile specific code * streamline profiles with defaults and update tests * update changeset * add newline at end of gitignore * restore changes * streamline profiles with defaults; update tests and add vscode test * update rule profile tests * update wording for clearer profile management * refactor and clarify terminology * use original projectRoot var name * revert param desc * use updated claude assets from neno * add "YOUR_" before api key here * streamline codex profile * add gemini profile * update gemini profile * update tests * relocate function * update rules interactive setup Gemini desc * remove duplicative code * add comma
2025-07-09 07:22:11 -04:00
import fs from 'fs';
import path from 'path';
import { geminiProfile } from '../../../src/profiles/gemini.js';
describe('Gemini Profile Initialization Functionality', () => {
let geminiProfileContent;
beforeAll(() => {
const geminiJsPath = path.join(
process.cwd(),
'src',
'profiles',
'gemini.js'
);
geminiProfileContent = fs.readFileSync(geminiJsPath, 'utf8');
});
test('gemini.js has correct profile configuration', () => {
// Check for explicit, non-default values in the source file
expect(geminiProfileContent).toContain("name: 'gemini'");
expect(geminiProfileContent).toContain("displayName: 'Gemini'");
expect(geminiProfileContent).toContain("url: 'codeassist.google'");
expect(geminiProfileContent).toContain(
"docsUrl: 'github.com/google-gemini/gemini-cli'"
);
expect(geminiProfileContent).toContain("profileDir: '.gemini'");
expect(geminiProfileContent).toContain("rulesDir: '.'"); // non-default
expect(geminiProfileContent).toContain("mcpConfigName: 'settings.json'"); // non-default
expect(geminiProfileContent).toContain('includeDefaultRules: false'); // non-default
expect(geminiProfileContent).toContain("'AGENT.md': 'AGENTS.md'");
expect(geminiProfileContent).toContain("'GEMINI.md': 'GEMINI.md'");
Unify and streamline profile system architecture (#853) * move claude rules and commands to assets/claude * update claude profile to copy assets/claude to .claude * fix formatting * feat(profiles): Implement unified profile system - Convert Claude and Codex profiles to use createProfile() factory - Remove simple vs complex profile distinction in rule transformer - Unify convertAllRulesToProfileRules() to handle all profiles consistently - Fix mcpConfigPath construction in base-profile.js for null mcpConfigName - Update terminology from 'simpleProfiles' to 'assetOnlyProfiles' throughout - Ensure Claude .claude directory copying works in both CLI and MCP contexts - All profiles now follow same execution flow with proper lifecycle functions Changes: - src/profiles/claude.js: Convert to createProfile() factory pattern - src/profiles/codex.js: Convert to createProfile() factory pattern - src/utils/rule-transformer.js: Unified profile handling logic - src/utils/profiles.js: Remove simple profile categorization - src/profiles/base-profile.js: Fix mcpConfigPath construction - scripts/modules/commands.js: Update variable naming - tests/: Update all tests for unified system and terminology Fixes Claude profile asset copying issue in MCP context. All tests passing (617 passed, 11 skipped). * re-checkin claude files * fix formatting * chore: clean up test Claude rules files * chore: add changeset for unified profile system * add claude files back * add changeset * restore proper gitignore * remove claude agents file from root * remove incorrect doc * simplify profiles and update tests * update changeset * update changeset * remove profile specific code * streamline profiles with defaults and update tests * update changeset * add newline at end of gitignore * restore changes * streamline profiles with defaults; update tests and add vscode test * update rule profile tests * update wording for clearer profile management * refactor and clarify terminology * use original projectRoot var name * revert param desc * use updated claude assets from neno * add "YOUR_" before api key here * streamline codex profile * add gemini profile * update gemini profile * update tests * relocate function * update rules interactive setup Gemini desc * remove duplicative code * add comma
2025-07-09 07:22:11 -04:00
// Check the final computed properties on the profile object
expect(geminiProfile.profileName).toBe('gemini');
expect(geminiProfile.displayName).toBe('Gemini');
expect(geminiProfile.profileDir).toBe('.gemini');
expect(geminiProfile.rulesDir).toBe('.');
expect(geminiProfile.mcpConfig).toBe(true); // computed from mcpConfigName
expect(geminiProfile.mcpConfigName).toBe('settings.json');
expect(geminiProfile.mcpConfigPath).toBe('.gemini/settings.json'); // computed
expect(geminiProfile.includeDefaultRules).toBe(false);
expect(geminiProfile.fileMap['AGENT.md']).toBe('AGENTS.md');
expect(geminiProfile.fileMap['GEMINI.md']).toBe('GEMINI.md');
Unify and streamline profile system architecture (#853) * move claude rules and commands to assets/claude * update claude profile to copy assets/claude to .claude * fix formatting * feat(profiles): Implement unified profile system - Convert Claude and Codex profiles to use createProfile() factory - Remove simple vs complex profile distinction in rule transformer - Unify convertAllRulesToProfileRules() to handle all profiles consistently - Fix mcpConfigPath construction in base-profile.js for null mcpConfigName - Update terminology from 'simpleProfiles' to 'assetOnlyProfiles' throughout - Ensure Claude .claude directory copying works in both CLI and MCP contexts - All profiles now follow same execution flow with proper lifecycle functions Changes: - src/profiles/claude.js: Convert to createProfile() factory pattern - src/profiles/codex.js: Convert to createProfile() factory pattern - src/utils/rule-transformer.js: Unified profile handling logic - src/utils/profiles.js: Remove simple profile categorization - src/profiles/base-profile.js: Fix mcpConfigPath construction - scripts/modules/commands.js: Update variable naming - tests/: Update all tests for unified system and terminology Fixes Claude profile asset copying issue in MCP context. All tests passing (617 passed, 11 skipped). * re-checkin claude files * fix formatting * chore: clean up test Claude rules files * chore: add changeset for unified profile system * add claude files back * add changeset * restore proper gitignore * remove claude agents file from root * remove incorrect doc * simplify profiles and update tests * update changeset * update changeset * remove profile specific code * streamline profiles with defaults and update tests * update changeset * add newline at end of gitignore * restore changes * streamline profiles with defaults; update tests and add vscode test * update rule profile tests * update wording for clearer profile management * refactor and clarify terminology * use original projectRoot var name * revert param desc * use updated claude assets from neno * add "YOUR_" before api key here * streamline codex profile * add gemini profile * update gemini profile * update tests * relocate function * update rules interactive setup Gemini desc * remove duplicative code * add comma
2025-07-09 07:22:11 -04:00
});
test('gemini.js has no lifecycle functions', () => {
// Gemini profile should not have any lifecycle functions
expect(geminiProfileContent).not.toContain('function onAddRulesProfile');
expect(geminiProfileContent).not.toContain('function onRemoveRulesProfile');
expect(geminiProfileContent).not.toContain(
'function onPostConvertRulesProfile'
);
expect(geminiProfileContent).not.toContain('onAddRulesProfile:');
expect(geminiProfileContent).not.toContain('onRemoveRulesProfile:');
expect(geminiProfileContent).not.toContain('onPostConvertRulesProfile:');
});
test('gemini.js uses custom MCP config name', () => {
// Gemini uses settings.json instead of mcp.json
expect(geminiProfileContent).toContain("mcpConfigName: 'settings.json'");
// Should not contain mcp.json as a config value (comments are OK)
expect(geminiProfileContent).not.toMatch(
/mcpConfigName:\s*['"]mcp\.json['"]/
);
});
test('gemini.js has minimal implementation', () => {
// Verify the profile is minimal (no extra functions or logic)
const lines = geminiProfileContent.split('\n');
const nonEmptyLines = lines.filter((line) => line.trim().length > 0);
// Should be around 16 lines (import, export, and profile definition)
expect(nonEmptyLines.length).toBeLessThan(20);
});
});