mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-19 18:28:42 +00:00
Follow-up: revert ultimate fallback to undefined in computeEntityEntryName (#26629)
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user