test(player): lock primary-device audio policy for issue 260
All checks were successful
CI / test-and-quality (push) Successful in 2m56s
CI / test-and-quality (pull_request) Successful in 2m57s

This commit is contained in:
2026-03-02 02:30:11 +00:00
parent 361f78b1c8
commit 0bb15f749b
2 changed files with 45 additions and 0 deletions

View File

@@ -468,6 +468,33 @@ describe('PlayerShellComponent gameplay wiring', () => {
component.ngOnDestroy();
});
it('keeps primary-device playback untouched when no-audio capability is disabled', async () => {
const originalPlay = vi.fn().mockResolvedValue(undefined);
const mediaPrototype = { play: originalPlay };
vi.stubGlobal('window', {
location: { hash: '', search: '' },
history: { state: null, replaceState: vi.fn() },
localStorage: { getItem: vi.fn().mockReturnValue('en'), setItem: vi.fn(), removeItem: vi.fn() },
sessionStorage: { getItem: vi.fn().mockReturnValue(null), setItem: vi.fn(), removeItem: vi.fn() },
HTMLMediaElement: { prototype: mediaPrototype },
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
});
vi.stubGlobal('navigator', { language: 'en-US', onLine: true });
const component = new PlayerShellComponent();
(component as any).clientHasNoAudioOutput = false;
component.ngOnInit();
await expect(mediaPrototype.play()).resolves.toBeUndefined();
expect(mediaPrototype.play).toBe(originalPlay);
expect((mediaPrototype as any).__wppSecondaryDeviceAudioGuard__).toBeUndefined();
component.ngOnDestroy();
});
it('resolves i18n warning copy from shared catalog without key fallback', () => {
const component = new PlayerShellComponent();