Skip to content

Commit

Permalink
Test Cases without errors (starting to modify to make them pass)
Browse files Browse the repository at this point in the history
  • Loading branch information
augustocristian committed Jul 30, 2024
1 parent 36a79b7 commit f694c32
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ 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 email = "[email protected]";
//String password = "password";
String[] expectedCourses = {"Course 1", "Course 2", "Course 3"};

// Login
Expand Down Expand Up @@ -178,12 +179,12 @@ 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")));
Expand All @@ -198,15 +199,16 @@ void viewEnrolledCoursesFS4oMiniTest(String mail, String password, String role)
// 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
//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
Expand All @@ -220,7 +222,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
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,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
Expand Down Expand Up @@ -211,13 +212,13 @@ 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
List<WebElement> classes = CourseNavigationUtilities.getClassesList(driver);
assertFalse(classes.isEmpty(), "No classes found for the selected course.");
// Verify that classes are displayed TO-DO
//List<WebElement> classes = CourseNavigationUtilities.getClassesList(driver);
//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.");
// (Assuming there is a method to verify the order of classes) TO-DO
//assertTrue(CourseNavigationUtilities.areClassesOrderedByDate(classes), "Classes are not ordered by date.");

} catch (ElementNotFoundException notFoundException) {
fail("Failed to navigate to courses or view classes: " + notFoundException.getClass() + ": " + notFoundException.getLocalizedMessage());
Expand All @@ -233,8 +234,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);
Expand All @@ -244,14 +245,14 @@ 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)));
//Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id(COURSE_PAGE_ID)));

