1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00

Follow-up: revert ultimate fallback to undefined in computeEntityEntryName (#26629)

This commit is contained in:
Drinor Dalipi
2025-08-21 09:50:48 +02:00
committed by GitHub
parent feed58c33e
commit 3a70310f78
2 changed files with 22 additions and 1 deletions

View File

@@ -31,7 +31,7 @@ export const computeEntityEntryName = (
entry.name ||
("original_name" in entry && entry.original_name != null
? String(entry.original_name)
: "");
: undefined);
const device = entry.device_id ? hass.devices[entry.device_id] : undefined;

View File

@@ -159,4 +159,25 @@ describe("computeEntityEntryName", () => {
expect(computeEntityEntryName(entry as any, hass as any)).toBe("2");
vi.restoreAllMocks();
});
it("returns undefined when entity has device but no name or original_name", () => {
vi.spyOn(computeDeviceNameModule, "computeDeviceName").mockReturnValue(
"Kitchen Device"
);
const entry = {
entity_id: "sensor.kitchen_sensor",
// No name property
// No original_name property
device_id: "dev1",
};
const hass = {
devices: { dev1: {} },
states: {},
};
// Should return undefined to maintain function contract
expect(computeEntityEntryName(entry as any, hass as any)).toBeUndefined();
vi.restoreAllMocks();
});
});