Skip to content

Commit

Permalink
test(AudioVideoModerationTest) (jitsi#398)
Browse files Browse the repository at this point in the history
* feat(av-moderation) created av-moderation test

* feat(av-moderation) created toggleAudioAndCheck

* feat(av-moderation) fixed linelength

* feat(av-moderation) fixed test

* feat(av-moderation) updated test with changeModeratorOnParticipantReload and checkModerationEnableDisable cases

* feat(av-moderation) fixed checkstyle violation

* feat(av-moderation) updated if else

* feat(av-moderation) fixed rightcurly

* feat(av-moderation) separated test cases

* feat(av-moderation) removed unused private method

* feat(av-moderation) finished third test case

* feat(av-moderation) changed has to get notifications

* feat(av-moderation) updated methods to use participant id

* feat(av-moderation) removed test utils

* feat(av-moderation) fixed ask to unmute for change moderator

* feat(av-moderation) removed testutils

* squash: Workarounds a stale exception for notifications.

When a lot of notifications are received a stale exception sometimes occur because of re-rendering them.

* squash: Fixes few timeouts and random failures.

* squash: Fixes star imports.

Co-authored-by: Дамян Минков <damencho@jitsi.org>
  • Loading branch information
Calinteodor and damencho authored Aug 15, 2021
1 parent 527babf commit 1436219
Show file tree
Hide file tree
Showing 13 changed files with 642 additions and 20 deletions.
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

238 changes: 238 additions & 0 deletions src/test/java/org/jitsi/meet/test/AudioVideoModerationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
/*
* Copyright @ 2017 Atlassian Pty Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.meet.test;


import org.jitsi.meet.test.pageobjects.web.*;
import org.jitsi.meet.test.util.*;
import org.jitsi.meet.test.web.*;
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.*;
import org.testng.annotations.*;

import static org.testng.Assert.*;

/**
* Tests the A-V moderation functionality.
*
* @author Calin Chitu
*/
public class AudioVideoModerationTest extends WebTestBase
{
/**
* The participant.
*/
private WebParticipant participant1;
private WebParticipant participant2;
private WebParticipant participant3;

@Override
public void setupClass()
{
super.setupClass();

ensureThreeParticipants();
participant1 = getParticipant1();
participant2 = getParticipant2();
participant3 = getParticipant3();

assertTrue(participant1.isModerator(), "Participant 1 must be moderator");
assertFalse(participant2.isModerator(), "Participant 2 must not be moderator");
assertFalse(participant3.isModerator(), "Participant 3 must not be moderator");
}

/**
* Checks moderation by enabling and disabling it
*/
@Test
public void testCheckModerationEnableDisable()
{
ParticipantsPane participantsPane = participant1.getParticipantsPane();
AVModerationMenu avModerationMenu = participant1.getAVModerationMenu();

participantsPane.open();

participantsPane.clickContextMenuButton();

avModerationMenu.clickStartModeration();

participant2.getNotifications().getModerationStartNotification();

participantsPane.clickContextMenuButton();

avModerationMenu.clickStopModeration();

participant2.getNotifications().getModerationStopNotification();

checkAudioVideoParticipantUnmute(participant3);
}

/**
* Opens the context menu from the participants pane
* and enables moderation
*/
@Test(dependsOnMethods = { "testCheckModerationEnableDisable" })
public void testUnmuteByModeratorDialog()
{
ParticipantsPane participantsPane = participant1.getParticipantsPane();
AVModerationMenu avModerationMenu = participant1.getAVModerationMenu();
WebDriver driver1 = participant1.getDriver();

participantsPane.clickContextMenuButton();

avModerationMenu.clickStartModeration();

participant3.getNotifications().getModerationStartNotification();

// wait for the moderation start notification to disappear
TestUtils.waitForCondition(participant3.getDriver(), 8,
(ExpectedCondition<Boolean>) d -> !participant3.getNotifications().hasModerationStartNotification());

raiseHandToSpeak(participant3);

askParticipantToUnmute(participant3);

checkAudioVideoParticipantUnmute(participant3);

participantsPane.close();

raiseHandToSpeak(participant2);

UnmuteModalDialogHelper.clickUnmuteButton(driver1);

participant2.getNotifications().getAskToUnmuteNotification();

checkAudioVideoParticipantUnmute(participant2);

participantsPane.open();

participantsPane.clickContextMenuButton();

avModerationMenu.clickStopModeration();

participant2.getNotifications().getModerationStopNotification();

participantsPane.close();
}


/**
* Initial moderator reloads and next participant becomes the new moderator
*/
@Test(dependsOnMethods = { "testUnmuteByModeratorDialog" })
public void testHangUpAndChangeModerator()
{
participant2.hangUp();
participant3.hangUp();

ensureThreeParticipants();

participant2.muteAudio(true);
participant3.muteAudio(true);

participant1.getParticipantsPane().open();

participant1.getParticipantsPane().clickContextMenuButton();

participant1.getAVModerationMenu().clickStartModeration();

participant2.getToolbar().clickRaiseHandButton();

participant3.getToolbar().clickRaiseHandButton();

participant1.hangUp();

joinFirstParticipant();

if (participant2.isModerator())
{
participant2.getParticipantsPane().open();

participant2.getParticipantsPane().askToUnmute(participant3);

participant3.getNotifications().getAskToUnmuteNotification();

checkAudioVideoParticipantUnmute(participant3);

participant2.getParticipantsPane().clickContextMenuButton();

participant2.getAVModerationMenu().clickStopModeration();

participant3.getNotifications().getModerationStopNotification();

participant2.getParticipantsPane().close();
}

if (participant3.isModerator())
{
participant3.getParticipantsPane().open();

participant3.getParticipantsPane().askToUnmute(participant2);

participant2.getNotifications().getAskToUnmuteNotification();

checkAudioVideoParticipantUnmute(participant2);

participant3.getParticipantsPane().clickContextMenuButton();

participant3.getAVModerationMenu().clickStopModeration();

participant2.getNotifications().getModerationStopNotification();

participant3.getParticipantsPane().close();
}
}

/**
* Participant raises hand to speak during moderation
* @param participant the participant that wants to speak
*/
private void raiseHandToSpeak(WebParticipant participant)
{
participant.getToolbar().clickAudioMuteButton();

participant.getNotifications().getAudioModerationNotification();


participant.getToolbar().clickRaiseHandButton();

participant1.getNotifications().getRaisedHandNotification();
}

/**
* Moderator asks participant to unmute
* @param participant the participant who is requested to unmute
*/
private void askParticipantToUnmute(WebParticipant participant)
{
ParticipantsPane participantsPane = participant1.getParticipantsPane();

participantsPane.askToUnmute(participant);

participant.getNotifications().getAskToUnmuteNotification();
}

/**
* Checks audio/video unmute state for participant
* @param participant the participant that is checked
*/
private void checkAudioVideoParticipantUnmute(WebParticipant participant)
{
MeetUIUtils.toggleAudioAndCheck(participant, participant1, false, false);

MeetUIUtils.unmuteVideoAndCheck(participant, participant1);
}
}
2 changes: 1 addition & 1 deletion src/test/java/org/jitsi/meet/test/ModeratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void setupClass()

/**
* Grants moderator to participant2 and checks from participant2's
* perspective if this is viible.
* perspective if this is visible.
*/
@Test
public void grantModeratorToParticipant2AndValidate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void testTwoModeratorsFromSameTenant()
url.copy().setRoomParameters("jwt=" + moderator2Token),
url);

