From 64676d125f858af35dd86d36bb501bc4a7f40f02 Mon Sep 17 00:00:00 2001 From: Jonathan Flatt Date: Mon, 26 May 2025 00:09:35 +0000 Subject: [PATCH] Remove placeholder tests and clean up test structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .github/workflows/ci.yml | 26 ----- package.json | 2 - test/e2e/scenarios/containerExecution.test.js | 47 --------- test/e2e/scripts/setupTestContainer.js | 96 ------------------- 4 files changed, 171 deletions(-) delete mode 100644 test/e2e/scenarios/containerExecution.test.js delete mode 100644 test/e2e/scripts/setupTestContainer.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7793d4b..27860fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/package.json b/package.json index 4fee1f0..7c0e64b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/e2e/scenarios/containerExecution.test.js b/test/e2e/scenarios/containerExecution.test.js deleted file mode 100644 index 1f8c88a..0000000 --- a/test/e2e/scenarios/containerExecution.test.js +++ /dev/null @@ -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(); - }); -}); diff --git a/test/e2e/scripts/setupTestContainer.js b/test/e2e/scripts/setupTestContainer.js deleted file mode 100644 index f6adb6b..0000000 --- a/test/e2e/scripts/setupTestContainer.js +++ /dev/null @@ -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} - */ -async function cleanupTestContainer(containerId) { - await runScript('../../../test/test-container-cleanup.sh', [containerId]); -} - -module.exports = { - setupTestContainer, - cleanupTestContainer, - runScript -};