forked from claude-did-this/claude-hub
Remove placeholder tests and clean up test structure
- Delete placeholder E2E test file that only tested mocked values - Remove empty integration test directories (aws/, claude/, github/) - Clean up package.json test scripts (removed test:integration and test:e2e) - Update CI workflow to remove E2E test job These placeholder tests provided no real value as they only verified hardcoded mock responses. Real E2E and integration tests can be added when there's actual functionality to test. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
26
.github/workflows/ci.yml
vendored
26
.github/workflows/ci.yml
vendored
@@ -91,32 +91,6 @@ jobs:
|
||||
GITHUB_WEBHOOK_SECRET: 'test-secret'
|
||||
GITHUB_TOKEN: 'test-token'
|
||||
|
||||
# E2E tests - only 1 scenario, run on GitHub for simplicity
|
||||
test-e2e:
|
||||
name: E2E Tests
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
cache: 'npm'
|
||||
cache-dependency-path: 'package-lock.json'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --prefer-offline --no-audit
|
||||
|
||||
- name: Run e2e tests
|
||||
run: npm run test:e2e
|
||||
env:
|
||||
NODE_ENV: test
|
||||
BOT_USERNAME: '@TestBot'
|
||||
GITHUB_WEBHOOK_SECRET: 'test-secret'
|
||||
GITHUB_TOKEN: 'test-token'
|
||||
|
||||
# Coverage generation - depends on unit tests
|
||||
coverage:
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
"dev": "nodemon src/index.js",
|
||||
"test": "jest",
|
||||
"test:unit": "jest --testMatch='**/test/unit/**/*.test.js'",
|
||||
"test:integration": "jest --testMatch='**/test/integration/**/*.test.js'",
|
||||
"test:e2e": "jest --testMatch='**/test/e2e/scenarios/**/*.test.js'",
|
||||
"test:coverage": "jest --coverage",
|
||||
"test:watch": "jest --watch",
|
||||
"test:ci": "jest --ci --coverage",
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
// Import required modules but we'll use mocks for tests
|
||||
// const { setupTestContainer } = require('../scripts/setupTestContainer');
|
||||
// const axios = require('axios');
|
||||
|
||||
// Mock the setupTestContainer module
|
||||
jest.mock('../scripts/setupTestContainer', () => ({
|
||||
setupTestContainer: jest.fn().mockResolvedValue({ containerId: 'mock-container-123' }),
|
||||
cleanupTestContainer: jest.fn().mockResolvedValue(true),
|
||||
runScript: jest.fn()
|
||||
}));
|
||||
|
||||
describe('Container Execution E2E Tests', () => {
|
||||
// Mock container ID for testing
|
||||
const mockContainerId = 'mock-container-123';
|
||||
|
||||
// Test that the container configuration is valid
|
||||
test('Container should be properly configured', () => {
|
||||
expect(mockContainerId).toBeDefined();
|
||||
expect(mockContainerId.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
// Test a simple Claude request through the container
|
||||
test('Should process a simple Claude request', async () => {
|
||||
// This is a mock test that simulates a successful Claude API response
|
||||
const mockResponse = {
|
||||
status: 200,
|
||||
data: { response: 'Hello! 2+2 equals 4.' }
|
||||
};
|
||||
|
||||
// Verify expected response format
|
||||
expect(mockResponse.status).toBe(200);
|
||||
expect(mockResponse.data.response).toContain('4');
|
||||
});
|
||||
|
||||
// Test error handling
|
||||
test('Should handle errors gracefully', async () => {
|
||||
// Mock error response
|
||||
const mockErrorResponse = {
|
||||
status: 500,
|
||||
data: { error: 'Internal server error' }
|
||||
};
|
||||
|
||||
// Verify error handling
|
||||
expect(mockErrorResponse.status).toBe(500);
|
||||
expect(mockErrorResponse.data.error).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -1,96 +0,0 @@
|
||||
/**
|
||||
* Helper script to set up a test container for E2E testing
|
||||
* This is used to wrap shell script functionality in a format Jest can use
|
||||
*/
|
||||
const { spawn } = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* Runs a shell script with the provided arguments
|
||||
* @param {string} scriptPath - Path to the shell script
|
||||
* @param {string[]} args - Arguments to pass to the script
|
||||
* @returns {Promise<{stdout: string, stderr: string, exitCode: number}>}
|
||||
*/
|
||||
function runScript(scriptPath, args = []) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const scriptAbsPath = path.resolve(__dirname, scriptPath);
|
||||
const proc = spawn('bash', [scriptAbsPath, ...args]);
|
||||
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
|
||||
proc.stdout.on('data', data => {
|
||||
stdout += data.toString();
|
||||
});
|
||||
|
||||
proc.stderr.on('data', data => {
|
||||
stderr += data.toString();
|
||||
});
|
||||
|
||||
proc.on('close', exitCode => {
|
||||
resolve({
|
||||
stdout,
|
||||
stderr,
|
||||
exitCode
|
||||
});
|
||||
});
|
||||
|
||||
proc.on('error', err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up a test container for Claude testing
|
||||
* @param {object} options - Container setup options
|
||||
* @param {boolean} options.useFirewall - Whether to enable firewall
|
||||
* @param {boolean} options.privilegedMode - Whether to use privileged mode
|
||||
* @returns {Promise<{containerId: string}>}
|
||||
*/
|
||||
async function setupTestContainer({ useFirewall = true, privilegedMode = true } = {}) {
|
||||
// Determine which script to run based on options
|
||||
let scriptPath;
|
||||
|
||||
if (useFirewall && privilegedMode) {
|
||||
scriptPath = '../../../test/test-full-flow.sh';
|
||||
} else if (privilegedMode) {
|
||||
scriptPath = '../../../test/test-basic-container.sh';
|
||||
} else if (useFirewall) {
|
||||
scriptPath = '../../../test/test-claude-no-firewall.sh';
|
||||
} else {
|
||||
// Fallback to basic container as minimal-claude script was removed
|
||||
scriptPath = '../../../test/test-basic-container.sh';
|
||||
}
|
||||
|
||||
// Run the setup script
|
||||
const result = await runScript(scriptPath);
|
||||
|
||||
if (result.exitCode !== 0) {
|
||||
throw new Error(`Failed to set up test container: ${result.stderr}`);
|
||||
}
|
||||
|
||||
// Parse container ID from stdout
|
||||
const containerId = result.stdout.match(/Container ID: ([a-f0-9]+)/)?.[1];
|
||||
|
||||
if (!containerId) {
|
||||
throw new Error('Failed to extract container ID from script output');
|
||||
}
|
||||
|
||||
return { containerId };
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up a test container
|
||||
* @param {string} containerId - ID of the container to clean up
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function cleanupTestContainer(containerId) {
|
||||
await runScript('../../../test/test-container-cleanup.sh', [containerId]);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setupTestContainer,
|
||||
cleanupTestContainer,
|
||||
runScript
|
||||
};
|
||||
Reference in New Issue
Block a user