Skip to content

Commit

Permalink
Fixing the ReplyToCommentTest
Browse files Browse the repository at this point in the history
  • Loading branch information
augustocristian committed Aug 18, 2024
1 parent b277862 commit 5783521
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public static List<String> getUserEntries(WebDriver wd, String user_name) {
List<WebElement> entries = tab_content.findElements(By.className("entry-title"));
for (WebElement entry : entries) {
//if username is the publisher of the entry...
entries_titles.add(entry.findElement(FORUM_ENTRY_LIST_ENTRY_TITLE).getText());
if (entry.getText().contains(user_name))
entries_titles.add(entry.findElement(FORUM_ENTRY_LIST_ENTRY_TITLE).getText());
}

return entries_titles;
Expand All @@ -64,7 +65,6 @@ public static WebElement getEntry(WebDriver wd, String entry_name) throws Elemen

Wait.notTooMuch(wd).until(ExpectedConditions.visibilityOfElementLocated(FORUM_ICON));
WebElement tab_content = CourseNavigationUtilities.getTabContent(wd, FORUM_ICON);
//Wait.notTooMuch(wd).until(ExpectedConditions.visibilityOfElementLocated(By.className("entry-title")));
List<WebElement> entries = tab_content.findElements(By.className("entry-title"));
for (WebElement entry : entries) {
try {
Expand Down Expand Up @@ -147,6 +147,7 @@ public static WebDriver newEntry(WebDriver wd, String newEntryTitle, String newE
public static List<WebElement> getReplies(WebDriver driver, WebElement comment) { //7 lines
log.info("Get all the replies of the selected comment");
List<WebElement> replies = new ArrayList<>();
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST_COMMENT_DIV));
//get all comment-div
List<WebElement> nestedComments = comment.findElements(FORUM_COMMENT_LIST_COMMENT_DIV);
//ignore first it is original comment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public LoggedForumTest() {
}

public static Stream<Arguments> data() throws IOException {
return ParameterLoader.getTestUsers();
return ParameterLoader.getTestTeachers();
}


Expand Down Expand Up @@ -323,15 +323,14 @@ void forumNewReply2CommentTest(String mail, String password, String role) { // 6
try {
//check if one course have any entry for comment
NavigationUtilities.toCoursesHome(driver);//3lines

WebElement course = CourseNavigationUtilities.getCourseByName(driver, courseName);//14 lines
course.findElement(COURSE_LIST_COURSE_TITLE).click();
Wait.notTooMuch(driver).until(ExpectedConditions.visibilityOfElementLocated(By.id(TABS_DIV_ID)));
CourseNavigationUtilities.go2Tab(driver, FORUM_ICON);//4 lines
assertTrue(ForumNavigationUtilities.isForumEnabled(CourseNavigationUtilities.getTabContent(driver, FORUM_ICON)), "Forum not activated");//2lines
List<String> entries_list = ForumNavigationUtilities.getFullEntryList(driver);//6lines
WebElement entry;
if (entries_list.size() <= 0) {//if not new entry
if (entries_list.isEmpty()) {//if not new entry
newEntryTitle = "New Comment Test " + mDay + mMonth + mYear + mHour + mMinute + mSecond;
String newEntryContent = "This is the content written on the " + mDay + " of " + months[mMonth - 1] + ", " + mHour + ":" + mMinute + "," + mSecond;
ForumNavigationUtilities.newEntry(driver, newEntryTitle, newEntryContent); //19 lines
Expand All @@ -352,7 +351,7 @@ void forumNewReply2CommentTest(String mail, String password, String role) { // 6
WebElement textField = driver.findElement(FORUM_COMMENT_LIST_MODAL_NEW_REPLY_TEXT_FIELD);
textField.sendKeys(newReplyContent);
Click.element(user.getDriver(), FORUM_NEW_COMMENT_MODAL_POST_BUTTON);

user.waitUntil(ExpectedConditions.invisibilityOfElementLocated(FORUM_COMMENT_LIST_MODAL_NEW_REPLY),"The model is still visible");
user.waitUntil(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST), "The comments are not visible");

user.waitUntil(ExpectedConditions.visibilityOfElementLocated(FORUM_COMMENT_LIST_COMMENT), "The comment list are not visible");
Expand All @@ -361,16 +360,14 @@ void forumNewReply2CommentTest(String mail, String password, String role) { // 6
List<WebElement> replies = ForumNavigationUtilities.getReplies(user.getDriver(), comments.get(0)); // 7 lines
WebElement newReply = null;
for (WebElement reply : replies) {

reply.findElement(By.cssSelector("#div.col.l11.m11.s11 > div.message-itself"));
String text = reply.getText();
if (text.equals(newReplyContent))
if (text.contains(newReplyContent))
newReply = reply;
}
//assert reply
assertNotNull(newReply, "Reply not found");
boolean asserto = newReply.findElement(FORUM_COMMENT_LIST_COMMENT_USER).getText().equals(userName);
assertTrue(asserto, "Bad user in comment");
boolean isNameEqual = newReply.findElement(FORUM_COMMENT_LIST_COMMENT_USER).getText().equals(userName);
assertTrue(isNameEqual, "Bad user in comment");
//nested reply
//assert nested reply
} catch (ElementNotFoundException notFoundException) {
Expand Down

0 comments on commit 5783521

Please sign in to comment.