You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.3 KiB
JavaScript
65 lines
2.3 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const test = require('node:test');
|
|
|
|
const root = path.join(__dirname, '..');
|
|
|
|
function read(relativePath) {
|
|
return fs.readFileSync(path.join(root, relativePath), 'utf8');
|
|
}
|
|
|
|
test('dashboard starts live polling and exposes required controls', () => {
|
|
const html = read('frontend/index.html');
|
|
const dashboard = read('frontend/dashboard.js');
|
|
|
|
assert.match(html, /id="history-interval"/);
|
|
assert.match(dashboard, /updateDashboard\(\);/);
|
|
assert.match(
|
|
dashboard,
|
|
/setInterval\(updateDashboard,\s*POLLING_INTERVAL_MS\)/
|
|
);
|
|
});
|
|
|
|
test('dashboard HTML has balanced structural containers', () => {
|
|
const html = read('frontend/index.html');
|
|
const openDivs = (html.match(/<div\b/g) || []).length;
|
|
const closeDivs = (html.match(/<\/div>/g) || []).length;
|
|
const openSections = (html.match(/<section\b/g) || []).length;
|
|
const closeSections = (html.match(/<\/section>/g) || []).length;
|
|
|
|
assert.equal(openDivs, closeDivs);
|
|
assert.equal(openSections, closeSections);
|
|
});
|
|
|
|
test('terminal output does not append untrusted HTML', () => {
|
|
const service = read('frontend/ezo-service.js');
|
|
|
|
assert.doesNotMatch(service, /terminalOutput\.innerHTML/);
|
|
assert.match(service, /line\.textContent = message/);
|
|
});
|
|
|
|
test('sensor Makefiles reference their real implementation objects', () => {
|
|
assert.match(read('sensors/EZOPH/Makefile'), /OBJ=main\.o ezoph\.o/);
|
|
assert.match(read('sensors/EZODO/Makefile'), /OBJ=main\.o ezodo\.o/);
|
|
assert.match(read('sensors/EZOEC/Makefile'), /OBJ=main\.o ezoec\.o/);
|
|
assert.ok(read('sensors/EZODO/main.c').trim().length > 0);
|
|
});
|
|
|
|
test('dashboard uses locally installed chart and spreadsheet libraries', () => {
|
|
const html = read('frontend/index.html');
|
|
|
|
assert.match(html, /src="\/vendor\/chart\.js"/);
|
|
assert.match(html, /src="\/vendor\/xlsx\.js"/);
|
|
assert.doesNotMatch(html, /cdn\.jsdelivr|cdn\.sheetjs/);
|
|
});
|
|
|
|
test('hardware acquisition batches all EZO addresses under the shared lock', () => {
|
|
const source = read('sensors/EZOCommand/acquire.c');
|
|
|
|
for (const address of ['0x61', '0x63', '0x64', '0x66']) {
|
|
assert.match(source, new RegExp(address));
|
|
}
|
|
assert.match(source, /photobioreactor-i2c\.lock/);
|
|
});
|