Files
claude-task-master/tests/integration/roo-init-functionality.test.js
Eyal Toledano 75b7b93fa4 feat(task-90): Complete telemetry integration with /auth/init + fix Roo test brittleness
- Updated telemetry submission to use /auth/init endpoint instead of /api/v1/users
- Hardcoded gateway endpoint to http://localhost:4444/api/v1/telemetry for all users
- Removed unnecessary service API key complexity - simplified authentication
- Enhanced init.js with hosted gateway setup option and user registration
- Added configureTelemetrySettings() to update .taskmasterconfig with credentials
- Fixed brittle Roo integration tests that required exact string matching
- Updated tests to use flexible regex patterns supporting any quote style
- All test suites now green: 332 tests passed, 11 skipped, 0 failed
- All 11 telemetry tests passing with live gateway integration verified
- Ready for ai-services-unified.js integration in subtask 90.3
2025-05-28 22:38:18 -04:00

71 lines
2.7 KiB
JavaScript

import { jest } from "@jest/globals";
import fs from "fs";
import path from "path";
describe("Roo Initialization Functionality", () => {
let initJsContent;
beforeAll(() => {
// Read the init.js file content once for all tests
const initJsPath = path.join(process.cwd(), "scripts", "init.js");
initJsContent = fs.readFileSync(initJsPath, "utf8");
});
test("init.js creates Roo directories in createProjectStructure function", () => {
// Check if createProjectStructure function exists
expect(initJsContent).toContain("function createProjectStructure");
// Check for the line that creates the .roo directory (flexible quote matching)
const hasRooDir =
/ensureDirectoryExists\(path\.join\(targetDir,\s*['""]\.roo['""]/.test(
initJsContent
);
expect(hasRooDir).toBe(true);
// Check for the line that creates .roo/rules directory (flexible quote matching)
const hasRooRulesDir =
/ensureDirectoryExists\(path\.join\(targetDir,\s*['""]\.roo['""],\s*['""]rules['""]/.test(
initJsContent
);
expect(hasRooRulesDir).toBe(true);
// Check for the for loop that creates mode-specific directories (flexible matching)
const hasRooModeLoop =
(initJsContent.includes("for (const mode of [") ||
initJsContent.includes("for (const mode of[")) &&
initJsContent.includes("architect") &&
initJsContent.includes("ask") &&
initJsContent.includes("boomerang") &&
initJsContent.includes("code") &&
initJsContent.includes("debug") &&
initJsContent.includes("test");
expect(hasRooModeLoop).toBe(true);
});
test("init.js copies Roo files from assets/roocode directory", () => {
// Check for the .roomodes case in the copyTemplateFile function (flexible quote matching)
const casesRoomodes = /case\s*['""]\.roomodes['""]/.test(initJsContent);
expect(casesRoomodes).toBe(true);
// Check that assets/roocode appears somewhere in the file (flexible quote matching)
const hasRoocodePath = /['""]assets['""],\s*['""]roocode['""]/.test(
initJsContent
);
expect(hasRoocodePath).toBe(true);
// Check that roomodes file is copied (flexible quote matching)
const copiesRoomodes = /copyTemplateFile\(\s*['""]\.roomodes['""]/.test(
initJsContent
);
expect(copiesRoomodes).toBe(true);
});
test("init.js has code to copy rule files for each mode", () => {
// Look for template copying for rule files (more flexible matching)
const hasModeRulesCopying =
initJsContent.includes("copyTemplateFile(") &&
(initJsContent.includes("rules-") || initJsContent.includes("-rules"));
expect(hasModeRulesCopying).toBe(true);
});
});