feat(e2e): implement whole test suite

- some elements and tests still broken, but did the 80%
This commit is contained in:
Ralph Khreish
2025-07-17 20:12:25 +03:00
parent 3204582885
commit 2577c95e65
44 changed files with 3971 additions and 4851 deletions

View File

@@ -8,7 +8,7 @@ import { TestHelpers } from '../utils/test-helpers.js';
import { TestLogger } from '../utils/logger.js';
// Increase timeout for all E2E tests (can be overridden per test)
jest.setTimeout(180000);
jest.setTimeout(600000);
// Add custom matchers for CLI testing
expect.extend({
@@ -70,8 +70,16 @@ global.TestHelpers = TestHelpers;
global.TestLogger = TestLogger;
// Helper to create test context
import { mkdtempSync } from 'fs';
import { join } from 'path';
import { tmpdir } from 'os';
global.createTestContext = (testName) => {
const logger = new TestLogger(testName);
// Create a proper log directory in temp for tests
const testLogDir = mkdtempSync(join(tmpdir(), `task-master-test-logs-${testName}-`));
const testRunId = Date.now().toString();
const logger = new TestLogger(testLogDir, testRunId);
const helpers = new TestHelpers(logger);
return { logger, helpers };
};

View File

@@ -0,0 +1,73 @@
/**
* Custom Jest test sequencer to manage parallel execution
* and avoid hitting AI rate limits
*/
const Sequencer = require('@jest/test-sequencer').default;
class RateLimitSequencer extends Sequencer {
/**
* Sort tests to optimize execution and avoid rate limits
*/
sort(tests) {
// Categorize tests by their AI usage
const aiHeavyTests = [];
const aiLightTests = [];
const nonAiTests = [];
tests.forEach((test) => {
const testPath = test.path.toLowerCase();
// Tests that make heavy use of AI APIs
if (
testPath.includes('update-task') ||
testPath.includes('expand-task') ||
testPath.includes('research') ||
testPath.includes('parse-prd') ||
testPath.includes('generate') ||
testPath.includes('analyze-complexity')
) {
aiHeavyTests.push(test);
}
// Tests that make light use of AI APIs
else if (
testPath.includes('add-task') ||
testPath.includes('update-subtask')
) {
aiLightTests.push(test);
}
// Tests that don't use AI APIs
else {
nonAiTests.push(test);
}
});
// Sort each category by duration (fastest first)
const sortByDuration = (a, b) => {
const aTime = a.duration || 0;
const bTime = b.duration || 0;
return aTime - bTime;
};
aiHeavyTests.sort(sortByDuration);
aiLightTests.sort(sortByDuration);
nonAiTests.sort(sortByDuration);
// Return tests in order: non-AI first, then light AI, then heavy AI
// This allows non-AI tests to run quickly while AI tests are distributed
return [...nonAiTests, ...aiLightTests, ...aiHeavyTests];
}
/**
* Shard tests across workers to balance AI load
*/
shard(tests, { shardIndex, shardCount }) {
const shardSize = Math.ceil(tests.length / shardCount);
const start = shardSize * shardIndex;
const end = shardSize * (shardIndex + 1);
return tests.slice(start, end);
}
}
module.exports = RateLimitSequencer;