v0.16.3
This commit is contained in:
1 parent
f376f0a7b6
commit
8059e16d12
36 files changed
+1140
-193
No files matched your search
@@ -0,0 +1,29 @@
|
||||
// Focused UI behavior checks, with no browser or controller required.
|
||||
const fs = require('fs');
|
||||
const vm = require('vm');
|
||||
const ctx = vm.createContext({
|
||||
tr: key => key,
|
||||
app: { zones: [], devices: [], groups: [] },
|
||||
});
|
||||
vm.runInContext(fs.readFileSync('web/js-dynamic/entities.js', 'utf8'), ctx);
|
||||
const zone = {
|
||||
enabled: true,
|
||||
control_owner: 'automation',
|
||||
control_source: 'automation.flow',
|
||||
simple_heat: { day_target: 20, night_target: 20.6 },
|
||||
current_temperature: 20.2,
|
||||
demand: false,
|
||||
};
|
||||
function check(fn, expected, ...args) {
|
||||
const value = ctx[fn](...args);
|
||||
if (value !== expected) throw new Error(`${fn}: ${value} != ${expected}`);
|
||||
}
|
||||
check('zoneControlOwnerLabel', 'zones.ownerFlow', zone);
|
||||
check('zoneRuntimeStatusLabel', 'zones.flowDayOff', zone, 'off', { power: false });
|
||||
check('zoneRuntimeStatusLabel', 'zones.flowDayPendingOff', zone, 'off', { power: true });
|
||||
check('zoneRuntimeStatusLabel', 'zones.flowStandby', zone, 'heat', { power: true, enabled: true, online: true });
|
||||
check('zoneRuntimeStatusLabel', 'zones.flowHeating', { ...zone, demand: true }, 'heat', { power: true, enabled: true, online: true, mode: 'heat' });
|
||||
check('zoneRuntimeStatusLabel', 'zones.flowCoasting', { ...zone, heat_coasting: true }, 'heat', { power: true, enabled: true, online: true });
|
||||
check('zoneRuntimeStatusLabel', 'zones.manualDeviceControl', { ...zone, device_manual_override: true }, 'heat', { power: true });
|
||||
check('zoneControlOwnerLabel', 'zones.ownerExternal', { ...zone, control_owner: 'direct_manual', control_source: 'external' });
|
||||
console.log('OK: 8 UI Flow/manual status scenarios');
|
||||
Reference in new issue
Block a user