29 lines
2.4 KiB
JavaScript
29 lines
2.4 KiB
JavaScript
// Read-only public pages on the destination. No POST, registration or mail is performed.
|
|
const fs=require('node:fs'),path=require('node:path'),assert=require('node:assert/strict');
|
|
const {chromium}=require('C:/Users/macbook/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright');
|
|
const ROOT=path.resolve(__dirname,'..'),P=path.join(ROOT,'storage/app/private/investmoz-v2/portal-audit');
|
|
(async()=>{
|
|
const proof={at:new Date().toISOString(),target:'https://portal-investidor.test',accounts_created:0,emails_sent:0,TLS_bypass:false,errors:[],mixed:[],routes:[]};
|
|
const browser=await chromium.launch({headless:true,executablePath:'C:/Users/macbook/AppData/Local/ms-playwright/chromium-1243/chrome-win64/chrome.exe'});
|
|
try{
|
|
const ctx=await browser.newContext({ignoreHTTPSErrors:false}),page=await ctx.newPage();
|
|
page.on('pageerror',e=>proof.errors.push({type:e.name}));
|
|
page.on('request',r=>{if(r.url().startsWith('http:'))proof.mixed.push(new URL(r.url()).pathname);});
|
|
for(const route of ['/register','/email/verify','/settings/security']){
|
|
const response=await page.goto(proof.target+route,{waitUntil:'networkidle'});
|
|
proof.routes.push({requested:route,final_path:new URL(page.url()).pathname,status:response.status()});
|
|
if(route==='/register'){
|
|
assert.equal(response.status(),200);assert.equal(new URL(page.url()).pathname,route);
|
|
proof.tls=await response.securityDetails();proof.secure_context=await page.evaluate(()=>isSecureContext);
|
|
for(const name of ['name','email','password','password_confirmation'])assert(await page.locator('input[name="'+name+'"]').isVisible());
|
|
assert(await page.locator('[data-test="register-user-button"]').isVisible());proof.register_form_visible=true;
|
|
const form=await page.locator('form').evaluate(f=>({action:new URL(f.action).pathname,method:f.method}));
|
|
assert.equal(form.action,'/register');assert.equal(form.method,'post');proof.form=form;
|
|
await page.screenshot({path:path.join(P,'onboarding-public-registration.png'),fullPage:true});
|
|
}else{assert.equal(new URL(page.url()).pathname,'/login');assert.equal(response.status(),200);}
|
|
}
|
|
assert(proof.secure_context&&proof.errors.length===0&&proof.mixed.length===0);proof.result='passed';
|
|
}catch(e){proof.result='stopped';proof.error_type=e.name;process.exitCode=1;}
|
|
finally{fs.writeFileSync(path.join(P,'onboarding-public-browser.json'),JSON.stringify(proof,null,2));await browser.close();console.log(JSON.stringify(proof));}
|
|
})();
|