Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

test(settings): cover the Picture-in-Picture switch of the Experimental tab

Hristo Terezov7813bb650790
diff --git a/tests/pageobjects/SettingsDialog.ts b/tests/pageobjects/SettingsDialog.ts
index c0585bd503..df2e89ba0d 100644
--- a/tests/pageobjects/SettingsDialog.ts
+++ b/tests/pageobjects/SettingsDialog.ts
@@ -4,9 +4,11 @@ const EMAIL_FIELD = '#setEmail';
const CTRL_ALT_REACTION_SHORTCUTS_CHECKBOX = '//input[@name="enable-ctrl-alt-reaction-shortcuts"]';
const FOLLOW_ME_CHECKBOX = '//input[@name="follow-me"]';
const HIDE_SELF_VIEW_CHECKBOX = '//input[@name="hide-self-view"]';
+const PIP_SWITCH = '#config-option-browserPiP';
const SETTINGS_DIALOG_CONTENT = '.settings-pane';
const START_AUDIO_MUTED_CHECKBOX = '//input[@name="start-audio-muted"]';
const START_VIDEO_MUTED_CHECKBOX = '//input[@name="start-video-muted"]';
+const X_PATH_EXPERIMENTAL_TAB = '//div[contains(@class, "settings-dialog")]//*[text()="Experimental"]';
const X_PATH_MODERATOR_TAB = '//div[contains(@class, "settings-dialog")]//*[text()="Moderator"]';
const X_PATH_MORE_TAB = '//div[contains(@class, "settings-dialog")]//*[text()="General"]';
const X_PATH_PROFILE_TAB = '//div[contains(@class, "settings-dialog")]//*[text()="Profile"]';
@@ -63,6 +65,48 @@ export default class SettingsDialog extends BaseDialog {
return this.openTab(X_PATH_SHORTCUTS_TAB);
}
+ /**
+ * Returns whether the Experimental tab is offered. It is hidden when no config option can be changed by the user in
+ * the current browser and deployment.
+ */
+ hasExperimentalTab() {
+ return this.participant.driver.$(X_PATH_EXPERIMENTAL_TAB).isExisting();
+ }
+
+ /**
+ * Selects the Experimental tab to be displayed.
+ */
+ openExperimentalTab() {
+ return this.openTab(X_PATH_EXPERIMENTAL_TAB);
+ }
+
+ /**
+ * Returns whether browser Picture-in-Picture is switched on in the Experimental tab.
+ */
+ async isPictureInPictureEnabled() {
+ await this.openExperimentalTab();
+
+ return this.participant.driver.$(PIP_SWITCH).isSelected();
+ }
+
+ /**
+ * Switches browser Picture-in-Picture on or off in the Experimental tab.
+ *
+ * @param enable - Whether Picture-in-Picture should be on.
+ */
+ async setPictureInPictureEnabled(enable: boolean) {
+ await this.openExperimentalTab();
+
+ const pipSwitch = this.participant.driver.$(PIP_SWITCH);
+
+ await pipSwitch.waitForExist();
+
+ if (enable !== await pipSwitch.isSelected()) {
+ await pipSwitch.moveTo();
+ await pipSwitch.click();
+ }
+ }
+
/**
* Returns whether the Firefox-only Ctrl+Alt reaction shortcut setting exists.
*/
diff --git a/tests/pageobjects/Toolbar.ts b/tests/pageobjects/Toolbar.ts
index c267480fdb..5e8c9d2ccb 100644
--- a/tests/pageobjects/Toolbar.ts
+++ b/tests/pageobjects/Toolbar.ts
@@ -17,6 +17,7 @@ const OVERFLOW_MENU = 'More actions menu';
const OVERFLOW = 'More actions';
const CLOSE_OVERFLOW = 'Close more actions menu';
const PARTICIPANTS = 'Open participants pane';
+const PIP = 'Enter Picture-in-Picture mode';
const PROFILE = 'Edit your profile';
const RAISE_HAND = 'Raise your hand';
const LOWER_HAND = 'Lower your hand';
@@ -105,6 +106,25 @@ export default class Toolbar extends BasePageObject {
return this.clickButtonInOverflowMenu([ RECORDING, RECORDING_NON_MODERATOR ]);
}
+ /**
+ * Returns whether the Picture-in-Picture button exists in the DOM for this participant, which is the visible
+ * effect of Picture-in-Picture being turned on.
+ *
+ * @returns {Promise<boolean>}
+ */
+ async hasPictureInPictureButton(): Promise<boolean> {
+ // The button usually lives in the overflow ("More actions") menu, so it is only in the DOM while that menu
+ // is open. isExisting() searches the whole DOM, so opening the menu first also covers the case where the
+ // button is promoted to the main toolbar.
+ await this.openOverflowMenu();
+
+ const exists = await this.getButton(PIP).isExisting();
+
+ await this.closeOverflowMenu();
+
+ return exists;
+ }
+
/**
* Returns whether the live streaming button exists in the DOM for this participant.
*
diff --git a/tests/specs/iframe/pipSetting.spec.ts b/tests/specs/iframe/pipSetting.spec.ts
new file mode 100644
index 0000000000..8df9a59275
--- /dev/null
+++ b/tests/specs/iframe/pipSetting.spec.ts
@@ -0,0 +1,52 @@
+import type { Participant } from '../../helpers/Participant';
+import { setTestProperties } from '../../helpers/TestProperties';
+import { joinMuc } from '../../helpers/joinMuc';
+
+import { checkIframeApi } from './util';
+
+setTestProperties(__filename, {
+ description: 'A value an embedder sets for pip.enableBrowserPiP through the iframe API is final: it applies, and '
+ + 'the Experimental tab of the settings dialog does not offer the Picture-in-Picture setting, so the embedder '
+ + 'and the meeting never disagree about whether Picture-in-Picture is on.',
+ usesBrowsers: [ 'p1' ]
+});
+
+describe('Picture-in-Picture setting when embedded', () => {
+ let p1: Participant;
+
+ it('joining the meeting', async () => {
+ p1 = await joinMuc({ name: 'p1', iFrameApi: true }, {
+ configOverwrite: {
+ pip: {
+ enableBrowserPiP: true,
+ showToolbarButton: true
+ }
+ }
+ });
+
+ if (!await checkIframeApi(p1)) {
+ return;
+ }
+
+ if (!await p1.execute(() => 'documentPictureInPicture' in window || document.pictureInPictureEnabled)) {
+ ctx.skipSuiteTests = 'The browser does not support Picture-in-Picture in the iframe';
+ }
+ });
+
+ it('applies the embedder\'s value', async () => {
+ expect(await p1.getToolbar().hasPictureInPictureButton()).toBe(true);
+ });
+
+ it('does not offer the setting to the user', async () => {
+ await p1.getToolbar().clickSettingsButton();
+
+ const settings = p1.getSettingsDialog();
+
+ await settings.waitForDisplay();
+
+ // Picture-in-Picture is the only option of the tab so far, so the whole tab is hidden with it.
+ expect(await settings.hasExperimentalTab()).toBe(false);
+
+ await settings.clickCloseButton();
+ });
+});
diff --git a/tests/specs/ui/pipSetting.spec.ts b/tests/specs/ui/pipSetting.spec.ts
new file mode 100644
index 0000000000..945a9ff8fe
--- /dev/null
+++ b/tests/specs/ui/pipSetting.spec.ts
@@ -0,0 +1,108 @@
+import type { Participant } from '../../helpers/Participant';
+import { setTestProperties } from '../../helpers/TestProperties';
+import { ensureOneParticipant } from '../../helpers/participants';
+
+setTestProperties(__filename, {
+ description: 'The Experimental tab of the settings dialog lets a user turn browser Picture-in-Picture on and off '
+ + 'when the deployment leaves it unset. The choice applies right away and is remembered by the browser for '
+ + 'later meetings.',
+ usesBrowsers: [ 'p1' ]
+});
+
+/**
+ * The toolbar button is the visible effect of the setting, so it must not be hidden by the deployment. Leaves
+ * pip.enableBrowserPiP alone: URL parameters merge into the deployment's config, and a value set there is final and
+ * would hide the setting the test is about.
+ */
+const JOIN_OPTIONS = {
+ configOverwrite: {
+ pip: {
+ showToolbarButton: true
+ }
+ }
+};
+
+describe('Picture-in-Picture setting', () => {
+ it('joining the meeting', async () => {
+ await ensureOneParticipant(JOIN_OPTIONS);
+
+ const { p1 } = ctx;
+ const settings = await openSettings(p1);
+
+ if (!await settings.hasExperimentalTab()) {
+ // The tab has nothing to offer, and is hidden, in a browser without a Picture-in-Picture API and on a
+ // deployment whose config sets pip.enableBrowserPiP.
+ ctx.skipSuiteTests = 'Browser Picture-in-Picture is not left to the user here';
+ }
+
+ await settings.clickCloseButton();
+ });
+
+ it('is off by default', async () => {
+ const { p1 } = ctx;
+
+ expect(await isPiPEnabledInSettings(p1)).toBe(false);
+ expect(await p1.getToolbar().hasPictureInPictureButton()).toBe(false);
+ });
+
+ it('turning it on applies right away', async () => {
+ const { p1 } = ctx;
+
+ await setPiPEnabledInSettings(p1, true);
+
+ expect(await p1.getToolbar().hasPictureInPictureButton()).toBe(true);
+ });
+
+ it('the choice is remembered when joining again', async () => {
+ await ctx.p1.hangup();
+ await ensureOneParticipant(JOIN_OPTIONS);
+
+ const { p1 } = ctx;
+
+ expect(await p1.getToolbar().hasPictureInPictureButton()).toBe(true);
+ expect(await isPiPEnabledInSettings(p1)).toBe(true);
+ });
+
+ it('turning it off applies right away', async () => {
+ const { p1 } = ctx;
+
+ await setPiPEnabledInSettings(p1, false);
+
+ expect(await p1.getToolbar().hasPictureInPictureButton()).toBe(false);
+ });
+});
+
+/**
+ * Opens the settings dialog and waits for it to be displayed.
+ */
+async function openSettings(participant: Participant) {
+ await participant.getToolbar().clickSettingsButton();
+
+ const settings = participant.getSettingsDialog();
+
+ await settings.waitForDisplay();
+
+ return settings;
+}
+
+/**
+ * Reads the state of the Picture-in-Picture switch in the Experimental tab of the settings dialog.
+ */
+async function isPiPEnabledInSettings(participant: Participant) {
+ const settings = await openSettings(participant);
+ const enabled = await settings.isPictureInPictureEnabled();
+
+ await settings.clickCloseButton();
+
+ return enabled;
+}
+
+/**
+ * Switches Picture-in-Picture on or off in the Experimental tab of the settings dialog and submits the dialog.
+ */
+async function setPiPEnabledInSettings(participant: Participant, enable: boolean) {
+ const settings = await openSettings(participant);
+
+ await settings.setPictureInPictureEnabled(enable);
+ await settings.submit();
+}