fix: Downloads for iOS (#1869)

- Closes #1863

---------

Co-authored-by: Ilya Rakhlin <i.rakhlin@gmail.com>
This commit is contained in:
Dermot Duffy
2025-02-01 16:08:32 -08:00
committed by GitHub
co-authored by Ilya Rakhlin
parent a6ecb76efe
commit 43947b49dc
4 changed files with 70 additions and 24 deletions
+3 -7
View File
@@ -46,20 +46,16 @@ describe('downloadURL', () => {
expect(link.click).toBeCalled();
});
it('should download in apps via window.open', () => {
it('should download different origin via window.open', () => {
// Set the origin to the same.
const location: Location & { origin: string } = mock<Location>();
location.origin = 'http://foo';
global.window.location = location;
vi.stubGlobal('navigator', {
userAgent: 'Home Assistant/2023.3.0-3260 (Android 13; Pixel 7 Pro)',
});
const windowSpy = vi.spyOn(window, 'open').mockReturnValue(null);
downloadURL('http://foo/url.mp4');
expect(windowSpy).toBeCalledWith('http://foo/url.mp4', '_blank');
downloadURL('http://bar/url.mp4');
expect(windowSpy).toBeCalledWith('http://bar/url.mp4', '_blank');
});
});