-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-database.js
More file actions
64 lines (53 loc) · 2.25 KB
/
test-database.js
File metadata and controls
64 lines (53 loc) · 2.25 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
// Test database operations directly
// Run this in the extension background console
console.log('=== Testing Database Operations ===');
// Test 1: Check if database is initialized
(async () => {
try {
// First check database status
const debugResponse = await new Promise((resolve) => {
chrome.runtime.sendMessage({ type: 'DEBUG_ANALYTICS' }, resolve);
});
console.log('Database Debug Info:', debugResponse);
if (!debugResponse.success) {
console.error('Failed to get debug info:', debugResponse.error);
return;
}
console.log('\n--- Database Status ---');
console.log('Status:', debugResponse.debugInfo.databaseStatus);
console.log('Tables:', debugResponse.debugInfo.tableInfo.tables);
console.log('Counts:', debugResponse.debugInfo.tableInfo.counts);
// Test 2: Try a direct test insert
console.log('\n--- Testing Direct Insert ---');
const testResponse = await new Promise((resolve) => {
chrome.runtime.sendMessage({ type: 'TEST_ANALYTICS_INSERT' }, resolve);
});
if (testResponse.success) {
console.log('✅ Test insert successful!');
console.log('Stats after insert:', testResponse.stats);
} else {
console.error('❌ Test insert failed:', testResponse.error);
}
// Test 3: Get current statistics
console.log('\n--- Getting Current Statistics ---');
const statsResponse = await new Promise((resolve) => {
chrome.runtime.sendMessage({ type: 'GET_STATISTICS' }, resolve);
});
if (statsResponse.success) {
console.log('Current stats:', statsResponse.stats);
} else {
console.error('Failed to get stats:', statsResponse.error);
}
// Test 4: Check Chrome storage directly
console.log('\n--- Checking Chrome Storage ---');
const storage = await chrome.storage.local.get(['feedDatabase', 'processedPostIds', 'settings']);
console.log('Storage contents:', {
hasFeedDatabase: !!storage.feedDatabase,
feedDatabaseSize: storage.feedDatabase ? storage.feedDatabase.length : 0,
processedPostIds: storage.processedPostIds ? storage.processedPostIds.length : 0,
settings: storage.settings
});
} catch (error) {
console.error('Test failed:', error);
}
})();