fix: select native variables by datatype and explain rejected links

This commit is contained in:
jhartworks committed 2026-11-12 10:14:19 +01:00
1 parent 4967dd7950
commit 8c6b23bd22
29 files changed
+2031 -1790

No files matched your search

+19
View File
@@ -53,6 +53,13 @@ try {
picker.options = [{ id: "sensor.301", label: "Temperatur Küche EG" }, { id: "sensor.303", label: "Leistung Küche EG" }, { id: "sensor.430", label: "Temperatur Küche OG" }, { id: "sensor.601", label: "Betriebsstunden" }];
picker.fixed = [{ id: "none", label: "Keine Variable" }];
picker.value = "sensor.301";
picker.context = { label: "Temperatur", types: [1, 2], states: {
"sensor.301": { entity_id: "sensor.301", state: "21.5", attributes: { symcon_variable_type: 2 } },
"climate.302": { entity_id: "climate.302", state: "off", attributes: { symcon_variable_type: 0 } },
"sensor.303": { entity_id: "sensor.303", state: "10", attributes: { symcon_variable_type: 2 } },
"sensor.430": { entity_id: "sensor.430", state: "22", attributes: { symcon_variable_type: 2 } },
"sensor.601": { entity_id: "sensor.601", state: "40", attributes: { symcon_variable_type: 1 } },
} };
window.pickerChanges = [];
picker.addEventListener("change", (event) => window.pickerChanges.push(event.detail?.value ?? "NATIVE"));
const ha = document.querySelector("#ha");
@@ -82,6 +89,18 @@ try {
assert.ok(result.rows.some((row) => row.id === "object-302" && row.disabled === "true"), "incompatible variables remain visible");
assert.ok(result.rows.some((row) => row.name === "Leerer Ordner"), "empty categories must stay visible");
assert.ok(!result.text.includes("sensor.301"), "internal IDs must not appear in picker text");
await click("#object-302"); await settle();
assert.ok(await page.evaluate(() => {
const root = document.querySelector("#symcon").shadowRoot.querySelector("nf-symcon-object-picker").shadowRoot;
return /Datentyp Boolean.*Integer oder Float/.test(root.querySelector('[role=status]').textContent) && root.querySelector('.apply').disabled;
}), "an incompatible variable explains its actual type and disables confirmation instead of retaining an earlier pending choice");
assert.equal((await state()).value, "sensor.301", "a rejection does not clear the saved link");
await page.screenshot({ path: join(out, "symcon-picker-rejection.png") });
await click("#object-301"); await settle();
assert.equal(await page.evaluate(() => !!document.querySelector("#symcon").shadowRoot.querySelector("nf-symcon-object-picker").shadowRoot.querySelector('[role=status]')), false, "a valid selection removes the message");
await click("#object-200"); await settle();
assert.match((await state()).text, /Instanz.*Variable/);
await click("#object-301"); await settle();
await page.screenshot({ path: join(out, "symcon-picker-desktop.png") });
await page.keyboard.press("Escape");
assert.equal((await state()).open, false, "Escape closes the native modal");