diff --git a/src/test/suite/extension.test.js b/src/test/suite/extension.test.js new file mode 100644 index 0000000000..b8ddff26c6 --- /dev/null +++ b/src/test/suite/extension.test.js @@ -0,0 +1,37 @@ +const { expect } = require('chai'); +const vscode = require('vscode'); + +describe('Extension Tests', function() { + this.timeout(60000); // Increased timeout for extension operations + + it('should activate extension successfully', async () => { + // Get the extension + const extension = vscode.extensions.getExtension('saoudrizwan.claude-dev'); + expect(extension).to.not.be.undefined; + + // Activate the extension if not already activated + if (!extension.isActive) { + await extension.activate(); + } + expect(extension.isActive).to.be.true; + }); + + it('should open sidebar view', async () => { + // Execute the command to open sidebar + await vscode.commands.executeCommand('cline.plusButtonClicked'); + + // Wait for sidebar to be visible + await new Promise(resolve => setTimeout(resolve, 1000)); + + // Get all views + const views = vscode.window.visibleTextEditors; + // Just verify the command executed without error + // The actual view verification is handled in the TypeScript tests + }); + + it('should handle basic commands', async () => { + // Test basic command execution + await vscode.commands.executeCommand('cline.historyButtonClicked'); + // Success if no error thrown + }); +}); diff --git a/src/test/suite/index.js b/src/test/suite/index.js new file mode 100644 index 0000000000..50c997b131 --- /dev/null +++ b/src/test/suite/index.js @@ -0,0 +1,43 @@ +const path = require('path'); +const Mocha = require('mocha'); +const glob = require('glob'); + +async function run() { + // Create the mocha test + const mocha = new Mocha({ + ui: 'bdd', + color: true, + timeout: 60000 // Increased timeout for extension operations + }); + + const testsRoot = path.resolve(__dirname, '.'); + + try { + // Find all test files + const files = await glob('*.test.js', { cwd: testsRoot }); + + // Add files to the test suite + files.forEach(f => mocha.addFile(path.resolve(testsRoot, f))); + + // Run the mocha test + return new Promise((resolve, reject) => { + try { + // Run the tests + mocha.run(failures => { + if (failures > 0) { + reject(new Error(`${failures} tests failed.`)); + } else { + resolve(); + } + }); + } catch (err) { + reject(err); + } + }); + } catch (err) { + console.error('Failed to run tests:', err); + throw err; + } +} + +module.exports = { run };