Skip to content

Commit

Permalink
Removing Flakiness from entercourseandnavigatetab RESTTest Class and …
Browse files Browse the repository at this point in the history
…SessionTest related #88 (#96)

* Trying to remove test flakiness from entercourseandnavigatetab method

* Similar problem in Session test, making another implicit wait

* Removed unused imports from the FullTeachingEndToEndRESTTests.java
  • Loading branch information
augustocristian authored Mar 27, 2024
1 parent 31b3dfc commit 2df36e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import java.time.format.DateTimeFormatter;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertNotNull;

/**
* E2E tests for FullTeaching REST CRUD operations.
*
Expand Down Expand Up @@ -117,6 +119,7 @@ void courseInfoRestOperations() throws ElementNotFoundException { //12+16+65 set
log.info("Course information successfully updated");
CourseNavigationUtilities.deleteCourse(user.getDriver(), COURSE_NAME);
}

@Resource(resID = "LoginService", replaceable = {})
@AccessMode(resID = "LoginService", concurrency = 10, sharing = true, accessMode = "READONLY")
@Resource(resID = "OpenVidu", replaceable = {"OpenViduMock"})
Expand All @@ -135,6 +138,7 @@ void sessionRestOperations() throws ElementNotFoundException {

CourseNavigationUtilities.deleteCourse(user.getDriver(), COURSE_NAME);
}

private void addNewSession() {
enterCourseAndNavigateTab(COURSE_NAME, "sessions-tab-icon");
log.info("Adding new session");
Expand All @@ -143,6 +147,7 @@ private void addNewSession() {
waitForDialogClosed("course-details-modal", "Addition of session failed", user);
verifySessionDetails("TEST LESSON NAME", "TEST LESSON COMMENT", "Jan 3, 2018 - 03:10", "Mar 1, 2018 - 15:10");
}

private void editSession() {
log.info("Editing session");
openDialog(".edit-session-icon", user);
Expand Down Expand Up @@ -195,6 +200,7 @@ private void verifySessionDetails(String expectedTitle, String expectedComment,
String actualDateTime = user.getDriver().findElement(By.cssSelector("li.session-data .session-datetime")).getText();
Assertions.assertTrue(actualDateTime.equals(expectedDateTime1) || actualDateTime.equals(expectedDateTime2));
}

@Resource(resID = "LoginService", replaceable = {})
@AccessMode(resID = "LoginService", concurrency = 10, sharing = true, accessMode = "READONLY")
@Resource(resID = "OpenVidu", replaceable = {"OpenViduMock"})
Expand Down Expand Up @@ -428,6 +434,8 @@ void attendersRestOperations() throws ElementNotFoundException {//42+32+65 set u

private void enterCourseAndNavigateTab(String courseName, String tabId) { //16 lines
log.info("Entering course {}", courseName);
//All these tests always create a new course, so we wait for 3-courses in the main page (more than 2)
user.waitUntil(ExpectedConditions.numberOfElementsToBeMoreThan(By.cssSelector("#course-list .course-list-item div.course-title span"), 2), "The number of courses should be 3");
List<WebElement> allCourses = user.getDriver()
.findElements(By.cssSelector("#course-list .course-list-item div.course-title span"));
WebElement courseSpan = null;
Expand All @@ -437,7 +445,8 @@ private void enterCourseAndNavigateTab(String courseName, String tabId) { //16 l
break;
}
}
assert courseSpan != null;

assertNotNull(courseSpan, "The course with the name '" + courseName + "' could not be found. Total courses available: " + allCourses.size());
courseSpan.click();
user.waitUntil(ExpectedConditions.textToBe(By.id("main-course-title"), courseName), "Unexpected course title");
log.info("Navigating to tab by clicking icon with id '{}'", tabId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private void createNewSession(String sessionName) throws ElementNotFoundExceptio
Wait.notTooMuch(user.getDriver());
// Verify session creation
Wait.waitForPageLoaded(user.getDriver());
user.waitUntil(ExpectedConditions.numberOfElementsToBeMoreThan(SESSION_LIST_SESSION_ROW,3),"Incorrect number of sessions (never more than 2)");
List<String> session_titles = SessionNavigationUtilities.getFullSessionList(user.getDriver());
assertTrue(session_titles.contains(sessionName), "Session has not been created");
}
Expand Down

0 comments on commit 2df36e1

Please sign in to comment.