Ka-Note/ka-note/pw-inspect2.cjs

44 lines
1.5 KiB
JavaScript

// Test: does the dev server serve updated RenderedMarkdown?
// Check by fetching the compiled JS bundle and looking for historyEntryId
const http = require('http');
// First get the page to find script URLs
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const ctx = await browser.newContext();
const page = await ctx.newPage();
const scriptUrls = [];
page.on('response', resp => {
if (resp.url().includes('RenderedMarkdown') || resp.url().includes('rendered-markdown')) {
scriptUrls.push(resp.url());
}
});
await page.goto('http://localhost:5173/context/daily-log');
await page.waitForTimeout(3000);
// Check if RenderedMarkdown script contains historyEntryId
const hasHistoryEntryId = await page.evaluate(() => {
// Search all loaded script content
return document.documentElement.innerHTML.includes('historyEntryId');
});
console.log('Script URLs with RenderedMarkdown:', scriptUrls);
console.log('DOM contains historyEntryId text:', hasHistoryEntryId);
// Also check: what does RenderedMarkdown actually render?
const divInfo = await page.evaluate(() => {
return Array.from(document.querySelectorAll('.markdown-content')).map(el => ({
outerHTML: el.outerHTML.slice(0, 200),
hasHistoryAttr: el.hasAttribute('data-history-entry-id'),
historyAttrValue: el.getAttribute('data-history-entry-id')
}));
});
console.log('markdown-content divs:', JSON.stringify(divInfo, null, 2));
await browser.close();
})();