test(issue-268): lock phone audio guard against playback regressions
All checks were successful
CI / test-and-quality (push) Successful in 3m2s
CI / test-and-quality (pull_request) Successful in 3m5s

This commit is contained in:
2026-03-02 03:49:29 +00:00
parent ee2a202f34
commit e4841afbaa

View File

@@ -38,7 +38,10 @@ describe('i18n MVP flow smoke (host/player + audio policy)', () => {
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', {
location: { hash: '', search: '' },
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() },
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
HTMLMediaElement: { prototype: mediaPrototype },
});
vi.stubGlobal('navigator', { language: 'en-US', onLine: true });
vi.stubGlobal('document', { querySelectorAll: vi.fn().mockReturnValue([]) });
const host = new HostShellComponent();
const player = new PlayerShellComponent();
host.ngOnInit();
expect(host.clientHasNoAudioOutput).toBe(true);
expect(player.clientHasNoAudioOutput).toBe(true);
await expect(mediaPrototype.play()).rejects.toThrow('original play');
const player = new PlayerShellComponent();
player.ngOnInit();
await expect(mediaPrototype.play()).resolves.toBeUndefined();
player.ngOnDestroy();
await expect(mediaPrototype.play()).rejects.toThrow('original play');
host.ngOnDestroy();
});
});