From e5049c1e39706a16af98bc8e07a0ce0bb8de4926 Mon Sep 17 00:00:00 2001 From: damencho Date: Fri, 7 Jun 2024 15:39:18 -0500 Subject: [PATCH] feat: Adds rename breakout room tests. --- .../jitsi/meet/test/BreakoutRoomsTest.java | 70 +++++++++++++++---- .../java/org/jitsi/meet/test/SubjectTest.java | 12 ++-- .../pageobjects/web/BreakoutRoomsList.java | 24 +++++++ 3 files changed, 90 insertions(+), 16 deletions(-) diff --git a/src/test/java/org/jitsi/meet/test/BreakoutRoomsTest.java b/src/test/java/org/jitsi/meet/test/BreakoutRoomsTest.java index 7c357082a..4fb9d3f97 100644 --- a/src/test/java/org/jitsi/meet/test/BreakoutRoomsTest.java +++ b/src/test/java/org/jitsi/meet/test/BreakoutRoomsTest.java @@ -15,23 +15,21 @@ */ package org.jitsi.meet.test; -import org.jitsi.meet.test.base.JitsiMeetUrl; -import org.jitsi.meet.test.pageobjects.web.BreakoutRoomsList; -import org.jitsi.meet.test.pageobjects.web.ParticipantsPane; -import org.jitsi.meet.test.util.TestUtils; -import org.jitsi.meet.test.web.WebParticipant; -import org.jitsi.meet.test.web.WebTestBase; -import org.openqa.selenium.By; -import org.openqa.selenium.TimeoutException; -import org.openqa.selenium.support.ui.ExpectedCondition; -import org.testng.SkipException; -import org.testng.annotations.Test; +import org.jitsi.meet.test.base.*; +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.interactions.*; +import org.openqa.selenium.support.ui.*; +import org.testng.*; +import org.testng.annotations.*; import java.util.*; import java.util.logging.*; import static org.testng.Assert.*; -import static org.jitsi.meet.test.pageobjects.web.ParticipantsPane.PARTICIPANT_ITEM; +import static org.jitsi.meet.test.pageobjects.web.ParticipantsPane.*; /** * Tests the Breakout rooms functionality. @@ -346,4 +344,52 @@ public void testCollapseRoom() TestUtils.waitForCondition(participant1.getDriver(), 5, (ExpectedCondition) d -> roomsList.getRooms().get(0).getParticipantsCount() == 1); } + @Test(dependsOnMethods = {"testCollapseRoom"}) + public void testRenameRoom() + { + BreakoutRoomsList roomsList = participant1.getBreakoutRoomsList(); + + String myNewRoomName = "breakout-" + generateRandomRoomName(); + + // let's rename breakout room and see it in local and remote + BreakoutRoomsList.BreakoutRoom room = roomsList.getRooms().get(0); + room.renameRoom(myNewRoomName); + + SubjectTest.checkSubject(participant2, myNewRoomName); + + TestUtils.waitForCondition(participant1.getDriver(), "Breakout room was not renamed for moderator", 5, + (ExpectedCondition) d -> roomsList.getRooms().get(0).getName().trim().equals(myNewRoomName)); + + ParticipantsPane pane2 = participant2.getParticipantsPane(); + pane2.open(); + BreakoutRoomsList roomsList2 = participant2.getBreakoutRoomsList(); + + // leave room + pane2.leaveBreakoutRoom(); + + // there should be one empty room + TestUtils.waitForCondition(participant1.getDriver(), 5, + (ExpectedCondition) d -> { + List rooms = roomsList.getRooms(); + return rooms.size() == 1 + && rooms.get(0).getParticipantsCount() == 0; + }); + + assertEquals(roomsList2.getRooms().get(0).getName().trim(), myNewRoomName, + "Participant2 do not see new room name"); + + // send the second participant to the first breakout room + ParticipantsPane pane = participant1.getParticipantsPane(); + pane.sendParticipantToBreakoutRoom(participant2, roomsList.getRooms().get(0).getName().trim()); + + // there should be one room with one participant + TestUtils.waitForCondition(participant1.getDriver(), 5, + (ExpectedCondition) d -> { + List rooms = roomsList.getRooms(); + return rooms.size() == 1 + && rooms.get(0).getParticipantsCount() == 1; + }); + + SubjectTest.checkSubject(participant2, myNewRoomName); + } } diff --git a/src/test/java/org/jitsi/meet/test/SubjectTest.java b/src/test/java/org/jitsi/meet/test/SubjectTest.java index ba79ad38c..5c90db28e 100644 --- a/src/test/java/org/jitsi/meet/test/SubjectTest.java +++ b/src/test/java/org/jitsi/meet/test/SubjectTest.java @@ -15,9 +15,11 @@ */ package org.jitsi.meet.test; +import org.jitsi.meet.test.util.*; import org.jitsi.meet.test.web.*; import org.openqa.selenium.*; import org.openqa.selenium.interactions.*; +import org.openqa.selenium.support.ui.*; import org.testng.*; import org.testng.annotations.*; @@ -59,8 +61,8 @@ public void changeSubjectAndCheck() if (participant1.isModerator()) { - checkSubject(participant1); - checkSubject(getParticipant2()); + checkSubject(participant1, MY_TEST_SUBJECT); + checkSubject(getParticipant2(), MY_TEST_SUBJECT); } else { @@ -69,7 +71,7 @@ public void changeSubjectAndCheck() } } - private void checkSubject(WebParticipant participant) + public static void checkSubject(WebParticipant participant, String subject) { WebDriver driver = participant.getDriver(); @@ -80,6 +82,8 @@ private void checkSubject(WebParticipant participant) String txt = driver.findElement(By.xpath(SUBJECT_XPATH)).getText(); - assertTrue(txt.startsWith(MY_TEST_SUBJECT), "Subject does not match for " + participant.getName()); + TestUtils.waitForCondition(driver, "Subject does not match for " + participant.getName(), 5, + (ExpectedCondition) d -> + d.findElement(By.xpath(SUBJECT_XPATH)).getText().startsWith(subject)); } } diff --git a/src/test/java/org/jitsi/meet/test/pageobjects/web/BreakoutRoomsList.java b/src/test/java/org/jitsi/meet/test/pageobjects/web/BreakoutRoomsList.java index be83dd411..2e08e26f8 100644 --- a/src/test/java/org/jitsi/meet/test/pageobjects/web/BreakoutRoomsList.java +++ b/src/test/java/org/jitsi/meet/test/pageobjects/web/BreakoutRoomsList.java @@ -177,6 +177,30 @@ public void removeRoom() removeButton.click(); } + public void renameRoom(String newName) + { + WebDriver driver = participant.getDriver(); + + openContextMenu(); + WebElement removeButton = TestUtils.waitForElementBy(driver, By.id("rename-room-" + id), 2); + + removeButton.click(); + + TestUtils.waitForElementBy(driver, By.xpath("//input[@name='breakoutRoomName']"), 5); + + // give time for the dialog to fully load + TestUtils.waitMillis(1000); + + WebElement passwordInput = driver.findElement(By.xpath("//input[@name='breakoutRoomName']")); + + passwordInput.clear(); + passwordInput.sendKeys(newName); + + TestUtils.waitMillis(500); + + ModalDialogHelper.clickOKButton(driver); + } + public void closeRoom() { openContextMenu();