-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
305 lines (265 loc) · 11.8 KB
/
Copy pathtest.html
File metadata and controls
305 lines (265 loc) · 11.8 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Digital Keys to Soil Taxonomy - Test Runner</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace;
background: #1e1e1e;
color: #d4d4d4;
padding: 20px;
}
.container { max-width: 1200px; margin: 0 auto; }
header { background: linear-gradient(135deg, #4a90a4 0%, #2d5a6f 100%); padding: 30px; border-radius: 8px; margin-bottom: 30px; color: white; }
header h1 { font-size: 28px; margin-bottom: 10px; }
header p { opacity: 0.9; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 30px; }
.stat-box { background: #2d2d2d; border-left: 4px solid #4a90a4; padding: 20px; border-radius: 4px; }
.stat-box h3 { color: #4a90a4; font-size: 14px; margin-bottom: 10px; text-transform: uppercase; }
.stat-box .value { font-size: 32px; font-weight: bold; color: #d4d4d4; }
.stat-box.pass .value { color: #4ec9b0; }
.stat-box.fail .value { color: #f48771; }
.stat-box.total .value { color: #ce9178; }
.test-results { margin-bottom: 20px; }
.test-suite { background: #2d2d2d; border: 1px solid #3e3e3e; border-radius: 6px; margin-bottom: 20px; overflow: hidden; }
.suite-header {
background: #404040;
padding: 15px 20px;
font-weight: 600;
color: #4a90a4;
border-left: 4px solid #4a90a4;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
}
.suite-header:hover { background: #454545; }
.suite-header .toggle { font-size: 12px; color: #888; }
.suite-header.collapsed .toggle::before { content: '▶ '; }
.suite-header.expanded .toggle::before { content: '▼ '; }
.suite-tests { display: none; padding: 0; }
.suite-tests.expanded { display: block; }
.test-item {
padding: 12px 20px;
border-bottom: 1px solid #3e3e3e;
display: flex;
align-items: center;
gap: 10px;
}
.test-item:last-child { border-bottom: none; }
.test-item.pass { background: rgba(78, 201, 176, 0.05); }
.test-item.fail { background: rgba(244, 135, 113, 0.05); }
.test-item.pass .icon { color: #4ec9b0; }
.test-item.fail .icon { color: #f48771; }
.icon { font-weight: bold; min-width: 20px; }
.test-name { flex: 1; }
.test-error {
color: #f48771;
font-size: 12px;
margin-top: 8px;
padding-left: 30px;
font-family: 'Courier New', monospace;
}
.controls { margin-bottom: 20px; display: flex; gap: 10px; }
button {
background: #4a90a4;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
font-family: inherit;
}
button:hover { background: #2d5a6f; }
button.secondary { background: #555; }
button.secondary:hover { background: #666; }
.console-output {
background: #1e1e1e;
border: 1px solid #3e3e3e;
border-radius: 4px;
padding: 15px;
margin-top: 20px;
max-height: 400px;
overflow-y: auto;
font-family: 'Courier New', monospace;
font-size: 12px;
color: #d4d4d4;
}
.console-log { color: #d4d4d4; }
.console-error { color: #f48771; }
.console-info { color: #4a90a4; }
.console-success { color: #4ec9b0; }
.loading { text-align: center; padding: 40px; color: #888; }
.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid #4a90a4; border-top: 3px solid transparent; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
</style>
</head>
<body>
<div class="container">
<header>
<h1>🧪 Test Suite: Digital Keys to Soil Taxonomy</h1>
<p>Comprehensive unit, integration, and edge case tests for satisfaction logic and navigation</p>
</header>
<div class="controls">
<button onclick="runTests()">▶ Run Tests</button>
<button class="secondary" onclick="clearConsole()">Clear Console</button>
<button class="secondary" onclick="toggleAllSuites()">Toggle All Suites</button>
</div>
<div id="summary" class="summary" style="display: none;">
<div class="stat-box total">
<h3>Total Tests</h3>
<div class="value" id="total-count">0</div>
</div>
<div class="stat-box pass">
<h3>Passed</h3>
<div class="value" id="pass-count">0</div>
</div>
<div class="stat-box fail">
<h3>Failed</h3>
<div class="value" id="fail-count">0</div>
</div>
<div class="stat-box">
<h3>Pass Rate</h3>
<div class="value" id="pass-rate">0%</div>
</div>
</div>
<div id="loading" class="loading">
<div class="spinner"></div>
<p style="margin-top: 10px;">Tests not run yet. Click "Run Tests" to start.</p>
</div>
<div id="test-results" class="test-results" style="display: none;"></div>
<div class="console-output" id="console-output"></div>
</div>
<!-- Load Alpine.js (not strictly needed for tests, but good for completeness) -->
<script src="https://cdn.jsdelivr.net/npm/alpinejs@3.13.3/dist/cdn.min.js"></script>
<!-- Intercept console for output display -->
<script>
const consoleOutput = document.getElementById('console-output');
const originalLog = console.log;
const originalError = console.error;
const originalWarn = console.warn;
function addToOutput(message, className) {
const line = document.createElement('div');
line.className = `console-${className}`;
line.textContent = message;
consoleOutput.appendChild(line);
consoleOutput.scrollTop = consoleOutput.scrollHeight;
}
console.log = function(...args) {
originalLog(...args);
addToOutput(args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' '), 'log');
};
console.error = function(...args) {
originalError(...args);
addToOutput('ERROR: ' + args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' '), 'error');
};
console.warn = function(...args) {
originalWarn(...args);
addToOutput('WARN: ' + args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' '), 'info');
};
</script>
<!-- Load core engine + test suite -->
<script src="scripts/dst-core.js"></script>
<script src="scripts/tests.js"></script>
<!-- Test runner UI -->
<script>
function runTests() {
consoleOutput.innerHTML = '';
document.getElementById('summary').style.display = 'none';
document.getElementById('test-results').style.display = 'none';
document.getElementById('loading').style.display = 'block';
// Reset test suite
TEST_SUITE.passed = 0;
TEST_SUITE.failed = 0;
TEST_SUITE.tests = [];
// Run all tests (re-execute test file)
setTimeout(() => {
runAllTests();
displayResults();
}, 100);
}
function displayResults() {
const total = TEST_SUITE.passed + TEST_SUITE.failed;
const passRate = total > 0 ? ((TEST_SUITE.passed / total) * 100).toFixed(1) : 0;
// Update summary
document.getElementById('total-count').textContent = total;
document.getElementById('pass-count').textContent = TEST_SUITE.passed;
document.getElementById('fail-count').textContent = TEST_SUITE.failed;
document.getElementById('pass-rate').textContent = passRate + '%';
document.getElementById('summary').style.display = 'grid';
// Group tests by suite
const suiteMap = {};
TEST_SUITE.tests.forEach(test => {
if (!suiteMap[test.suite]) {
suiteMap[test.suite] = [];
}
suiteMap[test.suite].push(test);
});
// Render suites
const resultsDiv = document.getElementById('test-results');
resultsDiv.innerHTML = '';
Object.keys(suiteMap).forEach(suiteName => {
const tests = suiteMap[suiteName];
const passed = tests.filter(t => t.status === 'PASS').length;
const failed = tests.filter(t => t.status === 'FAIL').length;
const suite = document.createElement('div');
suite.className = 'test-suite';
const header = document.createElement('div');
header.className = 'suite-header expanded';
header.innerHTML = `
<span>${suiteName} <small>(${passed}/${tests.length})</small></span>
<span class="toggle"></span>
`;
header.onclick = () => {
header.classList.toggle('expanded');
header.classList.toggle('collapsed');
testsList.classList.toggle('expanded');
};
const testsList = document.createElement('div');
testsList.className = 'suite-tests expanded';
tests.forEach(test => {
const item = document.createElement('div');
item.className = `test-item ${test.status.toLowerCase()}`;
const icon = test.status === 'PASS' ? '✓' : '✗';
item.innerHTML = `
<div class="icon">${icon}</div>
<div class="test-name">${test.name}</div>
`;
if (test.error) {
const errorDiv = document.createElement('div');
errorDiv.className = 'test-error';
errorDiv.textContent = test.error;
item.appendChild(errorDiv);
}
testsList.appendChild(item);
});
suite.appendChild(header);
suite.appendChild(testsList);
resultsDiv.appendChild(suite);
});
document.getElementById('test-results').style.display = 'block';
document.getElementById('loading').style.display = 'none';
}
function clearConsole() {
consoleOutput.innerHTML = '';
}
function toggleAllSuites() {
document.querySelectorAll('.suite-header').forEach(header => {
const toggle = header.classList.contains('expanded');
header.classList.toggle('expanded');
header.classList.toggle('collapsed');
header.closest('.test-suite').querySelector('.suite-tests').classList.toggle('expanded');
});
}
// Auto-run tests when page loads
window.addEventListener('load', () => {
setTimeout(() => {
runTests();
}, 500);
});
</script>
</body>
</html>