25 lines
1.3 KiB
JavaScript
25 lines
1.3 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { fixture } from './fixture.mjs';
|
|
import { browser } from './browser.mjs';
|
|
import { P, stub } from './helpers/projects-review-fixture.mjs';
|
|
|
|
test('project work reserves a line for a wait reason', async t => {
|
|
const f = await fixture(), b = await browser({machine:false});
|
|
t.after(async () => { await b.close(); await f.close(); });
|
|
await b.call('Page.addScriptToEvaluateOnNewDocument', {source:stub});
|
|
await b.viewport(1440, 1000);
|
|
await b.navigate(f.base + '/#/projects/' + P);
|
|
await b.evaluate(`(async()=>{for(let i=0;i<200;i++){if(document.querySelector('.project-work'))return;await new Promise(r=>setTimeout(r,30))}throw Error('No project work')})()`);
|
|
const positions = await b.evaluate(`(()=>{
|
|
const line=document.querySelector('.project-work-wait'), bottom=document.querySelector('.project-work-bottom');
|
|
if(!line)return null;
|
|
const before=bottom.getBoundingClientRect().top, height=line.getBoundingClientRect().height;
|
|
line.textContent='Waiting: decision';
|
|
return {before,after:bottom.getBoundingClientRect().top,height,filled:line.getBoundingClientRect().height};
|
|
})()`);
|
|
assert.ok(positions, 'the wait line is present while empty');
|
|
assert.equal(positions.after, positions.before);
|
|
assert.ok(positions.height >= positions.filled);
|
|
});
|