Viewing:
// This is a "PandaScript", a javascript intended to be run with lightpanda, // e.g. https://lightpanda.io/docs/usage/pandascript, // lightpanda agent ./sanity-check-sites.js const page = new Page(); function mkSelText(sel) { return { selector: sel, fields: { text: '', } } } function assert(condition, statement) { if (!!condition) { return } throw new Error(statement); } const base_url='http://localhost:8001' await page.goto(`${base_url}/signup`); // signup console.log('signing up'); page.fill('input[name=username]', 'my_user'); page.fill('input[name=password]', 'my_pass'); page.fill('input[name=code]', 'asdf'); console.log('AAAAAA') // TODO: Check to see if redirect is not yet implemented. And if it is not, // if https://github.com/lightpanda-io/browser/pull/2883/files implements it. page.click('input[name=submit]'); console.log('BBBBBB') // create 3 view pad console.log('creating 3 view pad'); await page.goto(base_url+"/a"); page.waitForState('networkidle'); // pa const dataPostSignin = page.extract({ title: 'title', h1: mkSelText('h1'), nav: mkSelText('nav details'), }); // hack: something in client side redirect isn't happenieng fully, // even after waitForState networkidle console.log("erasmian", dataPostSignin.nav.text, dataPostSignin.h1.text, dataPostSignin.title); page.click('nav details a[href^=/newpad]'); page.fill('input[name=slug]', '3-views-till-delete'); page.fill('input[name=content]', '3 views till delete'); page.fill('input[name=views_left]', 3); page.click('input[name=submit]'); // create pad to delete console.log('creating to be deleted pad'); const contentToBeDeleted = 'to be deleted' const slugToBeDeleted = 'to-be-deleted' page.click('nav details a[href^=/newpad]'); page.fill('input[name=slug]', 'to-be-deleted'); page.fill('input[name=content]', 'to be deleted'); page.click('input[name=submit]'); await page.goto(base_url+"/p/"+slugToBeDeleted) console.log('viewing to be deleted pad'); const dataPadDelete = page.extract({ pad: mkSelText("body"), }) assert(dataPadDelete.pad.text === contentToBeDeleted, 'unexpected content: ' + dataPadDelete.pad.text) console.log('deleting pad'); const dataPadDeleted = page.extract({ repos: mkSelText("body"), })