47 lines
2.5 KiB
JavaScript
47 lines
2.5 KiB
JavaScript
// Run with: node tests/css_usage_audit.cjs
|
|
// Ensure the review archive stays unreferenced and critical live styles survive.
|
|
'use strict';
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const assert = require('node:assert/strict');
|
|
const root = path.resolve(__dirname, '..');
|
|
const read = file => fs.readFileSync(path.join(root, file), 'utf8');
|
|
const active = read('src/admin/web/style.css');
|
|
const unused = read('src/admin/web/unused.css');
|
|
const docs = read('src/admin/web/docs.css');
|
|
const archived = [
|
|
'auth-ip-card', 'certificate-dialog', 'config-columns', 'overview-grid',
|
|
'overview-inline-hidden-toggle', 'overview-layout-body', 'overview-layout-filters',
|
|
'overview-layout-grid', 'overview-layout-hidden-list', 'overview-layout-section-heading',
|
|
'settings-grid', 'stream-dashboard-card', 'table-container', 'transport-grid', 'www-service-heading',
|
|
];
|
|
for (const name of archived) {
|
|
const cssClass = new RegExp(`\\.${name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?![-\\w])`);
|
|
assert.ok(!cssClass.test(active), `${name} must not remain in the active stylesheet`);
|
|
assert.ok(cssClass.test(unused), `${name} must be reviewable in unused.css`);
|
|
}
|
|
for (const name of ['vh-setting-section', 'dashboard-overview-grid', 'vh-override-fields',
|
|
'refresh-settings-grid', 'docker-backend-ip-settings', 'acl-profile-layout']) {
|
|
assert.ok(active.includes(`.${name}`), `active class ${name} was removed`);
|
|
}
|
|
for (const file of [
|
|
'src/admin/web/index.html', 'src/admin/web/login.html', 'src/admin/web/docs.html',
|
|
'src/admin/panel_assets.rs', 'src/admin/documentation.rs',
|
|
]) assert.ok(!read(file).includes('unused.css'), `${file} must not load or serve unused.css`);
|
|
assert.ok(!/@import[^;]*unused\.css/.test(active));
|
|
assert.match(unused, /NOT INCLUDED by the admin panel/);
|
|
assert.match(docs, /\.swagger-ui \.opblock/);
|
|
for (const style of ['square', 'subtle', 'rounded', 'extra']) {
|
|
assert.ok(active.includes(`html[data-corner-style=${style}]`));
|
|
assert.ok(docs.includes(`html[data-corner-style=${style}]`));
|
|
}
|
|
for (const name of ['app-startup-spin', 'app-startup-reveal']) {
|
|
assert.ok(active.includes(`@keyframes ${name}`));
|
|
assert.ok(!unused.includes(`@keyframes ${name}`));
|
|
}
|
|
assert.ok(!active.includes('--backdrop-soft'));
|
|
assert.ok(!active.includes('var(--panel-strong)'));
|
|
assert.ok(!active.includes('var(--border)'));
|
|
assert.match(read('CHANGELOG.md'), /CSS maintenance:/);
|
|
console.log('CSS used/unused segregation, asset isolation and corner-style regression: PASS');
|