← back to Commercialrealestate

5x/rn-test.mjs

29 lines

import { chromium } from 'playwright';
const b = await chromium.launch();
const ctx = await b.newContext({ httpCredentials: { username:'admin', password:'DW2024!' } });
const pg = await ctx.newPage();
const errs = []; pg.on('pageerror', e => errs.push(String(e))); pg.on('console', m => { if (m.type()==='error') errs.push(m.text()); });
await pg.goto('http://127.0.0.1:9911', { waitUntil:'networkidle', timeout:30000 });
let R = { rows:0, expanded:false, notesBox:false, saved:false, errs:[] };
try {
  await pg.waitForSelector('[data-id]', { timeout:15000 });
  const rows = await pg.$$('.crow[data-id], .listtbl tr[data-id], .kvcard[data-id]');
  R.rows = rows.length;
  if (rows.length) {
    const row = rows[0];
    // click the row's open space (the element itself, away from links)
    await row.click({ position:{ x:8, y:8 } });
    await pg.waitForTimeout(400);
    R.expanded = await pg.$('.rn-panel') != null;
    const ta = await pg.$('.rn-ta'); R.notesBox = ta != null;
    if (ta) {
      await ta.fill('QA private note ' + Date.now());
      await pg.waitForTimeout(400);
      R.saved = await pg.evaluate(() => Object.keys(localStorage).some(k => k.startsWith('crcp_note_') && localStorage.getItem(k).includes('QA private note')));
    }
  }
} catch(e){ R.errs.push(String(e)); }
R.errs = R.errs.concat(errs.filter(e=>/row-notes|rn-/.test(e)));
console.log(JSON.stringify(R, null, 2));
await b.close();