Skip to content

Commit

Permalink
teacherCreateCourseFS4oTest passing!
Browse files Browse the repository at this point in the history
  • Loading branch information
augustocristian committed Jul 30, 2024
1 parent 74ec4ad commit 49cf184
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
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.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import com.fullteaching.e2e.no_elastest.common.NavigationUtilities;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.stream.Stream;
Expand Down Expand Up @@ -66,46 +70,49 @@ void teacherCreateAndDeletecourseTest (String mail, String password, String role
// Teardown
user.getDriver().get(APP_URL);
}
@ParameterizedTest
@MethodSource("data")
void teacherCreateCourseFS4oTest(String mail, String password, String role) {
this.slowLogin(user, mail, password);
@Test
void teacherCreateCourseFS4oTest() {
String teacherEmail = "[email protected]"; // Replace with actual test data
String teacherPassword = "pass"; // Replace with actual test data
this.slowLogin(user, teacherEmail, teacherPassword);

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

// Click on the "Create Course" button
WebElement createCourseButton = driver.findElement(By.id("create-course-button"));
WebElement createCourseButton = driver.findElement(By.id("add-course-icon"));
Click.element(driver, createCourseButton);

// Enter course title
WebElement courseTitleInput = driver.findElement(By.id("course-title-input"));
WebElement courseTitleInput = driver.findElement(By.id("input-post-course-name"));
courseTitleInput.sendKeys("New Course Title");

// Optionally upload an image
WebElement courseImageInput = driver.findElement(By.id("course-image-input"));
courseImageInput.sendKeys("/path/to/image.jpg");
WebElement fileInput = driver.findElement(By.id("inputPostCourseImage"));
File uploadFile= new File("src/test/resources/inputs/image.png");
fileInput.sendKeys(uploadFile.getAbsolutePath());

// Click on the "Create Course" button
WebElement createCourseSubmitButton = driver.findElement(By.id("create-course-submit-button"));
WebElement createCourseSubmitButton = driver.findElement(By.id("submit-post-course-btn"));
Click.element(driver, createCourseSubmitButton);

// Wait for the course to appear in the dashboard
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id("course-list")));

// Verify the new course appears in the teacher's dashboard
WebElement newCourse = driver.findElement(By.xpath("//div[contains(text(), 'New Course Title')]"));
WebElement newCourse = driver.findElement(By.xpath("//*[contains(text(), 'New Course Title')]"));
assertTrue(newCourse.isDisplayed(), "New course is not displayed in the dashboard");

} catch (Exception e) {
fail("Failed to create a new course: " + e.getClass() + ": " + e.getLocalizedMessage());
}
}
@ParameterizedTest
@MethodSource("data")
void teacherCreateCourseCOT4oTest(String mail, String password, String role) {
this.slowLogin(user, mail, password);
@Test
void teacherCreateCourseCOT4oTest() {
String teacherEmail = "[email protected]"; // Replace with actual test data
String teacherPassword = "pass"; // Replace with actual test data
this.slowLogin(user, teacherEmail, teacherPassword);

try {
// Navigate to the dashboard
Expand Down Expand Up @@ -143,11 +150,12 @@ void teacherCreateCourseCOT4oTest(String mail, String password, String role) {
@AccessMode(resID = "executor", concurrency = 1, accessMode = "READWRITE")
@AccessMode(resID = "webbrowser", concurrency = 1, accessMode = "READWRITE")
@AccessMode(resID = "webserver", concurrency = 1, accessMode = "READWRITE")
@ParameterizedTest
@MethodSource("data")
void teacherCreatesCourseFS4oMiniTest(String mail, String password, String role) {
@Test
void teacherCreatesCourseFS4oMiniTest() {
String teacherEmail = "[email protected]"; // Replace with actual test data
String teacherPassword = "pass"; // Replace with actual test data
// Log in with provided credentials
this.slowLogin(user, mail, password);
this.slowLogin(user, teacherEmail, teacherPassword);
String courseTitle = "New Course Title";
String courseImagePath = "path/to/image.jpg"; // Optional image path

Expand Down Expand Up @@ -182,17 +190,16 @@ void teacherCreatesCourseFS4oMiniTest(String mail, String password, String role)
}
}

@ParameterizedTest
@MethodSource("data")
void teacherCreatesCourseCOT4oMiniTest(String mail, String password, String role) throws ElementNotFoundException {
@Test
void teacherCreatesCourseCOT4oMiniTest() throws ElementNotFoundException {
// Test data
String teacherEmail = "teacher@example.com"; // Replace with actual test data
String teacherPassword = "password"; // Replace with actual test data
String teacherEmail = "teacher@gmail.com"; // Replace with actual test data
String teacherPassword = "pass"; // 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, mail, password);
this.slowLogin(user, teacherEmail, teacherPassword);

// Step 2: Navigate to Course Creation Page
NavigationUtilities.toCoursesHome(driver);
Expand Down
Binary file added src/test/resources/inputs/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 49cf184

Please sign in to comment.