-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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! Test Cases without errors (starting to modify to make them pass)
- Loading branch information
1 parent
36a79b7
commit 84f1652
Showing
6 changed files
with
147 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"); | ||
|
@@ -138,23 +138,23 @@ void viewEnrolledCoursesFS4oTest(String mail, String password, String role) { | |
// Teardown: Navigate to the main page to logout | ||
user.getDriver().get(APP_URL); | ||
} | ||
@Test | ||
void viewEnrolledCoursesCOT4oTest() { | ||
@ParameterizedTest | ||
@MethodSource("data") | ||
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"); | ||
|
@@ -178,38 +178,37 @@ void viewEnrolledCoursesCOT4oTest() { | |
@AccessMode(resID = "webserver", concurrency = 1, accessMode = "READWRITE") | ||
@ParameterizedTest | ||
@MethodSource("data") | ||
void viewEnrolledCoursesFS4oMiniTest(String mail, String password, String role) { | ||
void viewEnrolledCoursesFS4oMiniTest(String mail, String password, String role) throws ElementNotFoundException { | ||
// Setup: User logs into the application | ||
this.slowLogin(user, mail, password); | ||
|
||
// Navigate to the dashboard | ||
NavigationUtilities.toDashboard(driver); | ||
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."); | ||
|
||
// Teardown: Navigate back to the main page or logout | ||
user.getDriver().get(APP_URL); | ||
} | ||
@Test | ||
void viewEnrolledCoursesCOT4oMiniTest() { | ||
@ParameterizedTest | ||
@MethodSource("data") | ||
void viewEnrolledCoursesCOT4oMiniTest(String email, String password, String role) throws ElementNotFoundException { | ||
// Setup: Log in to the application | ||
String email = "[email protected]"; // Replace with actual test user email | ||
String password = "password"; // Replace with actual test user password | ||
this.slowLogin(user, email, password); | ||
|
||
// Navigation: Navigate to the dashboard | ||
NavigationUtilities.toDashboard(driver); | ||
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 | ||
|
@@ -220,7 +219,7 @@ void viewEnrolledCoursesCOT4oMiniTest() { | |
} | ||
|
||
// Teardown: Log out of the application | ||
NavigationUtilities.logout(driver); // Replace with actual logout method | ||
//NavigationUtilities.logout(driver); // Replace with actual logout method (NOT NECESSARY DONE IN THE TEAR-DOWN) | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -153,10 +154,11 @@ void accessCoursesAndViewClassesFS4oTest(String mail, String password, String ro | |
fail("Failed to access courses and view classes: " + e.getClass() + ": " + e.getLocalizedMessage()); | ||
} | ||
} | ||
@Test | ||
void userAccessCoursesAndViewClassesCOT4oTest() { | ||
@ParameterizedTest | ||
@MethodSource("data") | ||
void userAccessCoursesAndViewClassesCOT4oTest(String mail, String password, String role) { | ||
// Step 1: User logs into the application | ||
this.slowLogin(user, "[email protected]", "password"); | ||
this.slowLogin(user, mail, password); | ||
|
||
try { | ||
// Step 2: User navigates to the dashboard | ||
|
@@ -168,16 +170,17 @@ void userAccessCoursesAndViewClassesCOT4oTest() { | |
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"); | ||
} | ||
|
||
|
@@ -210,14 +213,18 @@ 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))); | ||
|
||
CourseNavigationUtilities.go2Tab(driver, SESSION_ICON); | ||
// Verify that classes are displayed | ||
List<WebElement> classes = CourseNavigationUtilities.getClassesList(driver); | ||
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) | ||
assertTrue(CourseNavigationUtilities.areClassesOrderedByDate(classes), "Classes are not ordered by date."); | ||
for (int i = 1; i < classes.size(); i++) { | ||
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"); | ||
} | ||
|
||
} catch (ElementNotFoundException notFoundException) { | ||
fail("Failed to navigate to courses or view classes: " + notFoundException.getClass() + ": " + notFoundException.getLocalizedMessage()); | ||
|
@@ -233,8 +240,8 @@ void userAccessCoursesAndViewClassesCOT4oMiniTest(String mail, String password, | |
|
||
try { | ||
// Step 2: Navigate to the dashboard | ||
NavigationUtilities.toDashboard(driver); | ||
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id(DASHBOARD_ID))); | ||
NavigationUtilities.toCoursesHome(driver); | ||
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(COURSES_DASHBOARD_TITLE)); | ||
|
||
// Step 3: View enrolled courses | ||
List<String> enrolledCourses = CourseNavigationUtilities.getCoursesList(driver); | ||
|
@@ -244,15 +251,18 @@ 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 | ||
List<WebElement> classes = CourseNavigationUtilities.getClassesList(driver); | ||
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."); | ||
|
||
for (int i = 1; i < classes.size(); i++) { | ||
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"); | ||
} | ||
} catch (Exception e) { | ||
fail("Test failed due to an exception: " + e.getMessage()); | ||
} finally { | ||
|
Oops, something went wrong.