Merge pull request 'test(#268): guard phone-client flow from triggering audio playback' (#271) from dev/issue-268-phone-ui-audio-guard into main
All checks were successful
CI / test-and-quality (push) Successful in 2m32s

This commit was merged in pull request #271.
This commit is contained in:
2026-03-02 04:58:11 +01:00

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();
});
});