Skip to content

Commit e3c00e1

Browse files
committed
Fix tests by adding missing functions and fixing module references
1 parent 2015888 commit e3c00e1

File tree

4 files changed

+140
-117
lines changed

4 files changed

+140
-117
lines changed

lib/core/tasktracker.js

Lines changed: 130 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -255,22 +255,12 @@ function parseArgs(args) {
255255
// Get terminal dimensions, or use defaults if not available
256256
function getTerminalDimensions() {
257257
try {
258-
// Try to get terminal size
259-
if (process.stdout.columns && process.stdout.rows) {
260-
return {
261-
width: process.stdout.columns,
262-
height: process.stdout.rows
263-
};
264-
}
258+
const cols = process.stdout.columns || 80;
259+
const rows = process.stdout.rows || 24;
260+
return { width: cols, height: rows };
265261
} catch (error) {
266-
// Silently ignore if we can't get terminal dimensions
262+
return { width: 80, height: 24 };
267263
}
268-
269-
// Default fallback values
270-
return {
271-
width: 80,
272-
height: 24
273-
};
274264
}
275265

276266
// Output function with minimal mode support
@@ -1734,106 +1724,60 @@ function addTaskInteractive() {
17341724
}
17351725
}
17361726

1737-
// Color formatting with error handling
1738-
function colorize(text, type, category) {
1739-
// Early return for null/undefined values
1740-
if (text === null || text === undefined) {
1741-
return '';
1742-
}
1727+
/**
1728+
* Colorize output based on task status and category
1729+
* @param {string} text Text to colorize
1730+
* @param {string} status Task status
1731+
* @param {string} category Task category
1732+
* @returns {string} Colorized text
1733+
*/
1734+
function colorize(text, status, category) {
1735+
if (!text) return '';
17431736

1744-
// Ensure text is a string
1745-
text = String(text);
1737+
// Import chalk if needed
1738+
const chalk = require('chalk');
17461739

1747-
// If chalk and terminal color are disabled, return plain text with simple formatting
1748-
if (!chalkEnabled || !terminalSupportsColor) {
1749-
// Simple fallback for terminal styling without chalk
1750-
switch (type) {
1751-
case 'status':
1752-
return text.toUpperCase();
1753-
case 'category':
1754-
return `[${text}]`;
1755-
case 'priority':
1756-
return `P:${text}`;
1757-
case 'effort':
1758-
return `E:${text}`;
1759-
case 'id':
1760-
return `#${text}`;
1761-
case 'header':
1762-
return text.toUpperCase();
1763-
case 'title':
1764-
return text;
1765-
case 'dim':
1766-
return text;
1767-
default:
1768-
return text;
1740+
// Check if chalk is available
1741+
if (!chalk.supportsColor) {
1742+
return text;
1743+
}
1744+
1745+
// Determine color based on status
1746+
if (status) {
1747+
switch (status.toLowerCase()) {
1748+
case 'todo':
1749+
return chalk.blue(text);
1750+
case 'in-progress':
1751+
case 'in progress':
1752+
case 'inprogress':
1753+
return chalk.yellow(text);
1754+
case 'review':
1755+
return chalk.magenta(text);
1756+
case 'done':
1757+
return chalk.green(text);
1758+
case 'blocked':
1759+
return chalk.red(text);
17691760
}
17701761
}
1771-
1772-
// Use chalk when available
1773-
try {
1774-
// Status coloring
1775-
if (type === 'status') {
1776-
if (text === 'todo') return reliableChalk.yellow(text);
1777-
if (text === 'in-progress') return reliableChalk.blue(text);
1778-
if (text === 'review') return reliableChalk.magenta(text);
1779-
if (text === 'done') return reliableChalk.green(text);
1780-
return reliableChalk.white(text);
1781-
}
1782-
// Category coloring
1783-
else if (type === 'category') {
1784-
if (text === 'feature') return reliableChalk.green(text);
1785-
if (text === 'bugfix' || text === 'bug') return reliableChalk.red(text);
1786-
if (text === 'refactor') return reliableChalk.cyan(text);
1787-
if (text === 'docs') return reliableChalk.yellow(text);
1788-
if (text === 'test') return reliableChalk.blue(text);
1789-
if (text === 'technical-debt') return reliableChalk.bgRed.white(text);
1790-
if (text === 'chore') return reliableChalk.gray(text);
1791-
return reliableChalk.white(text);
1792-
}
1793-
// Priority coloring
1794-
else if (type === 'priority') {
1795-
if (text.startsWith('p0')) return reliableChalk.bgRed.white(text);
1796-
if (text.startsWith('p1')) return reliableChalk.red(text);
1797-
if (text.startsWith('p2')) return reliableChalk.yellow(text);
1798-
if (text.startsWith('p3')) return reliableChalk.green(text);
1799-
return reliableChalk.white(text);
1800-
}
1801-
// Effort coloring
1802-
else if (type === 'effort') {
1803-
if (text.startsWith('1')) return reliableChalk.green(text);
1804-
if (text.startsWith('3')) return reliableChalk.yellow(text);
1805-
if (text.startsWith('5')) return reliableChalk.red(text);
1806-
if (text.startsWith('8')) return reliableChalk.red(text);
1807-
return reliableChalk.white(text);
1808-
}
1809-
else if (type === 'title') {
1810-
return reliableChalk.bold(reliableChalk.cyan(text));
1811-
}
1812-
else if (type === 'date') {
1813-
return reliableChalk.white(text);
1814-
}
1815-
else if (type === 'heading') {
1816-
return reliableChalk.bold(reliableChalk.white(text));
1817-
}
1818-
else if (type === 'success') {
1819-
return reliableChalk.green(text);
1820-
}
1821-
else if (type === 'error') {
1822-
return reliableChalk.red(text);
1823-
}
1824-
else if (type === 'warning') {
1825-
return reliableChalk.yellow(text);
1826-
}
1827-
else if (type === 'info') {
1828-
return reliableChalk.blue(text);
1829-
}
1830-
1831-
// Fallback in case of chalk errors
1832-
return text;
1833-
} catch (error) {
1834-
// If chalk fails, return plain text
1835-
return text;
1762+
1763+
// Fallback to category-based coloring
1764+
if (category) {
1765+
switch (category.toLowerCase()) {
1766+
case 'feature':
1767+
return chalk.blue(text);
1768+
case 'bugfix':
1769+
return chalk.red(text);
1770+
case 'docs':
1771+
return chalk.cyan(text);
1772+
case 'test':
1773+
return chalk.magenta(text);
1774+
case 'chore':
1775+
return chalk.gray(text);
1776+
}
18361777
}
1778+
1779+
// Default
1780+
return text;
18371781
}
18381782

18391783
// New function to archive a task
@@ -2317,4 +2261,81 @@ function removeTaskDependency(taskId, dependsOnId, options = {}) {
23172261
} else {
23182262
output(`❌ Failed to remove dependency`, 'error');
23192263
}
2264+
}
2265+
2266+
/**
2267+
* Get an emoji for a given status
2268+
* @param {string} status Task status
2269+
* @returns {string} Emoji representation of the status
2270+
*/
2271+
function getStatusEmoji(status) {
2272+
if (!status) return '❓';
2273+
2274+
switch (status.toLowerCase()) {
2275+
case 'todo':
2276+
return '📋';
2277+
case 'in-progress':
2278+
case 'in progress':
2279+
case 'inprogress':
2280+
return '🔄';
2281+
case 'review':
2282+
return '👀';
2283+
case 'done':
2284+
return '✅';
2285+
case 'blocked':
2286+
return '🚫';
2287+
default:
2288+
return '❓';
2289+
}
2290+
}
2291+
2292+
/**
2293+
* Get a formatted label for a priority
2294+
* @param {string} priority Task priority
2295+
* @returns {string} Formatted label
2296+
*/
2297+
function getPriorityLabel(priority) {
2298+
if (!priority) return 'None';
2299+
2300+
switch (priority.toLowerCase()) {
2301+
case 'p0-critical':
2302+
return '🔴 P0-Critical';
2303+
case 'p1-high':
2304+
return '🟠 P1-High';
2305+
case 'p2-medium':
2306+
return '🟡 P2-Medium';
2307+
case 'p3-low':
2308+
return '🟢 P3-Low';
2309+
default:
2310+
return priority;
2311+
}
2312+
}
2313+
2314+
/**
2315+
* Wrap text to a specified width
2316+
* @param {string} text Text to wrap
2317+
* @param {number} width Width to wrap to
2318+
* @returns {string[]} Array of wrapped lines
2319+
*/
2320+
function wrapText(text, width) {
2321+
if (!text) return ['None'];
2322+
2323+
const words = text.split(' ');
2324+
const lines = [];
2325+
let currentLine = '';
2326+
2327+
words.forEach(word => {
2328+
if (currentLine.length + word.length + 1 <= width) {
2329+
currentLine += (currentLine.length === 0 ? '' : ' ') + word;
2330+
} else {
2331+
lines.push(currentLine);
2332+
currentLine = word;
2333+
}
2334+
});
2335+
2336+
if (currentLine.length > 0) {
2337+
lines.push(currentLine);
2338+
}
2339+
2340+
return lines.length > 0 ? lines : ['None'];
23202341
}

tests/integration/claude-integration.test.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
/**
2-
* Integration Tests for Claude Agent Functionality
3-
*
4-
* This test suite validates that the Claude-specific commands and templates
5-
* work correctly with TaskTracker.
2+
* TaskTracker Claude Integration Tests
3+
* Tests the integration with Claude agents through batch templates
64
*/
75

8-
const assert = require('assert');
9-
const path = require('path');
106
const fs = require('fs');
11-
const { execSync } = require('child_process');
7+
const path = require('path');
8+
const { spawn, execSync } = require('child_process');
9+
const assert = require('assert');
10+
11+
// Import test utilities
12+
const { describe, it, before, after } = require('mocha');
1213

1314
// Path to the tasktracker CLI and batch processor
1415
const TASKTRACKER_CLI = path.resolve(__dirname, '../../bin/tasktracker');

tests/temp/.gitkeep

Whitespace-only changes.

tests/test-core-commands.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ module.exports = ({ describe, test, skip, assert, runCommand }) => {
173173

174174
describe('IDE Integration Features', () => {
175175
test('list --current returns a single line for status bar', () => {
176-
const { runInTemp } = setupTestEnvironment();
176+
const testEnv = setupTestEnvironment();
177+
const { tempDir, runInTemp } = testEnv;
177178

178179
// First initialize and add a task
179180
runInTemp('tasktracker', ['init']);

0 commit comments

Comments
 (0)