From 66647b8ded1f4df95934a34000f7371989c14400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=8F=D0=BD=20=D0=9C=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Fri, 7 Jun 2024 11:53:08 -0500 Subject: [PATCH 1/2] feat: Adds testing for setting subject via url param. (#642) * feat: Adds testing for setting subject via url param. * squash: Missing license and comments. * squash: imports --- .../java/org/jitsi/meet/test/SubjectTest.java | 85 +++++++++++++++++++ src/test/resources/desktop/testng.xml | 5 ++ 2 files changed, 90 insertions(+) create mode 100644 src/test/java/org/jitsi/meet/test/SubjectTest.java diff --git a/src/test/java/org/jitsi/meet/test/SubjectTest.java b/src/test/java/org/jitsi/meet/test/SubjectTest.java new file mode 100644 index 000000000..ba79ad38c --- /dev/null +++ b/src/test/java/org/jitsi/meet/test/SubjectTest.java @@ -0,0 +1,85 @@ +/* + * Copyright @ 2015 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.web.*; +import org.openqa.selenium.*; +import org.openqa.selenium.interactions.*; +import org.testng.*; +import org.testng.annotations.*; + +import java.util.logging.*; + +import static org.testng.Assert.*; + +/** + * TSets subject via config url hash param and check locally and remote for it. + * + * @author Damian Minkov + */ +public class SubjectTest + extends WebTestBase +{ + private static final String MY_TEST_SUBJECT = "My Test Subject"; + + /** + * The subject xpath. + */ + private final static String SUBJECT_XPATH = "//div[starts-with(@class, 'subject-text')]"; + + @Override + public void setupClass() + { + super.setupClass(); + + ensureTwoParticipants(getJitsiMeetUrl().appendConfig("config.subject=\"" + MY_TEST_SUBJECT + "\""), null); + } + + /** + * Kick participant2 and checks at participant1 is this is visible. + * and whether participant2 sees a notification that was kicked. + */ + @Test + public void changeSubjectAndCheck() + { + WebParticipant participant1 = getParticipant1(); + + if (participant1.isModerator()) + { + checkSubject(participant1); + checkSubject(getParticipant2()); + } + else + { + Logger.getGlobal().log(Level.WARNING, "Not testing subject as torture is not moderator."); + throw new SkipException("skip as test's participant cannot be moderator"); + } + } + + private void checkSubject(WebParticipant participant) + { + WebDriver driver = participant.getDriver(); + + WebElement localTile = driver.findElement(By.xpath(SUBJECT_XPATH)); + Actions hoverOnLocalTile = new Actions(driver); + hoverOnLocalTile.moveToElement(localTile); + hoverOnLocalTile.perform(); + + String txt = driver.findElement(By.xpath(SUBJECT_XPATH)).getText(); + + assertTrue(txt.startsWith(MY_TEST_SUBJECT), "Subject does not match for " + participant.getName()); + } +} diff --git a/src/test/resources/desktop/testng.xml b/src/test/resources/desktop/testng.xml index dabcb94b9..316bc5477 100644 --- a/src/test/resources/desktop/testng.xml +++ b/src/test/resources/desktop/testng.xml @@ -218,6 +218,11 @@ + + + + + From e5049c1e39706a16af98bc8e07a0ce0bb8de4926 Mon Sep 17 00:00:00 2001 From: damencho Date: Fri, 7 Jun 2024 15:39:18 -0500 Subject: [PATCH 2/2] 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();