feat(tests): Adds url normalize test.

This commit is contained in:
damencho
2025-06-20 08:12:49 -05:00
committed by Дамян Минков
parent cc6326a23f
commit b93c69c24e
6 changed files with 1525 additions and 649 deletions

2084
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -156,12 +156,12 @@
"@types/w3c-image-capture": "1.0.6",
"@types/w3c-web-hid": "1.0.3",
"@types/zxcvbn": "4.4.1",
"@wdio/allure-reporter": "9.4.3",
"@wdio/cli": "9.4.3",
"@wdio/globals": "9.4.3",
"@wdio/junit-reporter": "9.4.3",
"@wdio/local-runner": "9.4.3",
"@wdio/mocha-framework": "9.4.3",
"@wdio/allure-reporter": "9.16.0",
"@wdio/cli": "9.16.0",
"@wdio/globals": "9.16.0",
"@wdio/junit-reporter": "9.16.0",
"@wdio/local-runner": "9.16.0",
"@wdio/mocha-framework": "9.16.0",
"babel-loader": "9.1.0",
"babel-plugin-optional-require": "0.3.1",
"circular-dependency-plugin": "5.2.0",
@@ -186,7 +186,7 @@
"ts-loader": "9.4.2",
"typescript": "5.7.2",
"unorm": "1.6.0",
"webdriverio": "9.4.3",
"webdriverio": "9.16.0",
"webpack": "5.95.0",
"webpack-bundle-analyzer": "4.4.2",
"webpack-cli": "5.1.4",

View File

@@ -223,6 +223,10 @@ export class Participant {
url = `${url}&jwt="${this._jwt}"`;
}
if (options.baseUrl) {
this.driver.options.baseUrl = options.baseUrl;
}
await this.driver.setTimeout({ 'pageLoad': 30000 });
let urlToLoad = url.startsWith('/') ? url.substring(1) : url;
@@ -292,9 +296,9 @@ export class Participant {
/**
* Waits for the page to load.
*
* @returns {Promise<void>}
* @returns {Promise<boolean>}
*/
async waitForPageToLoad(): Promise<void> {
async waitForPageToLoad(): Promise<boolean> {
return this.driver.waitUntil(
() => this.execute(() => document.readyState === 'complete'),
{
@@ -364,9 +368,9 @@ export class Participant {
/**
* Waits for ICE to get connected.
*
* @returns {Promise<void>}
* @returns {Promise<boolean>}
*/
waitForIceConnected(): Promise<void> {
waitForIceConnected(): Promise<boolean> {
return this.driver.waitUntil(() =>
this.execute(() => APP?.conference?.getConnectionState() === 'connected'), {
timeout: 15_000,
@@ -377,9 +381,9 @@ export class Participant {
/**
* Waits for ICE to get connected on the p2p connection.
*
* @returns {Promise<void>}
* @returns {Promise<boolean>}
*/
waitForP2PIceConnected(): Promise<void> {
waitForP2PIceConnected(): Promise<boolean> {
return this.driver.waitUntil(() =>
this.execute(() => APP?.conference?.getP2PConnectionState() === 'connected'), {
timeout: 15_000,
@@ -392,16 +396,16 @@ export class Participant {
*
* @param {Object} options
* @param {boolean} options.checkSend - If true we will chec
* @returns {Promise<void>}
* @returns {Promise<boolean>}
*/
waitForSendReceiveData({
checkSend = true,
checkReceive = true,
timeout = 15_000,
msg
} = {} as IWaitForSendReceiveDataOptions): Promise<void> {
} = {} as IWaitForSendReceiveDataOptions): Promise<boolean> {
if (!checkSend && !checkReceive) {
return Promise.resolve();
return Promise.resolve(true);
}
const lMsg = msg ?? `expected to ${
@@ -426,9 +430,9 @@ export class Participant {
* Waits for remote streams.
*
* @param {number} number - The number of remote streams to wait for.
* @returns {Promise<void>}
* @returns {Promise<boolean>}
*/
async waitForRemoteStreams(number: number): Promise<void> {
async waitForRemoteStreams(number: number): Promise<boolean> {
return await this.driver.waitUntil(async () => await this.execute(
count => (APP?.conference?.getNumberOfParticipantsWithTracks() ?? -1) >= count,
number
@@ -443,9 +447,9 @@ export class Participant {
*
* @param {number} number - The number of participant to wait for.
* @param {string} msg - A custom message to use.
* @returns {Promise<void>}
* @returns {Promise<boolean>}
*/
waitForParticipants(number: number, msg?: string): Promise<void> {
waitForParticipants(number: number, msg?: string): Promise<boolean> {
return this.driver.waitUntil(
() => this.execute(count => (APP?.conference?.listMembers()?.length ?? -1) === count, number),
{

View File

@@ -22,6 +22,11 @@ export type IContext = {
export type IJoinOptions = {
/**
* Overwrites the base url set in the config.
*/
baseUrl?: string;
/**
* Config overwrites to use.
*/

View File

@@ -0,0 +1,39 @@
import { multiremotebrowser } from '@wdio/globals';
import { ensureTwoParticipants } from '../../helpers/participants';
describe('URL Normalisation', () => {
it('joining the meeting', async () => {
// a hack to extract the baseUrl that the test will use
const baseUrl = multiremotebrowser.getInstance('p1').options.baseUrl;
if (!baseUrl) {
throw new Error('baseUrl is not set');
}
// we want to extract the host and use a custom tenant
const host = new URL(baseUrl).origin;
// @ts-ignore
ctx.oldRoomName = ctx.roomName;
ctx.roomName = `${ctx.roomName}@example.com`;
await ensureTwoParticipants(ctx, {
baseUrl: `${host}/tenant@example.com/`
});
});
it('check', async () => {
const currentUrlStr = await ctx.p1.driver.getUrl();
const currentUrl = new URL(currentUrlStr);
const path = currentUrl.pathname;
const parts = path.split('/');
expect(parts[1]).toBe('tenantexample.com');
// @ts-ignore
expect(parts[2]).toBe(`${ctx.oldRoomName}example.com`);
});
});

View File

@@ -62,7 +62,7 @@ export const config: WebdriverIO.MultiremoteConfig = {
runner: 'local',
specs: [
'specs/**'
'specs/**/*.spec.ts'
],
maxInstances: parseInt(process.env.MAX_INSTANCES || '1', 10), // if changing check onWorkerStart logic