Ka-Note/ka-note/debug-idb6.mjs

63 lines
2.5 KiB
JavaScript

import { chromium } from 'playwright';
const userDataDir = 'C:/Users/d-chrka/AppData/Local/Temp/playwright-ka-note-profile';
const context = await chromium.launchPersistentContext(userDataDir, { headless: true });
const page = await context.newPage();
await page.goto('http://localhost:5173', { waitUntil: 'networkidle' });
await page.waitForTimeout(3000);
const result = await page.evaluate(() => {
return new Promise((resolve) => {
const req = indexedDB.open('ka-note');
req.onsuccess = (e) => {
const db = e.target.result;
resolve({ version: db.version, stores: Array.from(db.objectStoreNames) });
};
req.onerror = (e) => resolve({ error: String(e.target.error) });
});
});
console.log('ka-note DB:', JSON.stringify(result));
// Dump historyEntries with [
const history = await page.evaluate(() => {
return new Promise((resolve) => {
const req = indexedDB.open('ka-note');
req.onsuccess = (e) => {
const db = e.target.result;
const stores = Array.from(db.objectStoreNames);
if (!stores.includes('historyEntries')) { resolve({ error: 'no historyEntries', stores }); return; }
const tx = db.transaction('historyEntries', 'readonly');
const all = tx.objectStore('historyEntries').getAll();
all.onsuccess = () => {
const matched = all.result.filter(e => e.text && e.text.includes('['));
resolve({ total: all.result.length, matched: matched.map(e => ({ id: e.id, text: e.text })) });
};
};
});
});
console.log('\n=== HISTORY ENTRIES ===');
console.log('Total:', history.total, '| Matched:', history.matched?.length);
if (history.error) console.log('ERROR:', history.error);
(history.matched || []).forEach(e => console.log('ID:', e.id, '\nTEXT:', JSON.stringify(e.text), '\n'));
// Dump tasks
const tasks = await page.evaluate(() => {
return new Promise((resolve) => {
const req = indexedDB.open('ka-note');
req.onsuccess = (e) => {
const db = e.target.result;
const stores = Array.from(db.objectStoreNames);
if (!stores.includes('tasks')) { resolve({ error: 'no tasks store', stores }); return; }
const tx = db.transaction('tasks', 'readonly');
const all = tx.objectStore('tasks').getAll();
all.onsuccess = () => resolve({ tasks: all.result });
};
});
});
console.log('\n=== TASKS ===');
if (tasks.error) console.log('ERROR:', tasks.error, '| Stores:', tasks.stores);
else console.log(JSON.stringify(tasks.tasks, null, 2));
await context.close();