fix(tests): Send logs to browser to keep correct order.

This commit is contained in:
damencho
2025-10-22 06:48:57 -05:00
committed by Дамян Минков
parent e82ef6de4b
commit fa9703a41e
6 changed files with 37 additions and 40 deletions

View File

@@ -191,8 +191,8 @@ export class Participant {
* @param {string} message - The message to log.
* @returns {void}
*/
log(message: string): void {
logInfo(this.driver, message);
async log(message: string): Promise<void> {
await logInfo(this.driver, message);
}
/**

View File

@@ -70,17 +70,14 @@ export function saveLogs(driver: WebdriverIO.Browser, value: string) {
* @param {string} message - The message to add.
* @returns {void}
*/
export function logInfo(driver: WebdriverIO.Browser, message: string) {
export async function logInfo(driver: WebdriverIO.Browser, message: string) {
// @ts-ignore
if (!driver.logFile) {
return;
}
try {
// @ts-ignore
fs.appendFileSync(driver.logFile, `${new Date().toISOString()} ${LOG_PREFIX} ${message}\n`);
} catch (err) {
console.error(err);
}
return driver.execute((prefix, msg) =>
console.log(`${new Date().toISOString()} ${prefix} ${msg}\n`),
LOG_PREFIX, message);
}

View File

@@ -51,7 +51,7 @@ export default class InviteDialog extends BaseDialog {
const fullText = await elem.getText();
this.participant.log(`Extracted text in invite dialog: ${fullText}`);
await this.participant.log(`Extracted text in invite dialog: ${fullText}`);
return fullText.split(':')[1].trim();
}

View File

@@ -55,8 +55,8 @@ export default class Toolbar extends BasePageObject {
*
* @returns {Promise<void>}
*/
clickAudioMuteButton(): Promise<void> {
this.participant.log('Clicking on: Audio Mute Button');
async clickAudioMuteButton(): Promise<void> {
await this.participant.log('Clicking on: Audio Mute Button');
return this.audioMuteBtn.click();
}
@@ -66,8 +66,8 @@ export default class Toolbar extends BasePageObject {
*
* @returns {Promise<void>}
*/
clickAudioUnmuteButton(): Promise<void> {
this.participant.log('Clicking on: Audio Unmute Button');
async clickAudioUnmuteButton(): Promise<void> {
await this.participant.log('Clicking on: Audio Unmute Button');
return this.audioUnMuteBtn.click();
}
@@ -91,8 +91,8 @@ export default class Toolbar extends BasePageObject {
*
* @returns {Promise<void>}
*/
clickVideoMuteButton(): Promise<void> {
this.participant.log('Clicking on: Video Mute Button');
async clickVideoMuteButton(): Promise<void> {
await this.participant.log('Clicking on: Video Mute Button');
return this.videoMuteBtn.click();
}
@@ -102,8 +102,8 @@ export default class Toolbar extends BasePageObject {
*
* @returns {Promise<void>}
*/
clickVideoUnmuteButton(): Promise<void> {
this.participant.log('Clicking on: Video Unmute Button');
async clickVideoUnmuteButton(): Promise<void> {
await this.participant.log('Clicking on: Video Unmute Button');
return this.videoUnMuteBtn.click();
}
@@ -113,8 +113,8 @@ export default class Toolbar extends BasePageObject {
*
* @returns {Promise<void>}
*/
clickCloseParticipantsPaneButton(): Promise<void> {
this.participant.log('Clicking on: Close Participants pane Button');
async clickCloseParticipantsPaneButton(): Promise<void> {
await this.participant.log('Clicking on: Close Participants pane Button');
return this.getButton(CLOSE_PARTICIPANTS_PANE).click();
}
@@ -124,8 +124,8 @@ export default class Toolbar extends BasePageObject {
*
* @returns {Promise<void>}
*/
clickParticipantsPaneButton(): Promise<void> {
this.participant.log('Clicking on: Participants pane Button');
async clickParticipantsPaneButton(): Promise<void> {
await this.participant.log('Clicking on: Participants pane Button');
// Special case for participants pane button, as it contains the number of participants and its label
// is changing
@@ -150,8 +150,8 @@ export default class Toolbar extends BasePageObject {
/**
* Clicks on the raise hand button that enables participants will to speak.
*/
clickRaiseHandButton(): Promise<void> {
this.participant.log('Clicking on: Raise hand Button');
async clickRaiseHandButton(): Promise<void> {
await this.participant.log('Clicking on: Raise hand Button');
return this.getButton(RAISE_HAND).click();
}
@@ -159,8 +159,8 @@ export default class Toolbar extends BasePageObject {
/**
* Clicks on the chat button that opens chat panel.
*/
clickChatButton(): Promise<void> {
this.participant.log('Clicking on: Chat Button');
async clickChatButton(): Promise<void> {
await this.participant.log('Clicking on: Chat Button');
return this.getButton(CHAT).click();
}
@@ -168,8 +168,8 @@ export default class Toolbar extends BasePageObject {
/**
* Clicks on the chat button that closes chat panel.
*/
clickCloseChatButton(): Promise<void> {
this.participant.log('Clicking on: Close Chat Button');
async clickCloseChatButton(): Promise<void> {
await this.participant.log('Clicking on: Close Chat Button');
return this.getButton(CLOSE_CHAT).click();
}
@@ -205,8 +205,8 @@ export default class Toolbar extends BasePageObject {
/**
* Clicks on the hangup button that ends the conference.
*/
clickHangupButton(): Promise<void> {
this.participant.log('Clicking on: Hangup Button');
async clickHangupButton(): Promise<void> {
await this.participant.log('Clicking on: Hangup Button');
return this.getButton(HANGUP).click();
}
@@ -237,7 +237,7 @@ export default class Toolbar extends BasePageObject {
// so let's move focus away before clicking the button
await this.participant.driver.$('#overflow-context-menu').moveTo();
this.participant.log(`Clicking on: ${accessibilityLabel}`);
await this.participant.log(`Clicking on: ${accessibilityLabel}`);
await this.getButton(accessibilityLabel).click();
await this.closeOverflowMenu();

View File

@@ -272,19 +272,19 @@ describe('Active speaker', () => {
*/
async function testActiveSpeaker(
activeSpeaker: Participant, otherParticipant1: Participant, otherParticipant2: Participant) {
activeSpeaker.log(`Start testActiveSpeaker for participant: ${activeSpeaker.name}`);
await activeSpeaker.log(`Start testActiveSpeaker for participant: ${activeSpeaker.name}`);
const speakerEndpoint = await activeSpeaker.getEndpointId();
// just a debug print to go in logs
activeSpeaker.log('Unmuting in testActiveSpeaker');
await activeSpeaker.log('Unmuting in testActiveSpeaker');
// Unmute
await activeSpeaker.getToolbar().clickAudioUnmuteButton();
// just a debug print to go in logs
otherParticipant1.log(`Participant unmuted in testActiveSpeaker ${speakerEndpoint}`);
otherParticipant2.log(`Participant unmuted in testActiveSpeaker ${speakerEndpoint}`);
await otherParticipant1.log(`Participant unmuted in testActiveSpeaker ${speakerEndpoint}`);
await otherParticipant2.log(`Participant unmuted in testActiveSpeaker ${speakerEndpoint}`);
await activeSpeaker.getFilmstrip().assertAudioMuteIconIsDisplayed(activeSpeaker, true);
@@ -297,14 +297,14 @@ async function testActiveSpeaker(
30_000); // 30 seconds
// just a debug print to go in logs
activeSpeaker.log('Muting in testActiveSpeaker');
await activeSpeaker.log('Muting in testActiveSpeaker');
// Mute back again
await activeSpeaker.getToolbar().clickAudioMuteButton();
// just a debug print to go in logs
otherParticipant1.log(`Participant muted in testActiveSpeaker ${speakerEndpoint}`);
otherParticipant2.log(`Participant muted in testActiveSpeaker ${speakerEndpoint}`);
await otherParticipant1.log(`Participant muted in testActiveSpeaker ${speakerEndpoint}`);
await otherParticipant2.log(`Participant muted in testActiveSpeaker ${speakerEndpoint}`);
await otherParticipant1.getFilmstrip().assertAudioMuteIconIsDisplayed(activeSpeaker);
}

View File

@@ -127,7 +127,7 @@ describe('Start muted', () => {
const p2ID = await p2.getEndpointId();
p1.log(`Start configOptionsTest, second participant: ${p2ID}`);
await p1.log(`Start configOptionsTest, second participant: ${p2ID}`);
// Participant 3 should be muted, 1 and 2 unmuted.
await p3.getFilmstrip().assertAudioMuteIconIsDisplayed(p3);
@@ -148,7 +148,7 @@ describe('Start muted', () => {
await p1.getToolbar().clickAudioMuteButton();
await p2.getToolbar().clickAudioMuteButton();
await p3.getToolbar().clickAudioUnmuteButton();
p1.log('configOptionsTest, unmuted third participant');
await p1.log('configOptionsTest, unmuted third participant');
await p1.waitForAudioMuted(p3, false /* unmuted */);
});