From b86909af52c34307343642772482fb954c8586d7 Mon Sep 17 00:00:00 2001 From: Timo K Date: Tue, 2 Jun 2026 10:56:34 +0200 Subject: [PATCH] temp add tests --- src/state/CallViewModel/CallViewModel.test.ts | 37 ++++++++++++++++++- src/state/CallViewModel/CallViewModel.ts | 9 ++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/state/CallViewModel/CallViewModel.test.ts b/src/state/CallViewModel/CallViewModel.test.ts index fc25df481..1bf26d9bb 100644 --- a/src/state/CallViewModel/CallViewModel.test.ts +++ b/src/state/CallViewModel/CallViewModel.test.ts @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE in the repository root for full details. */ -import { test, vi, onTestFinished, it, describe } from "vitest"; +import { test, vi, onTestFinished, it, describe, expect } from "vitest"; import { BehaviorSubject, combineLatest, @@ -899,6 +899,41 @@ describe.each([ }, ); + // TODO add media to lk mocks + test.skip("onPipMediaOrientationUpdate is called with the spotlight media orientation", () => { + // Set the spy before creating the view model so the initial call is captured + const onPipMediaOrientationUpdate = vi.fn(); + window.controls.onPipMediaOrientationUpdate = onPipMediaOrientationUpdate; + onTestFinished(() => { + window.controls.onPipMediaOrientationUpdate = undefined; + }); + + withTestScheduler(({ behavior }) => { + // Alice starts as a regular participant, then shares her screen, then stops + const aliceSharingInputMarbles = "nyn"; + + withCallViewModel( + { + remoteParticipants$: constant([aliceParticipant]), + rtcMembers$: constant([localRtcMember, aliceRtcMember]), + sharingScreen: new Map([ + [aliceParticipant, behavior(aliceSharingInputMarbles, yesNo)], + ]), + }, + () => {}, + ); + }); + + // Should be called exactly 3 times: + // 1. Initially with "portrait" (Alice is in spotlight as a user, default portrait orientation) + // 2. With "landscape" when Alice starts screen sharing (screen shares always use landscape) + // 3. With "portrait" again when Alice stops screen sharing and returns to user tile + expect(onPipMediaOrientationUpdate).toHaveBeenCalledTimes(3); + expect(onPipMediaOrientationUpdate).toHaveBeenNthCalledWith(1, "portrait"); + expect(onPipMediaOrientationUpdate).toHaveBeenNthCalledWith(2, "landscape"); + expect(onPipMediaOrientationUpdate).toHaveBeenNthCalledWith(3, "portrait"); + }); + test("PiP tile in expanded spotlight layout switches speakers without layout shifts", () => { withTestScheduler(({ behavior, schedule, expectObservable }) => { // Switch to spotlight immediately diff --git a/src/state/CallViewModel/CallViewModel.ts b/src/state/CallViewModel/CallViewModel.ts index bdeca679a..bd89c7c58 100644 --- a/src/state/CallViewModel/CallViewModel.ts +++ b/src/state/CallViewModel/CallViewModel.ts @@ -1208,13 +1208,12 @@ export function createCallViewModel$( } return layout; }), - tap((orientation) => { - logger.info("controls api pip orientation updated:", orientation); - window.controls.onPipMediaOrientationUpdate?.(orientation); - }), scope.bind(), ) - .subscribe(); + .subscribe((orientation) => { + logger.info("controls api pip orientation updated:", orientation); + window.controls.onPipMediaOrientationUpdate?.(orientation); + }); /** * The media to be used to produce a layout.