-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests.html
More file actions
200 lines (180 loc) Β· 6.3 KB
/
run-tests.html
File metadata and controls
200 lines (180 loc) Β· 6.3 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ClueChain Test Runner</title>
<style>
body {
font-family: 'Courier New', monospace;
background: #1e1e1e;
color: #d4d4d4;
margin: 0;
padding: 20px;
}
.container {
max-width: 1000px;
margin: 0 auto;
}
h1 {
color: #4fc3f7;
text-align: center;
}
.test-section {
background: #2d2d2d;
margin: 20px 0;
padding: 15px;
border-radius: 5px;
border-left: 4px solid #4fc3f7;
}
button {
background: #4fc3f7;
color: #1e1e1e;
border: none;
padding: 10px 20px;
border-radius: 3px;
cursor: pointer;
margin: 5px;
font-weight: bold;
}
button:hover {
background: #29b6f6;
}
button:disabled {
background: #666;
cursor: not-allowed;
}
#output {
background: #000;
color: #0f0;
padding: 15px;
border-radius: 5px;
height: 400px;
overflow-y: auto;
font-family: 'Courier New', monospace;
font-size: 14px;
white-space: pre-wrap;
}
.success {
color: #4caf50;
}
.error {
color: #f44336;
}
.warning {
color: #ff9800;
}
.info {
color: #2196f3;
}
</style>
</head>
<body>
<div class="container">
<h1>π§ͺ ClueChain Test Suite</h1>
<div class="test-section">
<h2>Test Categories</h2>
<button onclick="runNavigationTests()">Navigation Tests</button>
<button onclick="runLetterMarketplaceTests()">Letter Marketplace Tests</button>
<button onclick="runAllTests()">Run All Tests</button>
<button onclick="clearOutput()">Clear Output</button>
</div>
<div class="test-section">
<h2>Test Output</h2>
<div id="output"></div>
</div>
</div>
<script type="module">
// Import test modules
import { runNavigationTests } from './js/tests/navigation.test.js';
// Make functions globally available
window.runNavigationTests = runNavigationTests;
// Try to import letter marketplace tests (may not exist yet)
try {
const { runLetterMarketplaceTests } = await import('./js/tests/letter-marketplace.test.js');
window.runLetterMarketplaceTests = runLetterMarketplaceTests;
} catch (error) {
window.runLetterMarketplaceTests = () => {
log("β οΈ Letter Marketplace tests not available", "warning");
};
}
const output = document.getElementById('output');
function log(message, type = 'info') {
const timestamp = new Date().toLocaleTimeString();
const className = type;
const logElement = document.createElement('div');
logElement.className = className;
logElement.textContent = `[${timestamp}] ${message}`;
output.appendChild(logElement);
output.scrollTop = output.scrollHeight;
}
// Override console methods to capture output
const originalConsole = {
log: console.log,
error: console.error,
warn: console.warn,
info: console.info
};
console.log = (...args) => {
const message = args.join(' ');
if (message.includes('β')) {
log(message, 'success');
} else if (message.includes('β')) {
log(message, 'error');
} else if (message.includes('π')) {
log(message, 'success');
} else if (message.includes('β')) {
log(message, 'error');
} else {
log(message, 'info');
}
originalConsole.log(...args);
};
console.error = (...args) => {
log(args.join(' '), 'error');
originalConsole.error(...args);
};
console.warn = (...args) => {
log(args.join(' '), 'warning');
originalConsole.warn(...args);
};
window.runAllTests = async function() {
log("π Starting Complete Test Suite...", "info");
const results = [];
try {
const navResult = await runNavigationTests();
results.push({ name: "Navigation", passed: navResult });
} catch (error) {
log(`Navigation tests failed with error: ${error.message}`, "error");
results.push({ name: "Navigation", passed: false });
}
try {
const marketResult = await window.runLetterMarketplaceTests();
results.push({ name: "Letter Marketplace", passed: marketResult });
} catch (error) {
log(`Letter Marketplace tests failed with error: ${error.message}`, "error");
results.push({ name: "Letter Marketplace", passed: false });
}
// Summary
const totalTests = results.length;
const passedTests = results.filter(r => r.passed).length;
log(`\nπ Overall Results: ${passedTests}/${totalTests} test suites passed`, "info");
if (passedTests === totalTests) {
log("π All test suites passed!", "success");
} else {
log(`β ${totalTests - passedTests} test suites failed`, "error");
results.forEach(result => {
if (!result.passed) {
log(` - ${result.name} suite failed`, "error");
}
});
}
};
window.clearOutput = function() {
output.innerHTML = '';
};
// Initialize
log("Test runner initialized. Click a button to run tests.", "info");
</script>
</body>
</html>