Reconcile local main history and retain qualified dashboard fixes

This commit is contained in:
archipelago
2026-10-08 07:53:33 -04:00
4 changed files with 69 additions and 2 deletions
@@ -2,6 +2,7 @@ import { describe, it, expect, afterEach, beforeEach, vi } from 'vitest'
import { mount, flushPromises } from '@vue/test-utils'
import MediaLightbox from '../cloud/MediaLightbox.vue'
import { usePipSession } from '../../composables/usePipSession'
import { togglePip } from '../../utils/pip'
import type { FileBrowserItem } from '../../api/filebrowser-client'
// jsdom has no picture-in-picture implementation — stub the pieces the
@@ -75,6 +76,18 @@ async function mountLightbox() {
}
describe('MediaLightbox picture-in-picture handoff', () => {
it('checks PiP support when the action is invoked in a WebView', async () => {
const video = document.createElement('video')
const request = vi.spyOn(video, 'requestPictureInPicture')
Object.defineProperty(document, 'pictureInPictureEnabled', { value: false, configurable: true })
await togglePip(video)
expect(request).not.toHaveBeenCalled()
Object.defineProperty(document, 'pictureInPictureEnabled', { value: true, configurable: true })
await togglePip(video)
expect(request).toHaveBeenCalledOnce()
})
it('entering PiP emits close exactly once and adopts the video before doing so', async () => {
const wrapper = await mountLightbox()
const video = findVideo()
+4 -1
View File
@@ -20,7 +20,10 @@ export function isPipSupported(): boolean {
}
export async function togglePip(video: HTMLVideoElement | null | undefined): Promise<void> {
if (!video || !pipSupported) return
// Check at call time. Embedded WebViews can expose the document capability
// after the module has been evaluated, and companion navigation can restore
// a page with a different media capability than its first load.
if (!video || !isPipSupported()) return
try {
if (document.pictureInPictureElement === video) await document.exitPictureInPicture()
else await video.requestPictureInPicture()