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(iframe): add specs for toggleFilmStrip command and events (#17987)

ravindra-RKB17de046a0d61
diff --git a/tests/pageobjects/IframeAPI.ts b/tests/pageobjects/IframeAPI.ts
index e62f2e2891..a8a0c83878 100644
--- a/tests/pageobjects/IframeAPI.ts
+++ b/tests/pageobjects/IframeAPI.ts
@@ -23,6 +23,22 @@ export default class IframeAPI extends BasePageObject {
}, event);
}
+ /**
+ * Waits for an event result from the iframeAPI helper.
+ * @param event The event name.
+ * @param timeoutMsg Optional timeout message.
+ * @param timeout Optional timeout in milliseconds.
+ */
+ waitForEventResult<T = any>(event: string, timeoutMsg?: string, timeout = 5000): Promise<T> {
+ return this.participant.driver.waitUntil(
+ () => this.getEventResult(event),
+ {
+ timeout,
+ timeoutMsg: timeoutMsg || `${event} event was not received`
+ }
+ );
+ }
+
/**
* Clears the history of an event.
* @param event
diff --git a/tests/specs/iframe/filmstrip.spec.ts b/tests/specs/iframe/filmstrip.spec.ts
new file mode 100644
index 0000000000..620a12ed74
--- /dev/null
+++ b/tests/specs/iframe/filmstrip.spec.ts
@@ -0,0 +1,78 @@
+import { expect } from '@wdio/globals';
+
+import type { Participant } from '../../helpers/Participant';
+import { setTestProperties } from '../../helpers/TestProperties';
+import { ensureOneParticipant } from '../../helpers/participants';
+
+import { checkIframeApi } from './util';
+
+setTestProperties(__filename, {
+ usesBrowsers: [ 'p1' ]
+});
+
+describe('Filmstrip iframe API command and events', () => {
+ let p1: Participant;
+
+ /**
+ * Executes the toggleFilmStrip iframe API command and asserts the filmstripDisplayChanged event
+ * and in-meeting DOM visibility.
+ *
+ * @param visible Whether the filmstrip is expected to be visible.
+ */
+ async function toggleAndExpect(visible: boolean) {
+ await p1.switchToMainFrame();
+ await p1.getIframeAPI().clearEventResults('filmstripDisplayChanged');
+ await p1.getIframeAPI().executeCommand('toggleFilmStrip');
+
+ const filmstripEvent: { visible: boolean; } = await p1.getIframeAPI().waitForEventResult(
+ 'filmstripDisplayChanged',
+ `filmstripDisplayChanged event was not received for toggleFilmStrip (${visible ? 'show' : 'hide'})`
+ );
+
+ expect(filmstripEvent).toEqual({ visible });
+
+ await p1.switchToIFrame();
+ await p1.getFilmstrip().assertVisible(visible);
+ }
+
+ it('joining the meeting', async () => {
+ await ensureOneParticipant({}, { name: 'p1', iFrameApi: true });
+
+ p1 = ctx.p1;
+
+ if (!await checkIframeApi(p1)) {
+ return;
+ }
+
+ await p1.switchToMainFrame();
+ await p1.getIframeAPI().addEventListener('filmstripDisplayChanged');
+ });
+
+ it('toggles filmstrip off via toggleFilmStrip command', async () => {
+ await toggleAndExpect(false);
+ });
+
+ it('toggles filmstrip back on via toggleFilmStrip command', async () => {
+ await toggleAndExpect(true);
+ });
+
+ it('toggles filmstrip from inside meeting via keyboard shortcut and emits event to embedder', async () => {
+ await p1.switchToMainFrame();
+ await p1.getIframeAPI().clearEventResults('filmstripDisplayChanged');
+
+ await p1.switchToIFrame();
+ await p1.driver.$('body').click();
+ await p1.driver.keys([ 'f' ]);
+
+ await p1.switchToMainFrame();
+ const filmstripEvent: { visible: boolean; } = await p1.getIframeAPI().waitForEventResult(
+ 'filmstripDisplayChanged',
+ 'filmstripDisplayChanged event was not received when toggling filmstrip via shortcut F'
+ );
+
+ expect(filmstripEvent).toEqual({ visible: false });
+
+ await p1.switchToIFrame();
+ await p1.getFilmstrip().assertVisible(false);
+ });
+});
diff --git a/tests/specs/iframe/tileView.spec.ts b/tests/specs/iframe/tileView.spec.ts
index 5d71f6a984..f9904625bc 100644
--- a/tests/specs/iframe/tileView.spec.ts
+++ b/tests/specs/iframe/tileView.spec.ts
@@ -27,20 +27,13 @@ describe('Tile view iframe API command and events', () => {
});
it('enters tile view via setTileView command', async () => {
- if (!await checkIframeApi(p1)) {
- return;
- }
-
await p1.switchToMainFrame();
await p1.getIframeAPI().clearEventResults('tileViewChanged');
await p1.getIframeAPI().executeCommand('setTileView', true);
- const tileViewEvent: { enabled: boolean; } = await p1.driver.waitUntil(
- () => p1.getIframeAPI().getEventResult('tileViewChanged'),
- {
- timeout: 5000,
- timeoutMsg: 'tileViewChanged event was not received for setTileView(true)'
- }
+ const tileViewEvent: { enabled: boolean; } = await p1.getIframeAPI().waitForEventResult(
+ 'tileViewChanged',
+ 'tileViewChanged event was not received for setTileView(true)'
);
expect(tileViewEvent).toEqual({ enabled: true });
@@ -50,20 +43,13 @@ describe('Tile view iframe API command and events', () => {
});
it('toggles tile view off via toggleTileView command', async () => {
- if (!await checkIframeApi(p1)) {
- return;
- }
-
await p1.switchToMainFrame();
await p1.getIframeAPI().clearEventResults('tileViewChanged');
await p1.getIframeAPI().executeCommand('toggleTileView');
- const toggleOffEvent: { enabled: boolean; } = await p1.driver.waitUntil(
- () => p1.getIframeAPI().getEventResult('tileViewChanged'),
- {
- timeout: 5000,
- timeoutMsg: 'tileViewChanged event was not received for toggleTileView (off)'
- }
+ const toggleOffEvent: { enabled: boolean; } = await p1.getIframeAPI().waitForEventResult(
+ 'tileViewChanged',
+ 'tileViewChanged event was not received for toggleTileView (off)'
);
expect(toggleOffEvent).toEqual({ enabled: false });
@@ -73,20 +59,13 @@ describe('Tile view iframe API command and events', () => {
});
it('toggles tile view back on via toggleTileView command', async () => {
- if (!await checkIframeApi(p1)) {
- return;
- }
-
await p1.switchToMainFrame();
await p1.getIframeAPI().clearEventResults('tileViewChanged');
await p1.getIframeAPI().executeCommand('toggleTileView');
- const toggleOnEvent: { enabled: boolean; } = await p1.driver.waitUntil(
- () => p1.getIframeAPI().getEventResult('tileViewChanged'),
- {
- timeout: 5000,
- timeoutMsg: 'tileViewChanged event was not received for toggleTileView (on)'
- }
+ const toggleOnEvent: { enabled: boolean; } = await p1.getIframeAPI().waitForEventResult(
+ 'tileViewChanged',
+ 'tileViewChanged event was not received for toggleTileView (on)'
);
expect(toggleOnEvent).toEqual({ enabled: true });
@@ -96,20 +75,13 @@ describe('Tile view iframe API command and events', () => {
});
it('exits tile view via setTileView(false) command', async () => {
- if (!await checkIframeApi(p1)) {
- return;
- }
-
await p1.switchToMainFrame();
await p1.getIframeAPI().clearEventResults('tileViewChanged');
await p1.getIframeAPI().executeCommand('setTileView', false);
- const setOffEvent: { enabled: boolean; } = await p1.driver.waitUntil(
- () => p1.getIframeAPI().getEventResult('tileViewChanged'),
- {
- timeout: 5000,
- timeoutMsg: 'tileViewChanged event was not received for setTileView(false)'
- }
+ const setOffEvent: { enabled: boolean; } = await p1.getIframeAPI().waitForEventResult(
+ 'tileViewChanged',
+ 'tileViewChanged event was not received for setTileView(false)'
);
expect(setOffEvent).toEqual({ enabled: false });