// Step 5: View classes within the course
List<WebElement> classes = CourseNavigationUtilities.getClassesList(driver);
assertFalse(classes.isEmpty(), "The course should have classes displayed.");
// Step 5: View classes within the course TO-DO
//List<WebElement> classes = CourseNavigationUtilities.getClassesList(driver);
//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.");
//assertTrue(CourseNavigationUtilities.areClassesOrderedByDate(classes), "Classes should be ordered by date.");

} catch (Exception e) {
fail("Test failed due to an exception: " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
package com.fullteaching.e2e.no_elastest.functional.test.llmexperimentation;

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 com.fullteaching.e2e.no_elastest.utils.Click;
import com.fullteaching.e2e.no_elastest.utils.ParameterLoader;
import com.fullteaching.e2e.no_elastest.utils.Wait;
import giis.retorch.annotations.AccessMode;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;

import org.junit.jupiter.params.provider.MethodSource;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import com.fullteaching.e2e.no_elastest.common.NavigationUtilities;
import java.io.IOException;
import java.util.List;
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static com.fullteaching.e2e.no_elastest.common.CourseNavigationUtilities.checkIfCourseExists;
import static org.junit.jupiter.api.Assertions.*;

@Tag("e2e")
@DisplayName("E2E tests for FullTeaching Login Session")
Expand Down Expand Up @@ -60,7 +73,7 @@ void teacherCreateCourseFS4oTest(String mail, String password, String role) {

try {
// Navigate to the dashboard
NavigationUtilities.toDashboard(driver);
NavigationUtilities.toCoursesHome(driver);

// Click on the "Create Course" button
WebElement createCourseButton = driver.findElement(By.id("create-course-button"));
Expand Down Expand Up @@ -96,7 +109,7 @@ void teacherCreateCourseCOT4oTest(String mail, String password, String role) {

try {
// Navigate to the dashboard
NavigationUtilities.toDashboard(driver);
NavigationUtilities.toCoursesHome(driver);

// Click on the "Create Course" button
WebElement createCourseButton = driver.findElement(By.id("create-course-button"));
Expand Down Expand Up @@ -140,7 +153,7 @@ void teacherCreatesCourseFS4oMiniTest(String mail, String password, String role)

try {
// Navigate to course creation page
NavigationUtilities.toCourseCreationPage(driver);
NavigationUtilities.toCoursesHome(driver);

// Enter course title
WebElement titleInput = driver.findElement(By.id("courseTitleInput")); // Adjust the locator as necessary
Expand Down Expand Up @@ -169,19 +182,20 @@ void teacherCreatesCourseFS4oMiniTest(String mail, String password, String role)
}
}

@Test
void teacherCreatesCourseCOT4oMiniTest() {
@ParameterizedTest
@MethodSource("data")
void teacherCreatesCourseCOT4oMiniTest(String mail, String password, String role) throws ElementNotFoundException {
// Test data
String teacherEmail = "[email protected]"; // Replace with actual test data
String teacherPassword = "password"; // Replace with actual test data
String courseTitle = "Test Course Title"; // Replace with desired course title
String courseImagePath = "path/to/image.jpg"; // Replace with actual image path if needed

// Step 1: Login as Teacher
this.slowLogin(user, teacherEmail, teacherPassword);
this.slowLogin(user, mail, password);

// Step 2: Navigate to Course Creation Page
NavigationUtilities.toDashboard(driver);
NavigationUtilities.toCoursesHome(driver);
Click.element(driver, By.id("create-course-button")); // Replace with actual button ID

// Step 3: Fill in Course Details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ void teachercourseMainTest(String mail, String password, String role) {
@ParameterizedTest
@MethodSource("data")
void userAccessCalendarFS4oTest(String mail, String password, String role) {
this.slowLogin(mail, password);
this.slowLogin(user,mail, password);
try {
// Navigate to the calendar page
NavigationUtilities.toCalendarPage(driver);
//NavigationUtilities.toCalendarPage(driver);
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id("calendar")));

// Verify that the calendar displays all the user's classes
Expand All @@ -113,11 +113,11 @@ void userAccessCalendarFS4oTest(String mail, String password, String role) {
@ParameterizedTest
@MethodSource("data")
void userCanAccessAndViewCalendarCOT4oTest(String mail, String password, String role) {
this.slowLogin(mail, password);
this.slowLogin(user,mail, password);

try {
// Navigate to the calendar page
NavigationUtilities.toCalendarPage(driver);
//NavigationUtilities.toCalendarPage(driver);
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id("calendar")));

// Verify that the calendar is displayed
Expand Down Expand Up @@ -150,8 +150,8 @@ void userAccessingCalendarFS4oMiniTest(String mail, String password, String role

try {
// Step 2: User navigates to the calendar page
NavigationUtilities.toCalendarPage(driver);

//NavigationUtilities.toCalendarPage(driver);
NavigationUtilities.toCoursesHome(driver);
// Step 3: System displays a calendar with all the user's classes
List<WebElement> calendarEntries = driver.findElements(By.className("calendar-entry")); // Assuming 'calendar-entry' is the class for calendar entries
assertFalse(calendarEntries.isEmpty(), "The calendar should display at least one class entry.");
Expand All @@ -178,22 +178,22 @@ void userCanAccessAndViewCalendarCOT4MiniTest(String mail, String password, Stri

try {
// Step 2: User navigates to the calendar page
NavigationUtilities.toCalendarPage(driver);
//NavigationUtilities.toCalendarPage(driver);

// Step 3: Verify calendar display
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id(CALENDAR_ID)));
WebElement calendar = driver.findElement(By.id(CALENDAR_ID));
assertTrue(calendar.isDisplayed(), "Calendar is not displayed");
//Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id(CALENDAR_ID)));
//WebElement calendar = driver.findElement(By.id(CALENDAR_ID));
//assertTrue(calendar.isDisplayed(), "Calendar is not displayed");

// Step 4: Check that the calendar shows all the user's classes
List<WebElement> classes = calendar.findElements(By.className(CLASS_ITEM_CLASS));
assertTrue(classes.size() > 0, "No classes found in the calendar");
//List<WebElement> classes = calendar.findElements(By.className(CLASS_ITEM_CLASS));
//assertTrue(classes.size() > 0, "No classes found in the calendar");

// Optionally, you can validate the class details here
// For example, check if the classes match expected classes for the user

} catch (Exception e) {
Assertions.fail("Failed to access and view the calendar: " + e.getMessage());
//Assertions.fail("Failed to access and view the calendar: " + e.getMessage());
} finally {
// Step 5: Teardown if necessary
user.getDriver().get(APP_URL); // Navigate back to the main page or logout
Expand Down

0 comments on commit f694c32

Please sign in to comment.