mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-29 03:09:36 +00:00
39 lines
2.2 KiB
JavaScript
39 lines
2.2 KiB
JavaScript
import { launch, checkAll, finish } from './serve.mjs';
|
||
const { page, browser } = await launch();
|
||
const res = await page.evaluate(async () => {
|
||
const out = {};
|
||
const c = window.__card;
|
||
const sr = () => c.shadowRoot || c.renderRoot;
|
||
const setFill = async (settings) => {
|
||
c._serverCfg = { ...c._serverCfg, spaces: c._serverCfg.spaces.map((s) => s.id !== 'f1' ? s : ({ ...s, settings })) };
|
||
c.requestUpdate(); await c.updateComplete;
|
||
return [...sr().querySelectorAll('.room.styled')].map((r) => {
|
||
const st = r.getAttribute('style') || '';
|
||
const m = st.match(/--room-fill:([^;]+)/);
|
||
return m ? m[1] : null;
|
||
});
|
||
};
|
||
// living room avg temp = 22.4 (единственный термометр в demo)
|
||
out.comfy = await setFill({ show_borders: true, fill_mode: 'temp', temp_min: 20, temp_max: 25 });
|
||
out.cold = await setFill({ show_borders: true, fill_mode: 'temp', temp_min: 23, temp_max: 26 });
|
||
out.hot = await setFill({ show_borders: true, fill_mode: 'temp', temp_min: 18, temp_max: 21 });
|
||
out.swapped = await setFill({ show_borders: true, fill_mode: 'temp', temp_min: 25, temp_max: 20 });
|
||
// диалог: поля границ видны только в режиме temp
|
||
c._openSpaceDialog('edit', 'f1'); await c.updateComplete;
|
||
out.dialogTempFields = sr().querySelectorAll('.tempin').length;
|
||
c._spaceDialog = { ...c._spaceDialog, fillMode: 'custom' }; await c.updateComplete;
|
||
out.dialogHiddenWhenCustom = sr().querySelectorAll('.tempin').length;
|
||
c._spaceDialog = null;
|
||
return out;
|
||
});
|
||
// значения зафиксированы прогоном на v1.43.1 и сверены с кодом (audit T1)
|
||
checkAll(res, {
|
||
"comfy": ["#66d17a", "transparent", "transparent", "transparent"],
|
||
"cold": ["#4fc3f7", "transparent", "transparent", "transparent"],
|
||
"hot": ["#ffd45c", "transparent", "transparent", "transparent"],
|
||
"swapped": ["#66d17a", "transparent", "transparent", "transparent"],
|
||
"dialogTempFields": 4, // масштаб + мин/макс + компас пространства (docs/SUN.md)
|
||
"dialogHiddenWhenCustom": 2, // мин/макс скрыты; масштаб и компас остаются
|
||
});
|
||
await finish(browser, res);
|