From 289c1907e7cf4b8fab0d105362d359c1c11d7620 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Tue, 18 Nov 2025 15:59:44 -0600 Subject: [PATCH] test: Skip iframe tests when the API is disabled. --- tests/specs/iframe/chat.spec.ts | 10 +++++----- tests/specs/iframe/kick.spec.ts | 8 +++++--- tests/specs/iframe/participantsPresence.spec.ts | 8 +++++--- tests/specs/iframe/util.ts | 15 +++++++++++++++ 4 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 tests/specs/iframe/util.ts diff --git a/tests/specs/iframe/chat.spec.ts b/tests/specs/iframe/chat.spec.ts index 05f9fab316..0affc2e1c6 100644 --- a/tests/specs/iframe/chat.spec.ts +++ b/tests/specs/iframe/chat.spec.ts @@ -3,9 +3,10 @@ import { expect } from '@wdio/globals'; import type { Participant } from '../../helpers/Participant'; import { setTestProperties } from '../../helpers/TestProperties'; import { config as testsConfig } from '../../helpers/TestsConfig'; -import { expectations } from '../../helpers/expectations'; import { joinMuc } from '../../helpers/joinMuc'; +import { checkIframeApi } from './util'; + setTestProperties(__filename, { usesBrowsers: [ 'p1', 'p2' ] }); @@ -15,12 +16,11 @@ describe('Chat', () => { it('setup', async () => { p1 = await joinMuc({ name: 'p1', iFrameApi: true, token: testsConfig.jwt.preconfiguredToken }); + if (!await checkIframeApi(p1)) { + return; + } p2 = await joinMuc({ name: 'p2', iFrameApi: true }); - const iframeEnabled = !await p1.execute(() => config.disableIframeAPI); - - expect(iframeEnabled).toBe(expectations.iframe.enabled); - await p1.switchToMainFrame(); await p2.switchToMainFrame(); }); diff --git a/tests/specs/iframe/kick.spec.ts b/tests/specs/iframe/kick.spec.ts index bef53b68c6..33cdaba61f 100644 --- a/tests/specs/iframe/kick.spec.ts +++ b/tests/specs/iframe/kick.spec.ts @@ -1,9 +1,10 @@ import { isEqual } from 'lodash-es'; import { setTestProperties } from '../../helpers/TestProperties'; -import { expectations } from '../../helpers/expectations'; import { ensureTwoParticipants } from '../../helpers/participants'; +import { checkIframeApi } from './util'; + setTestProperties(__filename, { usesBrowsers: [ 'p1', 'p2' ] }); @@ -13,9 +14,10 @@ describe('Kick participants', () => { await ensureTwoParticipants({}, { name: 'p1', iFrameApi: true }); const { p1, p2 } = ctx; - const iframeEnabled = !await p1.execute(() => config.disableIframeAPI); - expect(iframeEnabled).toBe(expectations.iframe.enabled); + if (!await checkIframeApi(p1)) { + return; + } await Promise.all([ p1.switchToMainFrame(), diff --git a/tests/specs/iframe/participantsPresence.spec.ts b/tests/specs/iframe/participantsPresence.spec.ts index 3eeeca415c..f67f3352af 100644 --- a/tests/specs/iframe/participantsPresence.spec.ts +++ b/tests/specs/iframe/participantsPresence.spec.ts @@ -1,8 +1,9 @@ import { P1, P2 } from '../../helpers/Participant'; import { setTestProperties } from '../../helpers/TestProperties'; -import { expectations } from '../../helpers/expectations'; import { ensureTwoParticipants, parseJid } from '../../helpers/participants'; +import { checkIframeApi } from './util'; + setTestProperties(__filename, { usesBrowsers: [ 'p1', 'p2' ] }); @@ -12,9 +13,10 @@ describe('Participants presence', () => { await ensureTwoParticipants({}, { name: 'p1', iFrameApi: true }); const { p1, p2 } = ctx; - const iframeEnabled = !await p1.execute(() => config.disableIframeAPI); - expect(iframeEnabled).toBe(expectations.iframe.enabled); + if (!await checkIframeApi(p1)) { + return; + } await Promise.all([ p1.switchToMainFrame(), diff --git a/tests/specs/iframe/util.ts b/tests/specs/iframe/util.ts new file mode 100644 index 0000000000..5eac5ca72a --- /dev/null +++ b/tests/specs/iframe/util.ts @@ -0,0 +1,15 @@ +import { expect } from '@wdio/globals'; + +import type { Participant } from '../../helpers/Participant'; +import { expectations } from '../../helpers/expectations'; + +export async function checkIframeApi(p: Participant) { + const iframeEnabled = !await p.execute(() => config.disableIframeAPI); + + expect(iframeEnabled).toBe(expectations.iframe.enabled); + if (!iframeEnabled) { + ctx.skipSuiteTests = 'The iFrame API is disabled'; + } + + return iframeEnabled; +}