feat: Surface the provider's error cause in the media_unavailable notification (#2599)

- Closes: #2592
This commit is contained in:
Dermot Duffy
2026-07-22 20:45:49 -07:00
committed by GitHub
parent 5a549c0326
commit 448fa2d9f1
18 changed files with 255 additions and 90 deletions
@@ -3,22 +3,27 @@ import { expect, it, vi } from 'vitest';
import { dispatchLiveErrorEvent } from '../../../../src/components-lib/live/utils/dispatch-live-error';
// @vitest-environment jsdom
it('should dispatch live error event', () => {
it('should dispatch live error event with an empty error when none is given', () => {
const element = document.createElement('div');
const handler = vi.fn();
element.addEventListener('advanced-camera-card:live:error', handler);
dispatchLiveErrorEvent(element);
expect(handler).toBeCalled();
expect(handler).toHaveBeenCalledWith(expect.objectContaining({ detail: {} }));
});
it('should forward the reason as the event detail', () => {
it('should forward the reason and detail as the event detail', () => {
const element = document.createElement('div');
const handler = vi.fn();
element.addEventListener('advanced-camera-card:live:error', handler);
dispatchLiveErrorEvent(element, 'unsupported');
dispatchLiveErrorEvent(element, {
reason: 'unsupported',
detail: 'Codec not supported',
});
expect(handler).toHaveBeenCalledWith(
expect.objectContaining({ detail: 'unsupported' }),
expect.objectContaining({
detail: { reason: 'unsupported', detail: 'Codec not supported' },
}),
);
});