-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-dht-integration.html
More file actions
146 lines (130 loc) · 5.03 KB
/
test-dht-integration.html
File metadata and controls
146 lines (130 loc) · 5.03 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DHT Integration Test</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background: #1a1f35;
color: white;
}
.test-section {
margin: 20px 0;
padding: 20px;
border: 1px solid #444;
border-radius: 8px;
}
button {
padding: 10px 20px;
margin: 10px;
background: #00d4ff;
color: black;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover { background: #00a8cc; }
.success { color: #4CAF50; }
.error { color: #f44336; }
.info { color: #2196F3; }
</style>
</head>
<body>
<h1> DHT Integration Test</h1>
<div class="test-section">
<h2>Test 1: Import Verification</h2>
<button onclick="testImports()">Test Imports</button>
<div id="importResults"></div>
</div>
<div class="test-section">
<h2>Test 2: DHT URL Utils</h2>
<button onclick="testUrlUtils()">Test URL Utilities</button>
<div id="urlResults"></div>
</div>
<div class="test-section">
<h2>Test 3: DHT Testing Dashboard</h2>
<button onclick="testDashboard()">Test Dashboard</button>
<div id="dashboardResults"></div>
</div>
<div class="test-section">
<h2>Test 4: Global Functions</h2>
<button onclick="testGlobalFunctions()">Test Global Functions</button>
<div id="globalResults"></div>
</div>
<script type="module">
import ZhtpUrlUtils from './src/utils/zhtp-url-utils.js';
import DhtTestingDashboard from './src/utils/dht-testing-dashboard.js';
// Make available globally for testing
window.ZhtpUrlUtils = ZhtpUrlUtils;
window.DhtTestingDashboard = DhtTestingDashboard;
window.testImports = function() {
const results = document.getElementById('importResults');
try {
if (typeof ZhtpUrlUtils !== 'undefined' && typeof DhtTestingDashboard !== 'undefined') {
results.innerHTML = '<p class="success"> All imports successful!</p>';
} else {
results.innerHTML = '<p class="error">❌ Import failed</p>';
}
} catch (error) {
results.innerHTML = `<p class="error">❌ Import error: ${error.message}</p>`;
}
};
window.testUrlUtils = function() {
const results = document.getElementById('urlResults');
try {
const utils = new ZhtpUrlUtils();
const testUrl = 'zhtp://dao.network/treasury';
const parsed = utils.parseZhtpUrl(testUrl);
results.innerHTML = `
<p class="success"> URL Utils working!</p>
<p class="info">Parsed URL: ${JSON.stringify(parsed, null, 2)}</p>
`;
} catch (error) {
results.innerHTML = `<p class="error">❌ URL Utils error: ${error.message}</p>`;
}
};
window.testDashboard = function() {
const results = document.getElementById('dashboardResults');
try {
const mockBrowser = {
showNotification: (msg) => console.log('Notification:', msg),
getCurrentUrl: () => 'zhtp://test.network'
};
const dashboard = new DhtTestingDashboard(mockBrowser);
results.innerHTML = `
<p class="success"> Dashboard created successfully!</p>
<p class="info">Dashboard methods: ${Object.getOwnPropertyNames(Object.getPrototypeOf(dashboard)).join(', ')}</p>
`;
} catch (error) {
results.innerHTML = `<p class="error">❌ Dashboard error: ${error.message}</p>`;
}
};
window.testGlobalFunctions = function() {
const results = document.getElementById('globalResults');
const tests = [];
// Test if global functions exist
if (typeof window.openDhtTesting === 'function') {
tests.push(' openDhtTesting function exists');
} else {
tests.push('❌ openDhtTesting function missing');
}
if (typeof window.openSettings === 'function') {
tests.push(' openSettings function exists');
} else {
tests.push('❌ openSettings function missing');
}
results.innerHTML = `<div>${tests.join('<br>')}</div>`;
};
// Auto-run all tests
setTimeout(() => {
testImports();
testUrlUtils();
testDashboard();
testGlobalFunctions();
}, 100);
</script>
</body>
</html>