79 lines
2.9 KiB
HTML
79 lines
2.9 KiB
HTML
|
|
<!DOCTYPE html>
|
||
|
|
<html lang="en">
|
||
|
|
<head>
|
||
|
|
<meta charset="UTF-8">
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
|
<title>Brainy Cache Detection Browser Test</title>
|
||
|
|
<style>
|
||
|
|
body {
|
||
|
|
font-family: Arial, sans-serif;
|
||
|
|
max-width: 800px;
|
||
|
|
margin: 0 auto;
|
||
|
|
padding: 20px;
|
||
|
|
}
|
||
|
|
#results {
|
||
|
|
margin-top: 20px;
|
||
|
|
padding: 10px;
|
||
|
|
border: 1px solid #ccc;
|
||
|
|
border-radius: 5px;
|
||
|
|
background-color: #f9f9f9;
|
||
|
|
}
|
||
|
|
.success {
|
||
|
|
color: green;
|
||
|
|
font-weight: bold;
|
||
|
|
}
|
||
|
|
.error {
|
||
|
|
color: red;
|
||
|
|
font-weight: bold;
|
||
|
|
}
|
||
|
|
</style>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<h1>Brainy Cache Detection Browser Test</h1>
|
||
|
|
<p>This page tests if Brainy's cache detection works properly in browser environments.</p>
|
||
|
|
|
||
|
|
<button id="runTest">Run Test</button>
|
||
|
|
|
||
|
|
<div id="results">
|
||
|
|
<p>Test results will appear here...</p>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<script type="module">
|
||
|
|
import { BrainyData } from './dist/unified.js';
|
||
|
|
|
||
|
|
document.getElementById('runTest').addEventListener('click', async () => {
|
||
|
|
const resultsDiv = document.getElementById('results');
|
||
|
|
resultsDiv.innerHTML = '<p>Running test...</p>';
|
||
|
|
|
||
|
|
try {
|
||
|
|
console.log('Creating BrainyData instance...');
|
||
|
|
resultsDiv.innerHTML += '<p>Creating BrainyData instance...</p>';
|
||
|
|
|
||
|
|
const brainy = new BrainyData();
|
||
|
|
|
||
|
|
console.log('BrainyData instance created successfully!');
|
||
|
|
resultsDiv.innerHTML += '<p class="success">BrainyData instance created successfully!</p>';
|
||
|
|
|
||
|
|
// Initialize to make sure all components are created
|
||
|
|
await brainy.init();
|
||
|
|
|
||
|
|
console.log('BrainyData initialized successfully!');
|
||
|
|
resultsDiv.innerHTML += '<p class="success">BrainyData initialized successfully!</p>';
|
||
|
|
|
||
|
|
// Add a simple item to verify everything works
|
||
|
|
const id = await brainy.add("Test item for browser cache detection");
|
||
|
|
|
||
|
|
console.log('Added test item with ID:', id);
|
||
|
|
resultsDiv.innerHTML += `<p class="success">Added test item with ID: ${id}</p>`;
|
||
|
|
|
||
|
|
resultsDiv.innerHTML += '<p class="success">✅ Test completed successfully! Cache detection works in browser environment.</p>';
|
||
|
|
} catch (error) {
|
||
|
|
console.error('Error during cache detection test:', error);
|
||
|
|
resultsDiv.innerHTML += `<p class="error">❌ Error during test: ${error.message}</p>`;
|
||
|
|
resultsDiv.innerHTML += `<p class="error">Stack trace: ${error.stack}</p>`;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|