// FIXME: Showing remote video menu in tileview does not work
// FIXME: Showing remote video menu in tile view does not work
getParticipant1().getToolbar().clickTileViewButton();
getParticipant2().getToolbar().clickTileViewButton();
getParticipant3().getToolbar().clickTileViewButton();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.jitsi.meet.test.pageobjects.web;

import org.jitsi.meet.test.web.WebParticipant;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.Objects;

/**
* Represents the av moderation context menu in a particular {@link WebParticipant}.
*
* @author Calin Chitu
*/
public class AVModerationMenu
{
/**
* ID of the moderation context menu items
*/

private final static String START_MODERATION = "participants-pane-context-menu-start-moderation";

private final static String STOP_MODERATION = "participants-pane-context-menu-stop-moderation";

/**
* The participant.
*/
private final WebParticipant participant;

/**
* Initializes a new {@link AVModerationMenu} instance.
*
* @param participant the participant for this {@link AVModerationMenu}.
*/
public AVModerationMenu(WebParticipant participant)
{
this.participant = Objects.requireNonNull(participant, "participant");
}

/**
* Trys to click on the start moderation menu item and fails if it cannot be clicked.
*/
public void clickStartModeration()
{
WebDriver driver = participant.getDriver();
WebElement startModerationMenuItem
= driver.findElement(By.id(START_MODERATION));

startModerationMenuItem.click();
}

/**
* Trys to click on the stop moderation menu item and fails if it cannot be clicked.
*/
public void clickStopModeration()
{
WebDriver driver = participant.getDriver();
WebElement startModerationMenuItem
= driver.findElement(By.id(STOP_MODERATION));

startModerationMenuItem.click();
}
}
Loading

0 comments on commit 1436219

Please sign in to comment.