fix: Lazy unloading should not leave dangling connections (#2004)

- Closes #1992
This commit is contained in:
Dermot Duffy
2025-04-12 10:48:37 +01:00
committed by GitHub
parent a24c9628c5
commit a5ffd51728
12 changed files with 397 additions and 468 deletions
@@ -11,10 +11,11 @@ import {
MutationObserverMock,
callIntersectionHandler,
callMutationHandler,
callVisibilityHandler,
createParent,
flushPromises,
} from '../test-utils';
import { callVisibilityHandler, createTestSlideNodes } from '../utils/embla/test-utils';
import { createTestSlideNodes } from '../utils/embla/test-utils';
const getPlayer = (
element: HTMLElement,
@@ -47,7 +48,7 @@ describe('MediaActionsController', () => {
});
afterAll(() => {
vi.restoreAllMocks();
vi.unstubAllGlobals();
});
beforeEach(() => {
@@ -455,11 +456,7 @@ describe('MediaActionsController', () => {
(await getPlayer(children[0], 'video')?.getMediaPlayerController())?.[func],
).not.toBeCalled();
Object.defineProperty(document, 'visibilityState', {
value: 'visible',
writable: true,
});
await callVisibilityHandler();
await callVisibilityHandler(true);
// Not configured to take action on selection.
expect(
@@ -502,11 +499,7 @@ describe('MediaActionsController', () => {
(await getPlayer(children[0], 'video')?.getMediaPlayerController())?.[func],
).not.toBeCalled();
Object.defineProperty(document, 'visibilityState', {
value: 'hidden',
writable: true,
});
await callVisibilityHandler();
await callVisibilityHandler(false);
// Not configured to take action on selection.
expect(