65 lines
4.5 KiB
JavaScript
65 lines
4.5 KiB
JavaScript
const {chromium}=require('playwright');
|
|
const assert=require('node:assert/strict');
|
|
(async()=>{const browser=await chromium.launch();try{
|
|
for(const pwa of [false,true]){
|
|
const context=await browser.newContext({viewport:{width:1440,height:1000}});
|
|
if(pwa)await context.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true}));
|
|
const page=await context.newPage(),errors=[];page.on('pageerror',e=>errors.push(e.message));
|
|
for(const theme of ['modern-light','modern-dark','warm-light','warm-dark']){
|
|
await page.goto('http://127.0.0.1:5238/fixture?desktop=Locations&layout=full');
|
|
await page.evaluate(theme=>PlotDirectorApplyApplicationTheme(theme),theme);
|
|
const toolbar=page.locator('.location-hierarchy-toolbar');
|
|
assert.equal(await toolbar.isVisible(),!pwa);
|
|
const group=pwa?page.locator('[data-pwa-context-controls] .pd-context-group[aria-label="Location hierarchy"]'):toolbar;
|
|
const parent=group.getByRole('button',{name:'Change parent',exact:true}),relationship=group.getByRole('button',{name:'Create relationship',exact:true});
|
|
await parent.waitFor();await relationship.waitFor();
|
|
if(pwa){
|
|
assert.equal(await group.locator('.pd-context-segmented').count(),0);
|
|
const a=await parent.boundingBox(),b=await relationship.boundingBox();
|
|
assert.ok(b.x>a.x+a.width,'Separate ribbon commands have a gap');
|
|
assert.ok(a.height>=45&&b.height>=45,'Ordinary icon-and-label ribbon commands');
|
|
assert.equal(await parent.locator('svg').isVisible(),true);
|
|
assert.equal(await relationship.locator('svg').isVisible(),true);
|
|
}
|
|
await relationship.focus();await page.keyboard.press('Enter');
|
|
assert.equal(await parent.getAttribute('aria-pressed'),'false');assert.equal(await relationship.getAttribute('aria-pressed'),'true');
|
|
assert.equal(await page.locator('[data-location-drag-action]').inputValue(),'relationship');
|
|
await page.reload();
|
|
assert.equal(await relationship.getAttribute('aria-pressed'),'true','Persisted preference restores through ribbon binding');
|
|
assert.notEqual(await relationship.evaluate(node=>getComputedStyle(node).boxShadow),'none','Selected command is recessed');
|
|
await parent.click();
|
|
await page.waitForTimeout(200);
|
|
assert.equal(await parent.evaluate(node=>{const probe=document.createElement('span');probe.style.color='var(--pd-text)';node.append(probe);const expected=getComputedStyle(probe).color;probe.remove();return getComputedStyle(node).color===expected;}),true,'Depressed command retains readable theme foreground');
|
|
const source=page.locator('[data-drag-id="1"]'),target=page.locator('[data-drag-id="2"]');
|
|
assert.equal(await source.getAttribute('draggable'),null,'Row links and controls are not drag initiators');
|
|
const handle=source.locator('[data-location-drag-handle]');
|
|
assert.equal(await handle.getAttribute('draggable'),'true');
|
|
assert.equal(await handle.evaluate(node=>getComputedStyle(node).cursor),'grab');
|
|
assert.match(await handle.getAttribute('aria-label'),/choose Edit/);
|
|
assert.ok(await source.getByRole('link',{name:'Edit',exact:true}).isVisible(),'Accessible parent-edit alternative remains available');
|
|
await handle.dragTo(target);
|
|
const confirmation=page.locator('#plotlineConfirmModal');
|
|
await confirmation.waitFor({state:'visible'});
|
|
assert.match(await confirmation.innerText(),/Building/);
|
|
await confirmation.locator('[data-bs-dismiss="modal"]').last().click();
|
|
await confirmation.waitFor({state:'hidden'});
|
|
await page.locator('.modal-backdrop').waitFor({state:'hidden'});
|
|
await relationship.click();
|
|
await handle.dragTo(target);
|
|
const editor=page.locator('[data-location-relationship-modal]');
|
|
await editor.waitFor({state:'visible'});
|
|
await editor.locator('[data-drag-cancel]').first().click();
|
|
await editor.waitFor({state:'hidden'});
|
|
await parent.click();
|
|
const map=page.locator('#ribbon-panel-world a[data-ribbon-icon=maps]');
|
|
const floor=page.locator('#ribbon-panel-world a[data-ribbon-icon=floorplans]');
|
|
assert.equal(await map.getAttribute('data-ribbon-icon'),'maps');
|
|
assert.equal(await floor.getAttribute('data-ribbon-icon'),'floorplans');
|
|
assert.notEqual(await map.locator('path').getAttribute('d'),await floor.locator('path').getAttribute('d'));
|
|
|
|
}
|
|
assert.deepEqual(errors,[]);await context.close();
|
|
}
|
|
console.log('PASS separate icon-and-label Location hierarchy commands, keyboard selection, persisted state and browser/PWA fallback in four themes');
|
|
}finally{await browser.close();}})().catch(error=>{console.error(error);process.exitCode=1;});
|