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

36 lines
1.2 KiB
JavaScript

const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const ctx = await browser.newContext();
const page = await ctx.newPage();
// Capture the RenderedMarkdown module source
let rmSource = '';
page.on('response', async resp => {
if (resp.url().includes('RenderedMarkdown')) {
rmSource = await resp.text().catch(() => '');
}
});
await page.goto('http://localhost:5173/context/daily-log');
await page.waitForTimeout(4000);
console.log('RenderedMarkdown source contains historyEntryId:', rmSource.includes('historyEntryId'));
console.log('Source snippet:', rmSource.slice(rmSource.indexOf('historyEntryId') - 30, rmSource.indexOf('historyEntryId') + 60));
const result = await page.evaluate(() => {
const chip = document.querySelector('[data-task-new]');
if (!chip) return { noChip: true };
const container = chip.closest('.markdown-content');
return {
containerClass: container?.className,
containerHasHistoryId: container?.hasAttribute('data-history-entry-id'),
containerHistoryId: container?.getAttribute('data-history-entry-id'),
};
});
console.log(JSON.stringify(result, null, 2));
await browser.close();
})();