Skip to content

Commit

Permalink
Trying to remove test flakiness from entercourseandnavigatetab method
Browse files Browse the repository at this point in the history
  • Loading branch information
augustocristian committed Mar 26, 2024
1 parent 31b3dfc commit 6efabaa
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.fullteaching.e2e.no_elastest.common.BaseLoggedTest;
import com.fullteaching.e2e.no_elastest.common.CourseNavigationUtilities;
import com.fullteaching.e2e.no_elastest.common.exception.ElementNotFoundException;
import dev.failsafe.internal.util.Assert;
import giis.retorch.annotations.AccessMode;
import giis.retorch.annotations.Resource;
import io.github.bonigarcia.seljup.SeleniumJupiter;
Expand All @@ -37,6 +38,9 @@
import java.time.format.DateTimeFormatter;
import java.util.List;

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

/**
* E2E tests for FullTeaching REST CRUD operations.
*
Expand Down Expand Up @@ -117,6 +121,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 +140,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 +149,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 +202,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 +436,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 +447,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

0 comments on commit 6efabaa

Please sign in to comment.