diff --git a/src/components-lib/menu-button-controller.ts b/src/components-lib/menu-button-controller.ts index ff7a418f..b985c4c3 100644 --- a/src/components-lib/menu-button-controller.ts +++ b/src/components-lib/menu-button-controller.ts @@ -129,7 +129,7 @@ export class MenuButtonController { // Show all cameras in the menu rather than just cameras that support the // current view for a less surprising UX. const menuCameraIDs = cameraManager.getStore().getCameraIDsWithCapability('menu'); - if (menuCameraIDs.size) { + if (menuCameraIDs.size > 1) { const menuItems = Array.from( cameraManager.getStore().getCameraConfigEntries(menuCameraIDs), ([cameraID, config]) => { diff --git a/tests/components-lib/menu-button-controller.test.ts b/tests/components-lib/menu-button-controller.test.ts index 65cb5be1..0833a42e 100644 --- a/tests/components-lib/menu-button-controller.test.ts +++ b/tests/components-lib/menu-button-controller.test.ts @@ -27,7 +27,6 @@ import { createCameraConfig, createCameraManager, createCapabilities, - createCardAPI, createConfig, createHASS, createMediaCapabilities, @@ -115,7 +114,7 @@ describe('MenuButtonController', () => { }); describe('should have cameras menu', () => { - it('with multiple cameras', () => { + it('should have cameras menu with multiple cameras', () => { const cameraManager = createCameraManager(); vi.mocked(cameraManager.getStore).mockReturnValue( createStore([ @@ -167,13 +166,18 @@ describe('MenuButtonController', () => { }); }); - it('without a visible camera', () => { + it('should not have cameras menu with <= 1 camera', () => { const cameraManager = createCameraManager(); vi.mocked(cameraManager.getStore).mockReturnValue( createStore([ - { cameraID: 'camera-1', config: createCameraConfig({ hide: true }) }, + { cameraID: 'camera-1', capabilities: createCapabilities({ menu: true }) }, + { cameraID: 'camera-3', capabilities: createCapabilities({ menu: false }) }, ]), ); + vi.mocked(cameraManager).getCameraMetadata.mockReturnValue({ + title: 'title', + icon: 'icon', + }); const buttons = calculateButtons(controller, { cameraManager: cameraManager }); expect(buttons).not.toEqual(