test(issue-268): lock phone audio guard against playback regressions
This commit is contained in:
@@ -38,7 +38,10 @@ describe('i18n MVP flow smoke (host/player + audio policy)', () => {
|
|||||||
host.ngOnDestroy();
|
host.ngOnDestroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('keeps audio routing policy primary-only (client has no audio output)', () => {
|
it('keeps audio routing policy primary-only (client has no audio output)', async () => {
|
||||||
|
const originalPlay = vi.fn().mockRejectedValue(new Error('original play'));
|
||||||
|
const mediaPrototype = { play: originalPlay };
|
||||||
|
|
||||||
vi.stubGlobal('window', {
|
vi.stubGlobal('window', {
|
||||||
location: { hash: '', search: '' },
|
location: { hash: '', search: '' },
|
||||||
history: { state: null, replaceState: vi.fn() },
|
history: { state: null, replaceState: vi.fn() },
|
||||||
@@ -46,16 +49,25 @@ describe('i18n MVP flow smoke (host/player + audio policy)', () => {
|
|||||||
sessionStorage: { getItem: vi.fn().mockReturnValue(null), setItem: vi.fn(), removeItem: vi.fn() },
|
sessionStorage: { getItem: vi.fn().mockReturnValue(null), setItem: vi.fn(), removeItem: vi.fn() },
|
||||||
addEventListener: vi.fn(),
|
addEventListener: vi.fn(),
|
||||||
removeEventListener: vi.fn(),
|
removeEventListener: vi.fn(),
|
||||||
|
HTMLMediaElement: { prototype: mediaPrototype },
|
||||||
});
|
});
|
||||||
vi.stubGlobal('navigator', { language: 'en-US', onLine: true });
|
vi.stubGlobal('navigator', { language: 'en-US', onLine: true });
|
||||||
|
vi.stubGlobal('document', { querySelectorAll: vi.fn().mockReturnValue([]) });
|
||||||
|
|
||||||
const host = new HostShellComponent();
|
const host = new HostShellComponent();
|
||||||
const player = new PlayerShellComponent();
|
host.ngOnInit();
|
||||||
|
|
||||||
expect(host.clientHasNoAudioOutput).toBe(true);
|
await expect(mediaPrototype.play()).rejects.toThrow('original play');
|
||||||
expect(player.clientHasNoAudioOutput).toBe(true);
|
|
||||||
|
const player = new PlayerShellComponent();
|
||||||
|
player.ngOnInit();
|
||||||
|
|
||||||
|
await expect(mediaPrototype.play()).resolves.toBeUndefined();
|
||||||
|
|
||||||
player.ngOnDestroy();
|
player.ngOnDestroy();
|
||||||
|
|
||||||
|
await expect(mediaPrototype.play()).rejects.toThrow('original play');
|
||||||
|
|
||||||
host.ngOnDestroy();
|
host.ngOnDestroy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user