Skip to content

Commit

Permalink
All tests passing
Browse files Browse the repository at this point in the history
userCanAccessAndViewCalendarCOT4MiniTest passing!

userAccessingCalendarFS4oMiniTest passing!

userCanAccessAndViewCalendarCOT4oTest passing!

userAccessCalendarFS4oTest passing!

teacherCreatesCourseCOT4oMiniTest passing!

teacherCreatesCourseFS4oMiniTest passing!

teacherCreateCourseCOT4oTest passing!

teacherCreateCourseFS4oTest passing!

userAccessCoursesAndViewClassesCOT4oMiniTest passing!

userAccessCoursesAndViewClassesFS4oMiniTest passing!

userAccessCoursesAndViewClassesCOT4oTest passing!

accessCoursesAndViewClassesFS4oTest passing!

viewEnrolledCoursesCOT4oMiniTest passing!

viewEnrolledCoursesFS4oMiniTest passing!

viewEnrolledCoursesCOT4oTest passing!

viewEnrolledCoursesFS4oTest passing!
  • Loading branch information
augustocristian committed Jul 30, 2024
1 parent f694c32 commit 2270617
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ void viewEnrolledCoursesFS4oTest(String mail, String password, String role) {
}

// Step 3: System displays a list of courses the user is enrolled in
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id("courses-list")));
List<WebElement> courses = driver.findElements(By.className("course-item"));
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id("course-list")));
List<WebElement> courses = driver.findElements(By.className("course-list-item"));

// Expected Output: The dashboard shows a list of courses the user is enrolled in
assertTrue(courses.size() > 0, "No enrolled courses found for the user");
Expand All @@ -144,18 +144,19 @@ void viewEnrolledCoursesCOT4oTest(String email, String password, String role) {
// Setup
//String email = "[email protected]";
//String password = "password";
String[] expectedCourses = {"Course 1", "Course 2", "Course 3"};
String[] expectedCourses = {"Pseudoscientific course for treating the evil eye", "Don't mind. This is a real course"};

// Login
this.slowLogin(user, email, password);

// Verify Dashboard
try {
NavigationUtilities.toCoursesHome(driver);
// Wait for the dashboard to load
Wait.notTooMuch(driver).until(ExpectedConditions.presenceOfElementLocated(By.id("dashboard")));
Wait.notTooMuch(driver).until(ExpectedConditions.presenceOfElementLocated(COURSES_DASHBOARD_TITLE));

// Get the list of enrolled courses
List<WebElement> courses = driver.findElements(By.className("course-title"));
List<WebElement> courses = driver.findElements(By.className("title"));

// Verify the number of courses
assertEquals(expectedCourses.length, courses.size(), "Number of enrolled courses does not match");
Expand Down Expand Up @@ -187,11 +188,11 @@ void viewEnrolledCoursesFS4oMiniTest(String mail, String password, String role)
NavigationUtilities.toCoursesHome(driver);

// Wait for the courses list to be visible
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id("enrolledCoursesList")));
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id("course-list")));

// Verify that the dashboard shows a list of courses the user is enrolled in
List<WebElement> enrolledCourses = driver.findElements(By.className("course-title"));
assertFalse(enrolledCourses.isEmpty(), "The enrolled courses list should not be empty.");
List<WebElement> enrolledCourses = driver.findElements(By.className("course-list-item"));
assertFalse(enrolledCourses.size()!=2, "The enrolled courses list should not be empty.");

// Optionally, you can check for specific course titles if known
// assertTrue(enrolledCourses.stream().anyMatch(course -> course.getText().equals("Expected Course Title")), "Expected course is not found in the enrolled courses list.");
Expand All @@ -211,7 +212,7 @@ void viewEnrolledCoursesCOT4oMiniTest(String email, String password, String role
NavigationUtilities.toCoursesHome(driver);

// Verification: Check that the system displays a list of enrolled courses
List<WebElement> enrolledCourses = driver.findElements(By.className("enrolled-course")); // Replace with actual class name for enrolled courses
List<WebElement> enrolledCourses = driver.findElements(By.className("course-list-item")); // Replace with actual class name for enrolled courses
Assertions.assertFalse(enrolledCourses.isEmpty(), "The enrolled courses list should not be empty.");

// Optionally, validate the content of the enrolled courses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,18 @@ void accessCoursesAndViewClassesFS4oTest(String mail, String password, String ro
// Access the first course
WebElement course = CourseNavigationUtilities.getCourseByName(driver, courses.get(0));
course.findElement(By.cssSelector(".course-title")).click();
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id("course-classes")));
CourseNavigationUtilities.go2Tab(driver, SESSION_ICON);
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.className("session-data")));

