33 lines
3.9 KiB
JavaScript
33 lines
3.9 KiB
JavaScript
// Compiled Razor/CSS/JS with controlled recorded values; never queues AI or modifies a record.
|
|
const {chromium}=require('playwright'),assert=require('node:assert/strict'),fs=require('node:fs');
|
|
const base=process.env.PD_BROWSER_BASE||'http://127.0.0.1:5238';
|
|
(async()=>{const browser=await chromium.launch();let step='setup';try{
|
|
const c=await browser.newContext({viewport:{width:1450,height:1000}});let data={};const errors=[];let posts=0;
|
|
await c.route('**/signalr.min.js',r=>r.fulfill({contentType:'application/javascript',body:fs.readFileSync(require.resolve('@microsoft/signalr/dist/browser/signalr.min.js'),'utf8')}));
|
|
await c.route('**/native-companion/status',r=>r.fulfill({json:[]}));await c.route('**/native-companion/connection-state',r=>r.fulfill({json:{known:false}}));
|
|
await c.route('**/Characters/Workspace/Tab/*',async r=>{const query=new URLSearchParams({biography:data.biography||'',summary:data.summary||''});await r.fulfill({response:await r.fetch({url:base+'/character-overview-fixture?'+query})});});
|
|
c.on('request',r=>{if(r.method()==='POST'&&new URL(r.url()).pathname.startsWith('/Characters/'))posts++;});
|
|
const cases=[
|
|
{name:'identical',biography:'Recorded biography.',summary:'Recorded biography.',show:false},
|
|
{name:'whitespace',biography:'Recorded biography. More detail.',summary:'Recorded biography.\n\tMore\u00a0detail.',show:false},
|
|
{name:'distinct overlap',biography:'Recorded biography.',summary:'Recorded biography. Distinct recorded insight.',show:true},
|
|
{name:'biography only',biography:'Author narrative only.',show:false},
|
|
{name:'analysis only',summary:'Recorded analysis only.',show:true},
|
|
{name:'neither',show:false}
|
|
];
|
|
if(process.env.PD_CHARACTER_OVERVIEW_SNAPSHOT){const actual=JSON.parse(fs.readFileSync(process.env.PD_CHARACTER_OVERVIEW_SNAPSHOT));cases.unshift({name:'Barbara Development recorded values',...actual,show:false});}
|
|
const p=await c.newPage();p.on('pageerror',e=>errors.push(e.message));await p.addLocatorHandler(p.locator('[data-desktop-continue]'),n=>n.click());
|
|
for(const item of cases){step=item.name;data=item;await p.goto(base+'/character-workspace-fixture');await p.waitForSelector('[data-character-tab-content="overview"]');
|
|
assert.equal(await p.locator('[data-character-generated-analysis]').count(),item.show?1:0);
|
|
if(item.show){assert.equal(await p.locator('[data-character-analysis-summary]').innerText(),item.summary);assert.equal(await p.locator('[data-character-generated-analysis] p').count(),1);}
|
|
assert.equal(await p.locator('[data-character-analysis-dob],[data-character-analysis-age],[data-character-analysis-height],[data-character-analysis-eye]').count(),0);
|
|
for(const heading of ['Profile','Biography and description','At a glance','Known names','Recent recorded changes'])assert.equal(await p.getByRole('heading',{name:heading,exact:true}).count(),1);
|
|
assert.equal(await p.locator('[data-character-birth-date]').count(),1);assert.equal(await p.locator('[data-character-profile-age]').count(),1);
|
|
if(item.biography)assert.equal(await p.locator('.character-long-text').first().innerText(),item.biography);
|
|
assert.match(await p.getByRole('link',{name:'Edit profile and background'}).getAttribute('href'),/\/Characters\/Edit\/5/);
|
|
for(const width of [1450,900,390]){await p.setViewportSize({width,height:950});assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2));}
|
|
}
|
|
assert.equal(posts,0,'Overview reads never save or queue analysis');assert.deepEqual(errors,[]);
|
|
console.log('PASS compiled Character Overview: exact/Unicode whitespace duplicate, overlapping distinct analysis, biography-only, analysis-only, neither, structured Profile once, no empty analysis card, other Overview panels/edit route preserved, responsive desktop/mobile'+(process.env.PD_CHARACTER_OVERVIEW_SNAPSHOT?', actual Barbara Development snapshot':'')+'.');
|
|
}catch(e){console.error('FAILED '+step+': '+e.stack);process.exitCode=1;}finally{await browser.close();}})();
|