fix: Update components and styles to work with >= HA 2026.2 (#2333)

Caution: Requires HA >= `2026.2`

- Closes #2329
- Closes #2332
This commit is contained in:
Dermot Duffy
2026-02-07 20:32:05 -08:00
committed by GitHub
parent 6eb0a87ca8
commit 49073fee48
17 changed files with 827 additions and 62 deletions
+4 -1
View File
@@ -1,3 +1,4 @@
import { format } from 'date-fns';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { mock } from 'vitest-mock-extended';
import { CameraManagerEngine } from '../../../src/camera-manager/engine';
@@ -514,7 +515,9 @@ describe('FrigateCamera', () => {
);
expect(camera.getEndpoints({ view: 'media', media })?.ui).toEqual({
endpoint: 'http://frigate/recording/front_door/2023-01-01/10',
endpoint:
'http://frigate/recording/front_door/' +
format(media.getStartTime(), 'yyyy-MM-dd/HH'),
});
});
@@ -1,4 +1,4 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
import { afterEach, assert, describe, expect, it, vi } from 'vitest';
import { FrigateEventWatcher } from '../../../src/camera-manager/frigate/event-watcher.js';
import { FrigateEventChange } from '../../../src/camera-manager/frigate/types.js';
import { HomeAssistant } from '../../../src/ha/types.js';
@@ -77,6 +77,33 @@ describe('FrigateEventWatcher', () => {
expect(unsubscribeCallback).toBeCalledTimes(1);
});
it('should handle unsubscribe during pending subscription', async () => {
const stateWatcher = new FrigateEventWatcher();
const hass = createHASS();
let resolveSubscription: ((callback: () => Promise<void>) => void) | undefined;
const subscriptionPromise = new Promise<() => Promise<void>>((resolve) => {
resolveSubscription = resolve;
});
vi.mocked(hass.connection.subscribeMessage).mockReturnValue(subscriptionPromise);
const request = {
instanceID: 'frigate',
callback: vi.fn(),
};
// Start subscription (doesn't complete yet as not awaited).
const subscribePromise = stateWatcher.subscribe(hass, request);
// Unsubscribe while subscription is still pending.
await stateWatcher.unsubscribe(request);
// Complete the subscription.
assert(resolveSubscription);
resolveSubscription(vi.fn());
await subscribePromise;
});
describe('should call handler', () => {
afterEach(() => {
vi.resetAllMocks();