Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
ref: Refactor tests (#16315)
bgrozev048b089acd76
diff --git a/tests/helpers/Participant.ts b/tests/helpers/Participant.tsindex a9c04382eb..acfb23241d 100644--- a/tests/helpers/Participant.ts+++ b/tests/helpers/Participant.ts@@ -25,7 +25,7 @@ import Visitors from '../pageobjects/Visitors';import { LOG_PREFIX, logInfo } from './browserLogger';import { IToken } from './token';-import { IContext, IJoinOptions } from './types';+import { IParticipantJoinOptions, IParticipantOptions } from './types';export const P1 = 'p1';export const P2 = 'p2';@@ -60,6 +60,8 @@ export class Participant {*/private _dialInPin?: string;+ private _iFrameApi: boolean = false;+/*** The default config to use when joining.*@@ -116,14 +118,12 @@ export class Participant {} as IConfig;/**- * Creates a participant with given name.- *- * @param {string} name - The name of the participant.- * @param {string} token - The token if any.+ * Creates a participant with given options.*/- constructor(name: string, token?: IToken) {- this._name = name;- this._token = token;+ constructor(options: IParticipantOptions) {+ this._name = options.name;+ this._token = options.token;+ this._iFrameApi = options.iFrameApi || false;}/**@@ -186,13 +186,12 @@ export class Participant {/*** Joins conference.*- * @param {IContext} ctx - The context.* @param {IJoinOptions} options - Options for joining.* @returns {Promise<void>}*/- async joinConference(ctx: IContext, options: IJoinOptions = {}): Promise<void> {+ async joinConference(options: IParticipantJoinOptions): Promise<void> {const config = {- room: ctx.roomName,+ room: options.roomName,configOverwrite: {...this.config,...options.configOverwrite || {}@@ -209,17 +208,17 @@ export class Participant {};}- if (ctx.testProperties.useIFrameApi) {+ if (this._iFrameApi) {config.room = 'iframeAPITest.html';}let url = urlObjectToString(config) || '';- if (ctx.testProperties.useIFrameApi) {+ if (this._iFrameApi) {const baseUrl = new URL(this.driver.options.baseUrl || '');// @ts-ignore- url = `${this.driver.iframePageBase}${url}&domain="${baseUrl.host}"&room="${ctx.roomName}"`;+ url = `${this.driver.iframePageBase}${url}&domain="${baseUrl.host}"&room="${options.roomName}"`;if (process.env.IFRAME_TENANT) {url = `${url}&tenant="${process.env.IFRAME_TENANT}"`;@@ -238,20 +237,18 @@ export class Participant {await this.driver.setTimeout({ 'pageLoad': 30000 });- let urlToLoad = url.startsWith('/') ? url.substring(1) : url;+ // drop the leading '/' so we can use the tenant if any+ url = url.startsWith('/') ? url.substring(1) : url;- if (options.preferGenerateToken && !ctx.testProperties.useIFrameApi- && process.env.JWT_KID?.startsWith('vpaas-magic-cookie-') && process.env.IFRAME_TENANT) {- // This to enables tests like invite, which can force using the jaas auth instead of the provided token- urlToLoad = `/${process.env.IFRAME_TENANT}/${urlToLoad}`;+ if (options.forceTenant) {+ url = `/${options.forceTenant}/${url}`;}- // drop the leading '/' so we can use the tenant if any- await this.driver.url(urlToLoad);+ await this.driver.url(url);await this.waitForPageToLoad();- if (ctx.testProperties.useIFrameApi) {+ if (this._iFrameApi) {const mainFrame = this.driver.$('iframe');await this.driver.switchFrame(mainFrame);diff --git a/tests/helpers/participants.ts b/tests/helpers/participants.tsindex 5b8136a47f..4e096766ce 100644--- a/tests/helpers/participants.ts+++ b/tests/helpers/participants.ts@@ -214,15 +214,22 @@ async function _joinParticipant( // eslint-disable-line max-params}}- const newParticipant = new Participant(name, token);+ const newParticipant = new Participant({ name, token, iFrameApi: ctx.testProperties.useIFrameApi });// set the new participant instance// @ts-ignorectx[name] = newParticipant;- await newParticipant.joinConference(ctx, {- displayName: name,- ...options+ let forceTenant;++ if (options?.preferGenerateToken && !ctx.testProperties.useIFrameApi+ && process.env.JWT_KID?.startsWith('vpaas-magic-cookie-') && process.env.IFRAME_TENANT) {+ forceTenant = process.env.IFRAME_TENANT;+ }+ await newParticipant.joinConference({+ ...options,+ forceTenant,+ roomName: ctx.roomName,});}diff --git a/tests/helpers/types.ts b/tests/helpers/types.tsindex 009af2e335..71fd80a95c 100644--- a/tests/helpers/types.ts+++ b/tests/helpers/types.ts@@ -3,7 +3,7 @@ import { IConfig } from '../../react/features/base/config/configType';import type { Participant } from './Participant';import { ITestProperties } from './TestProperties';import type WebhookProxy from './WebhookProxy';-import { ITokenOptions } from './token';+import { IToken, ITokenOptions } from './token';export type IContext = {/**@@ -24,8 +24,19 @@ export type IContext = {webhooksProxy: WebhookProxy;};-export type IJoinOptions = {+export type IParticipantOptions = {+ /** Whether it should use the iFrame API. */+ iFrameApi?: boolean;+ /** Must be 'p1', 'p2', 'p3', or 'p4'. */+ name: string;+ /** An optional token to use. */+ token?: IToken;+};+/**+ * Options for joinConference.+ */+export type IParticipantJoinOptions = {/*** Overwrites the base url set in the config.*/@@ -37,9 +48,36 @@ export type IJoinOptions = {configOverwrite?: IConfig;/**- * The display name to use.+ * An optional tenant to use. If provided the URL is prepended with /$forceTenant+ */+ forceTenant?: string;++ /** The name of the room to join */+ roomName: string;++ /**+ * Whether to skip setting display name.+ */+ skipDisplayName?: boolean;++ /**+ * Whether to skip waiting for the participant to join the room. Cases like lobby where we do not succeed to join+ * based on the logic of the test.+ */+ skipWaitToJoin?: boolean;+};++export type IJoinOptions = {++ /**+ * Overwrites the base url set in the config.*/- displayName?: string;+ baseUrl?: string;++ /**+ * Config overwrites to use.+ */+ configOverwrite?: IConfig;/*** When joining the first participant and jwt singing material is available and a provided tokendiff --git a/tests/specs/helpers/jaas.ts b/tests/specs/helpers/jaas.tsindex c0e9361681..05140dea18 100644--- a/tests/specs/helpers/jaas.ts+++ b/tests/specs/helpers/jaas.ts@@ -24,7 +24,7 @@ export async function loadPage(roomName: string, instanceId: 'p1' | 'p2' | 'p3'}url += '#config.prejoinConfig.enabled=false&config.requireDisplayName=false';- const newParticipant = new Participant(instanceId, token);+ const newParticipant = new Participant({ name: instanceId, token });try {await newParticipant.driver.setTimeout({ 'pageLoad': 30000 });diff --git a/tests/specs/2way/iFrameApiChat.spec.ts b/tests/specs/iframe/chat.spec.tssimilarity index 99%rename from tests/specs/2way/iFrameApiChat.spec.tsrename to tests/specs/iframe/chat.spec.tsindex c2aa41d889..62a9ddd6bb 100644--- a/tests/specs/2way/iFrameApiChat.spec.ts+++ b/tests/specs/iframe/chat.spec.ts@@ -7,7 +7,8 @@ import { fetchJson } from '../../helpers/utils';setTestProperties(__filename, {useIFrameApi: true,- useWebhookProxy: true+ useWebhookProxy: true,+ usesBrowsers: [ 'p1', 'p2' ]});describe('Chat', () => {diff --git a/tests/specs/alone/iFrameApiInvite.spec.ts b/tests/specs/iframe/invite.spec.tssimilarity index 100%rename from tests/specs/alone/iFrameApiInvite.spec.tsrename to tests/specs/iframe/invite.spec.tsdiff --git a/tests/specs/2way/iFrameApiParticipantsPresence.spec.ts b/tests/specs/iframe/participantsPresence.spec.tssimilarity index 99%rename from tests/specs/2way/iFrameApiParticipantsPresence.spec.tsrename to tests/specs/iframe/participantsPresence.spec.tsindex 134be75031..9d64599d00 100644--- a/tests/specs/2way/iFrameApiParticipantsPresence.spec.ts+++ b/tests/specs/iframe/participantsPresence.spec.ts@@ -7,7 +7,8 @@ import { IContext } from '../../helpers/types';setTestProperties(__filename, {useIFrameApi: true,- useWebhookProxy: true+ useWebhookProxy: true,+ usesBrowsers: [ 'p1', 'p2' ]});/**diff --git a/tests/specs/alone/iFrameApiRecording.spec.ts b/tests/specs/iframe/recording.spec.tssimilarity index 100%rename from tests/specs/alone/iFrameApiRecording.spec.tsrename to tests/specs/iframe/recording.spec.tsdiff --git a/tests/specs/2way/iFrameApiTranscriptions.spec.ts b/tests/specs/iframe/transcriptions.spec.tssimilarity index 99%rename from tests/specs/2way/iFrameApiTranscriptions.spec.tsrename to tests/specs/iframe/transcriptions.spec.tsindex e7a1d39822..33a5806bbe 100644--- a/tests/specs/2way/iFrameApiTranscriptions.spec.ts+++ b/tests/specs/iframe/transcriptions.spec.ts@@ -7,7 +7,8 @@ import { ensureOneParticipant, ensureTwoParticipants } from '../../helpers/partisetTestProperties(__filename, {useIFrameApi: true,- useWebhookProxy: true+ useWebhookProxy: true,+ usesBrowsers: [ 'p1', 'p2' ]});describe('Transcriptions', () => {diff --git a/tests/specs/2way/iFrameApiVisitors.spec.ts b/tests/specs/iframe/visitors.spec.tssimilarity index 98%rename from tests/specs/2way/iFrameApiVisitors.spec.tsrename to tests/specs/iframe/visitors.spec.tsindex 69281bfdba..dcc75d0cf2 100644--- a/tests/specs/2way/iFrameApiVisitors.spec.ts+++ b/tests/specs/iframe/visitors.spec.ts@@ -3,7 +3,8 @@ import { ensureOneParticipant, ensureTwoParticipants } from '../../helpers/partisetTestProperties(__filename, {useIFrameApi: true,- useWebhookProxy: true+ useWebhookProxy: true,+ usesBrowsers: [ 'p1', 'p2' ]});describe('Visitors', () => {diff --git a/tests/specs/2way/iFrameApiVisitorsLive.spec.ts b/tests/specs/iframe/visitorsLive.spec.tssimilarity index 97%rename from tests/specs/2way/iFrameApiVisitorsLive.spec.tsrename to tests/specs/iframe/visitorsLive.spec.tsindex 392ea9f827..72f78445a2 100644--- a/tests/specs/2way/iFrameApiVisitorsLive.spec.ts+++ b/tests/specs/iframe/visitorsLive.spec.ts@@ -5,7 +5,8 @@ import { ensureOneParticipant, ensureTwoParticipants } from '../../helpers/partisetTestProperties(__filename, {useIFrameApi: true,- useWebhookProxy: true+ useWebhookProxy: true,+ usesBrowsers: [ 'p1', 'p2' ]});describe('Visitors', () => {diff --git a/tests/wdio.firefox.conf.ts b/tests/wdio.firefox.conf.tsindex eb74c41f6f..e421c3d1fb 100644--- a/tests/wdio.firefox.conf.ts+++ b/tests/wdio.firefox.conf.ts@@ -21,7 +21,7 @@ if (process.env.HEADLESS === 'true') {const mergedConfig = merge(defaultConfig, {exclude: [- 'specs/**/iFrameApi*.spec.ts', // FF does not support uploading files (uploadFile)+ 'specs/iframe/*.spec.ts', // FF does not support uploading files (uploadFile)// FF does not support setting a file as mic input, no dominant speaker events'specs/3way/activeSpeaker.spec.ts',