test: Skip iframe tests when the API is disabled.

This commit is contained in:
Boris Grozev
2025-11-18 15:59:44 -06:00
committed by Дамян Минков
parent 35adea48ae
commit 289c1907e7
4 changed files with 30 additions and 11 deletions

View File

@@ -3,9 +3,10 @@ import { expect } from '@wdio/globals';
import type { Participant } from '../../helpers/Participant'; import type { Participant } from '../../helpers/Participant';
import { setTestProperties } from '../../helpers/TestProperties'; import { setTestProperties } from '../../helpers/TestProperties';
import { config as testsConfig } from '../../helpers/TestsConfig'; import { config as testsConfig } from '../../helpers/TestsConfig';
import { expectations } from '../../helpers/expectations';
import { joinMuc } from '../../helpers/joinMuc'; import { joinMuc } from '../../helpers/joinMuc';
import { checkIframeApi } from './util';
setTestProperties(__filename, { setTestProperties(__filename, {
usesBrowsers: [ 'p1', 'p2' ] usesBrowsers: [ 'p1', 'p2' ]
}); });
@@ -15,12 +16,11 @@ describe('Chat', () => {
it('setup', async () => { it('setup', async () => {
p1 = await joinMuc({ name: 'p1', iFrameApi: true, token: testsConfig.jwt.preconfiguredToken }); p1 = await joinMuc({ name: 'p1', iFrameApi: true, token: testsConfig.jwt.preconfiguredToken });
if (!await checkIframeApi(p1)) {
return;
}
p2 = await joinMuc({ name: 'p2', iFrameApi: true }); p2 = await joinMuc({ name: 'p2', iFrameApi: true });
const iframeEnabled = !await p1.execute(() => config.disableIframeAPI);
expect(iframeEnabled).toBe(expectations.iframe.enabled);
await p1.switchToMainFrame(); await p1.switchToMainFrame();
await p2.switchToMainFrame(); await p2.switchToMainFrame();
}); });

View File

@@ -1,9 +1,10 @@
import { isEqual } from 'lodash-es'; import { isEqual } from 'lodash-es';
import { setTestProperties } from '../../helpers/TestProperties'; import { setTestProperties } from '../../helpers/TestProperties';
import { expectations } from '../../helpers/expectations';
import { ensureTwoParticipants } from '../../helpers/participants'; import { ensureTwoParticipants } from '../../helpers/participants';
import { checkIframeApi } from './util';
setTestProperties(__filename, { setTestProperties(__filename, {
usesBrowsers: [ 'p1', 'p2' ] usesBrowsers: [ 'p1', 'p2' ]
}); });
@@ -13,9 +14,10 @@ describe('Kick participants', () => {
await ensureTwoParticipants({}, { name: 'p1', iFrameApi: true }); await ensureTwoParticipants({}, { name: 'p1', iFrameApi: true });
const { p1, p2 } = ctx; 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([ await Promise.all([
p1.switchToMainFrame(), p1.switchToMainFrame(),

View File

@@ -1,8 +1,9 @@
import { P1, P2 } from '../../helpers/Participant'; import { P1, P2 } from '../../helpers/Participant';
import { setTestProperties } from '../../helpers/TestProperties'; import { setTestProperties } from '../../helpers/TestProperties';
import { expectations } from '../../helpers/expectations';
import { ensureTwoParticipants, parseJid } from '../../helpers/participants'; import { ensureTwoParticipants, parseJid } from '../../helpers/participants';
import { checkIframeApi } from './util';
setTestProperties(__filename, { setTestProperties(__filename, {
usesBrowsers: [ 'p1', 'p2' ] usesBrowsers: [ 'p1', 'p2' ]
}); });
@@ -12,9 +13,10 @@ describe('Participants presence', () => {
await ensureTwoParticipants({}, { name: 'p1', iFrameApi: true }); await ensureTwoParticipants({}, { name: 'p1', iFrameApi: true });
const { p1, p2 } = ctx; 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([ await Promise.all([
p1.switchToMainFrame(), p1.switchToMainFrame(),

View File

@@ -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;
}