// Verify classes are ordered by date
List<WebElement> classes = driver.findElements(By.cssSelector(".class-item"));
List<WebElement> classes = driver.findElements(By.className("session-data"));
assertTrue(classes.size() > 0, "No classes found in the course");

// Check if classes are ordered by date
boolean isOrderedByDate = true;
for (int i = 1; i < classes.size(); i++) {
String previousDate = classes.get(i - 1).findElement(By.cssSelector(".class-date")).getText();
String currentDate = classes.get(i).findElement(By.cssSelector(".class-date")).getText();
String previousDate = classes.get(i - 1).findElement(By.className("session-datetime")).getText();
String currentDate = classes.get(i).findElement(By.className("session-datetime")).getText();
if (previousDate.compareTo(currentDate) > 0) {
isOrderedByDate = false;
break;
Expand Down Expand Up @@ -169,16 +170,17 @@ void userAccessCoursesAndViewClassesCOT4oTest(String mail, String password, Stri
String courseName = courses.get(0); // Select the first course for simplicity
WebElement course = CourseNavigationUtilities.getCourseByName(driver, courseName);
course.findElement(By.cssSelector(".course-title")).click();
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id("course-page")));
CourseNavigationUtilities.go2Tab(driver, SESSION_ICON);
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.className("session-data")));

// Step 4: System displays the classes within the course, ordered by date
List<WebElement> classes = driver.findElements(By.cssSelector(".class-item"));
List<WebElement> classes = driver.findElements(By.className("session-data"));
assertTrue(classes.size() > 0, "No classes found in the course");

// Verify that classes are ordered by date
for (int i = 1; i < classes.size(); i++) {
String previousDate = classes.get(i - 1).findElement(By.cssSelector(".class-date")).getText();
String currentDate = classes.get(i).findElement(By.cssSelector(".class-date")).getText();
String previousDate = classes.get(i - 1).findElement(By.className("session-datetime")).getText();
String currentDate = classes.get(i).findElement(By.className("session-datetime")).getText();
assertTrue(previousDate.compareTo(currentDate) <= 0, "Classes are not ordered by date");
}

Expand Down Expand Up @@ -211,10 +213,10 @@ void userAccessCoursesAndViewClassesFS4oMiniTest(String mail, String password, S

// Step 4: System displays the classes within the course, ordered by date
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id(TABS_DIV_ID)));

// Verify that classes are displayed TO-DO
//List<WebElement> classes = CourseNavigationUtilities.getClassesList(driver);
//assertFalse(classes.isEmpty(), "No classes found for the selected course.");
CourseNavigationUtilities.go2Tab(driver, SESSION_ICON);
// Verify that classes are displayed
List<WebElement> classes = driver.findElements(By.className("session-data"));
assertFalse(classes.isEmpty(), "No classes found for the selected course.");

// Optionally, check if classes are ordered by date
// (Assuming there is a method to verify the order of classes) TO-DO
Expand Down Expand Up @@ -245,11 +247,11 @@ void userAccessCoursesAndViewClassesCOT4oMiniTest(String mail, String password,
String courseName = enrolledCourses.get(0); // Access the first course
WebElement courseElement = CourseNavigationUtilities.getCourseByName(driver, courseName);
Click.element(driver, courseElement);
//Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id(COURSE_PAGE_ID)));

// Step 5: View classes within the course TO-DO
//List<WebElement> classes = CourseNavigationUtilities.getClassesList(driver);
//assertFalse(classes.isEmpty(), "The course should have classes displayed.");
// Step 5: View classes within the course
CourseNavigationUtilities.go2Tab(driver, SESSION_ICON);
List<WebElement> classes = driver.findElements(By.className("session-data"));
assertFalse(classes.isEmpty(), "The course should have classes displayed.");
// Optionally, check if classes are ordered by date
// (Assuming there's a method to verify order)
//assertTrue(CourseNavigationUtilities.areClassesOrderedByDate(classes), "Classes should be ordered by date.");
Expand Down
Loading

0 comments on commit 2270617

Please sign in to comment.