18 lines
2.4 KiB
JavaScript
18 lines
2.4 KiB
JavaScript
const {chromium}=require('playwright'),fs=require('node:fs'),assert=require('node:assert/strict');
|
|
const identity=JSON.parse(fs.readFileSync(process.argv[2]));assert.equal(identity.Database,'PlotDirector_Development');assert(identity.Email.startsWith('pwa-browser-'));
|
|
const restricted=JSON.parse(fs.readFileSync('/srv/repos/PlotDirector.Website/Tests/restricted-help-routes.json'));const base='https://dev.plotdirector.com';
|
|
(async()=>{const browser=await chromium.launch();const checks=[];try{
|
|
for(const signedIn of [false,true]){
|
|
const ctx=await browser.newContext(),page=await ctx.newPage();
|
|
if(signedIn){await page.goto(base+'/Account/Login');await page.locator('#Email').fill(identity.Email);await page.locator('#Password').fill(identity.Password);await Promise.all([page.waitForURL('**/Projects'),page.locator('form button[type=submit]').click()]);}
|
|
await page.goto(base+'/help');assert.equal(await page.locator('a[href*="story-intelligence-admin"]').count(),0);assert(!((await page.locator('main').innerText()).includes('Story Intelligence Admin')));
|
|
for(const a of restricted.articles){for(const path of [a.Url,'/Help/Article/'+encodeURIComponent(a.ContextKey),'/HelpDrawer/Article?key='+encodeURIComponent(a.ContextKey)]){const response=await page.request.get(base+path);assert.equal(response.status(),404,path);}}
|
|
for(const path of restricted.categories){const response=await page.request.get(base+path);assert.equal(response.status(),404);}
|
|
await page.goto(base+'/help?q=Story%20Intelligence%20Admin');assert.equal(await page.locator('a[href*="story-intelligence-admin"]').count(),0);
|
|
checks.push({principal:signedIn?'authenticated nonadministrator':'anonymous',articleAndAliasDenials:restricted.articles.length*3,categoryDenials:restricted.categories.length,navigationAndSearchClean:true});
|
|
await ctx.close();
|
|
}
|
|
const publicPage=await browser.newPage();await publicPage.goto('http://192.168.10.10:5051/help');await publicPage.screenshot({path:'/tmp/pd-public-help-visibility.png',fullPage:true});
|
|
fs.writeFileSync('/tmp/pd-help-application-browser.json',JSON.stringify({passed:true,checks,administratorRendering:'All 42 real controllers/Markdown renders verified by focused policy/claims tests; no owner credentials used'},null,2));console.log(JSON.stringify({passed:true,checks}));
|
|
}finally{await browser.close();}})().catch(e=>{console.error(e.message);process.exitCode=1;});
|