-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-functionality.html
More file actions
129 lines (111 loc) Β· 4.99 KB
/
test-functionality.html
File metadata and controls
129 lines (111 loc) Β· 4.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DTUI2 Functionality Test</title>
<style>
body {
font-family: Monaco, monospace;
background: #1e1e1e;
color: #fff;
padding: 20px;
margin: 0;
}
.test-result {
margin: 10px 0;
padding: 10px;
border-radius: 4px;
}
.success { background: rgba(0, 255, 0, 0.1); border: 1px solid green; }
.error { background: rgba(255, 0, 0, 0.1); border: 1px solid red; }
.info { background: rgba(0, 123, 255, 0.1); border: 1px solid blue; }
pre { background: #2d2d2d; padding: 10px; border-radius: 4px; overflow-x: auto; }
</style>
</head>
<body>
<h1>π§ͺ DTUI2 Functionality Test</h1>
<div id="test-results"></div>
<script type="module">
// Import and test Mock AI functionality
function log(message, type = 'info') {
const div = document.createElement('div');
div.className = `test-result ${type}`;
div.innerHTML = message;
document.getElementById('test-results').appendChild(div);
console.log(message);
}
async function testMockAPI() {
try {
// Import Mock API
const { initializeMockAPI } = await import('/src/services/MockElectronAPI.js');
initializeMockAPI();
if (window.electronAPI) {
log('β
Mock Electron API initialized successfully', 'success');
// Test shell command
const shellResult = await window.electronAPI.executeShellCommand('ls');
log(`Shell command test: ${JSON.stringify(shellResult)}`, 'info');
// Test file read
const fileResult = await window.electronAPI.readFile('/package.json');
log(`File read test: ${fileResult.success ? 'β
Success' : 'β Failed'}`, fileResult.success ? 'success' : 'error');
// Test directory list
const dirResult = await window.electronAPI.listDirectory('.');
log(`Directory list test: ${dirResult.success ? 'β
Success' : 'β Failed'}`, dirResult.success ? 'success' : 'error');
return true;
} else {
log('β Mock Electron API not available', 'error');
return false;
}
} catch (error) {
log(`β Mock API test failed: ${error.message}`, 'error');
return false;
}
}
async function testAIProvider() {
try {
// Import AI Provider
const { AIProvider } = await import('/src/services/AIProvider.js');
const aiProvider = new AIProvider();
log('β
AI Provider initialized', 'success');
// Test basic response
const testMessages = [{
id: '1',
role: 'user',
content: 'Hello',
timestamp: new Date()
}];
const response = await aiProvider.generateResponse(testMessages);
log(`AI Response test: ${response ? 'β
Got response' : 'β No response'}`, response ? 'success' : 'error');
if (response) {
log(`<pre>Response: ${response}</pre>`, 'info');
}
// Test shell command
const shellMessages = [{
id: '2',
role: 'user',
content: '!ls',
timestamp: new Date()
}];
const shellResponse = await aiProvider.generateResponse(shellMessages);
log(`Shell command test: ${shellResponse ? 'β
Got response' : 'β No response'}`, shellResponse ? 'success' : 'error');
return true;
} catch (error) {
log(`β AI Provider test failed: ${error.message}`, 'error');
return false;
}
}
async function runAllTests() {
log('π Starting functionality tests...', 'info');
const mockAPIResult = await testMockAPI();
const aiProviderResult = await testAIProvider();
if (mockAPIResult && aiProviderResult) {
log('π All tests passed! The application should work correctly.', 'success');
} else {
log('β οΈ Some tests failed. Check the errors above.', 'error');
}
}
// Run tests when page loads
runAllTests();
</script>
</body>
</html>