29 lines
1.7 KiB
JavaScript
29 lines
1.7 KiB
JavaScript
'use strict';
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const css = fs.readFileSync(path.join(__dirname, '..', 'popup.css'), 'utf8');
|
|
const js = fs.readFileSync(path.join(__dirname, '..', 'popup.js'), 'utf8');
|
|
const rule = selector => {
|
|
const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
const matches = Array.from(css.matchAll(new RegExp('(?:^|\\n)\\s*' + escaped + '\\s*\\{([^}]*)\\}', 'g')));
|
|
assert.equal(matches.length, 1, `${selector}: expected exactly one CSS rule`);
|
|
return matches[0][1];
|
|
};
|
|
const body = rule('html, body');
|
|
const app = rule('.app');
|
|
const details = rule('#details');
|
|
const panel = rule('.headers-panel');
|
|
assert.match(body, /height\s*:\s*520px/, 'document must have a fixed height');
|
|
assert.match(body, /overflow\s*:\s*hidden/, 'page itself must not scroll');
|
|
assert.match(app, /height\s*:\s*520px/, 'popup must have a fixed height');
|
|
assert.match(details, /flex\s*:\s*1\s+1\s+auto/, 'main view must fill the available space');
|
|
assert.match(panel, /overflow-y\s*:\s*auto/, 'only the table panel should scroll');
|
|
assert.match(panel, /overscroll-behavior\s*:\s*contain/, 'wheel scrolling must not propagate outside panel');
|
|
assert.match(panel, /scrollbar-gutter\s*:\s*stable/, 'scrollbar must not change table width');
|
|
assert.doesNotMatch(js, /document\.scrollingElement\.scrollTop\s*=\s*0/, 'must not reset page scrolling');
|
|
assert.match(js, /if \(renderKey === lastHeaderRenderKey\) return;/, 'unchanged header table should not be re-rendered');
|
|
assert.match(js, /panel\.scrollTop = previousScrollTop;/, 'keep position on header updates');
|
|
console.log('OK: fixed-size popup, only table scrolling; live updates preserve scroll.');
|