From 0b4d33b095305a24ecac74397a6b5c6cb849ab96 Mon Sep 17 00:00:00 2001 From: araschitor <71637144+araschitor@users.noreply.github.com> Date: Wed, 24 Mar 2021 15:23:23 +0200 Subject: [PATCH] Updated tests for Add blog post comment (#93) * feature/APPS-871: Adjusted existing helper methods and deleted all java docs. * feature/APPS-871: Adjusted existing methods and deleted java docs * feature/APPS-871: Ajusted helper methods * feature/APPS-871: Renamed methods * feature/APPS-871: Addressed suggestions #1 * feature/APPS-871: Renamed test class --- ...ommentTests_addCommentToDraftBlogPost.html | 627 ++++++++++++++++++ .../po/share/site/blog/BlogPostListPage.java | 108 +-- .../po/share/site/blog/BlogPostViewPage.java | 135 +--- .../po/share/site/blog/BlogPromptWindow.java | 34 +- .../sitesFeatures/blog/AccessBlogTests.java | 2 +- .../blog/BlogPostAddCommentTests.java | 177 ++--- .../blog/BlogPostEditCommentsTests.java | 7 +- .../blog/BrowsingBlogPostsTests.java | 6 +- .../blog/CreatingABlogPostTests.java | 8 +- .../blog/DeletingABlogPostTests.java | 12 +- .../blog/DeletingACommentTests.java | 7 +- .../blog/EditingABlogPostTests.java | 14 +- .../blog/ViewingABlogPostTests.java | 12 +- 13 files changed, 823 insertions(+), 326 deletions(-) create mode 100644 alfresco-tas-share-test/Test Results - BlogPostAddCommentTests_addCommentToDraftBlogPost.html diff --git a/alfresco-tas-share-test/Test Results - BlogPostAddCommentTests_addCommentToDraftBlogPost.html b/alfresco-tas-share-test/Test Results - BlogPostAddCommentTests_addCommentToDraftBlogPost.html new file mode 100644 index 0000000000..9fcb0e9441 --- /dev/null +++ b/alfresco-tas-share-test/Test Results - BlogPostAddCommentTests_addCommentToDraftBlogPost.html @@ -0,0 +1,627 @@ + + + + + Test Results — BlogPostAddCommentTests.addCommentToDraftBlogPost + + + + + + + + + +
+ +
+ +
+
+ + + diff --git a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/site/blog/BlogPostListPage.java b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/site/blog/BlogPostListPage.java index e5471b3a65..3ad7490070 100644 --- a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/site/blog/BlogPostListPage.java +++ b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/site/blog/BlogPostListPage.java @@ -42,12 +42,14 @@ public class BlogPostListPage extends SiteCommon private final By nodeTitle = By.xpath(".//span[@class = 'nodeTitle']"); private final By simpleNodePost = By.cssSelector(".node.post.simple"); private final By postDateTime = By.xpath(".//div[@class = 'published']//span[@class = 'nodeAttrValue']"); + private final By readLabel = By.xpath("div[@class = 'nodeFooter']//span[@class = 'nodeAttrValue']//a"); private final By editButton = By.xpath(".//../div[@class = 'nodeEdit']//div[@class = 'onEditBlogPost']//a//span[text() = 'Edit']"); private final By blogLinkName = By.id("HEADER_SITE_BLOG-POSTLIST"); private final By allFilter = By.cssSelector("ul.filterLink span.all>a"); private final By latestFilter = By.cssSelector("ul.filterLink span.new>a"); private final By myDraftsFilter = By.cssSelector("ul.filterLink span.mydrafts>a"); + private final By listTitle = By.className("listTitle"); private final By myPublished = By.cssSelector("ul.filterLink span.mypublished>a"); private final By tag = By.xpath("//span[@class ='tag']/a"); @@ -117,11 +119,6 @@ public BlogPostListPage assertNoBlogPostFound(String expectedNoBlogPostsFoundLab return this; } - /** - * Method to check if the New Post button is displayed on the Blog Page - * - * @return - */ public boolean isNewPostButtonDisplayed() { return isElementDisplayed(newPostButton); @@ -156,23 +153,11 @@ private String getPostPublishedDateTime(String title) return getElementText(getBlogPostRow(title).findElement(postDateTime)); } - /** - * Method to check if the edit button is available for the blog post under test - * - * @param title - * @return - */ public boolean isEditButtonPresentForBlogPost(String title) { return selectBlogPostWithTitle(title).findElement(By.xpath("//div[@class = 'onEditBlogPost']")).isDisplayed(); } - /** - * Method to check if the delete button is available for the blog post under test - * - * @param title - * @return - */ public boolean isDeleteButtonPresentForBlogPost(String title) { return selectBlogPostWithTitle(title).findElement(By.xpath("//div[@class = 'onDeleteBlogPost']")).isDisplayed(); @@ -266,7 +251,7 @@ public String getBlogPostContent(String title) return getElementText(post.findElement(blogContent)); } - public BlogPostListPage assertBlogPostNumberOfRepliesEqualTo(String title, String expectedNumberOfReplies) + public BlogPostListPage assertPostNumberOfRepliesEqualTo(String title, String expectedNumberOfReplies) { log.info("Assert blog post number of replies equal to {}", expectedNumberOfReplies); waitUntilElementIsVisible(By.xpath(String.format(postFooterPath, expectedNumberOfReplies))); @@ -309,9 +294,6 @@ public BlogPostListPage assertBlogPostHaveTagEqualsTo(String title, String expec return this; } - /** - * Method to get the page title - */ public String getPageTitle() { return pageTitle.getText(); @@ -322,131 +304,81 @@ public boolean isBlogPostDisplayed(String title) return isElementDisplayed(getBlogPostRow(title)); } - /** - * Method to click on the All filter - */ - public void clickAllFilter() + public BlogPostListPage navigateToAllFilter() { - findElement(allFilter).click(); - waitUntilElementContainsText(pageTitle, "All Posts"); + log.info("Navigate to all filter"); + clickElement(allFilter); + return this; } - /** - * Click on Latest filter - */ public void clickLatestFilter() { - findElement(latestFilter).click(); - waitUntilElementContainsText(pageTitle, "New Posts"); + clickElement(latestFilter); + waitUntilElementContainsText(listTitle, "New Posts"); } - /** - * Click on My Drafts filter - */ - public void clickMyDraftsFilter() + public BlogPostListPage navigateToMyDrafts() { clickElement(myDraftsFilter); - findElement(myDraftsFilter).click(); - waitUntilElementContainsText(pageTitle, "My Draft Posts"); + waitUntilElementContainsText(listTitle, "My Draft Posts"); + return this; } - /** - * Click on My Published filter - */ public void clickMyPublishedFilter() { - findElement(myPublished).click(); - waitUntilElementContainsText(pageTitle, "My Published Posts"); + clickElement(myPublished); + waitUntilElementContainsText(listTitle, "My Published Posts"); } - /** - * Click on Tag filter - */ public void clickTag(String tag) { mouseOver(selectTagsByTagName(tag)); - selectTagsByTagName(tag).click(); - waitUntilElementContainsText(pageTitle, "Blog Post List"); + clickElement(selectTagsByTagName(tag)); + waitUntilElementContainsText(listTitle, "Blog Post List"); } - /** - * Click on Archive Month filter - * - * @param month - */ public void clickArchiveMonth(String month) { selectArchiveMonth(month).click(); waitUntilElementContainsText(pageTitle, "Posts for Month " + month); } - /** - * Method to click on the Read button for the selected blog post - */ - public BlogPostViewPage clickReadBlogPost(String title) + public BlogPostViewPage readPost(String postTitle) { - waitUntilWebElementIsDisplayedWithRetry(selectBlogPostFooter(title)); - selectBlogPostFooter(title).findElement(By.xpath(".//div[@class = 'nodeFooter']//span[@class = 'nodeAttrValue']//a[text() ='Read']")).click(); + log.info("Read post {}", postTitle); + waitUntilWebElementIsDisplayedWithRetry(getBlogPostRow(postTitle)); + clickElement(getBlogPostRow(postTitle).findElement(readLabel)); return new BlogPostViewPage(webDriver); } - /** - * Method to check if the blog post content is displayed while on the Blog Post List page - * - * @param title - * @return - */ public boolean isBlogPostContentDisplayed(String title) { return isElementDisplayed(By.xpath(".//div[@class = 'content yuieditor']")); } - /** - * Method to get the button name displayed for Simple View/ Detailed View button - * - * @return - */ public String getButtonName() { return findElement(simpleViewButton).getText(); } - /** - * Method to click on the blog post title - * - * @param title - */ public BlogPostViewPage clickOnThePostTitle(String title) { findElement(By.xpath("//tr[contains(@class, 'yui-dt-rec')]//div[@class = 'nodeContent']//span/a[text() = '" + title + "']")).click(); return new BlogPostViewPage(webDriver); } - /** - * Method to click the Edit button for the selected blog post that needs to be edited. The blog post is selected by title - * - * @param title - */ public EditBlogPostPage clickEditButton(String title) { selectBlogPostWithTitle(title).findElement(editButton).click(); return new EditBlogPostPage(webDriver); } - /** - * Method to click the New Post button - */ public CreateBlogPostPage clickNewPostButton() { clickElement(newPostButton); return new CreateBlogPostPage(webDriver); } - /** - * Method to click on the Delete button for the selected blog post - * - * @param title - */ public void clickDeleteButton(String title) { selectBlogPostWithTitle(title).findElement(By.xpath("//div[@class = 'onDeleteBlogPost']//span[text()='Delete']")).click(); diff --git a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/site/blog/BlogPostViewPage.java b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/site/blog/BlogPostViewPage.java index 1e413b8f10..3f7de0c58d 100644 --- a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/site/blog/BlogPostViewPage.java +++ b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/site/blog/BlogPostViewPage.java @@ -2,6 +2,8 @@ import java.util.ArrayList; import java.util.List; + +import lombok.extern.slf4j.Slf4j; import org.alfresco.po.share.DeleteDialog; import org.alfresco.po.share.site.SiteCommon; import org.openqa.selenium.By; @@ -10,37 +12,26 @@ import org.openqa.selenium.support.FindAll; import org.openqa.selenium.support.FindBy; +@Slf4j public class BlogPostViewPage extends SiteCommon { - public final By commentText = By.cssSelector("div[class ='comment-content'] p"); - @FindBy (xpath = "//tbody[@class = 'yui-dt-message']//div[@class = 'yui-dt-liner']") - public WebElement noCommentsText; - - @FindBy (css = "div[id*='_blog-postview'] div.nodeTitle>a") - private WebElement blogPostTitle; - - @FindBy (css = "div[id*='_blog-postview'] div.content") - private WebElement blogPostContent; - @FindBy (css = ".published .nodeAttrValue>a") - private WebElement blogPostAuthor; - @FindBy (css = ".nodeTitle .nodeStatus") - private WebElement blogPostNote; - @FindBy (css = "div[id*='_blog-postview'] .backLink>a") - private WebElement blogPostListButton; - @FindBy (css = "button[id$='_default-create-button-button']") - private WebElement newPostButton; - @FindBy (css = ".onEditBlogPost>a") - private WebElement editButton; - @FindBy (css = ".onDeleteBlogPost>a") - private WebElement deleteButton; - @FindBy (css = ".onAddCommentClick button") - private WebElement addCommentButton; + public final By noCommentsText = By.xpath("//tbody[@class = 'yui-dt-message']//div[@class = 'yui-dt-liner']"); + private final By blogPostTitle = By.cssSelector("div[id*='_blog-postview'] div.nodeTitle>a"); + private final By blogPostContent = By.cssSelector("div[id*='_blog-postview'] div.content"); + private final By blogPostAuthor = By.cssSelector(".published .nodeAttrValue>a"); + private final By blogPostNote = By.cssSelector(".nodeTitle .nodeStatus"); + private final By blogPostListButton = By.cssSelector("div[id*='_blog-postview'] .backLink>a"); + private final By editButton = By.cssSelector(".onEditBlogPost>a"); + private final By deleteButton = By.cssSelector(".onDeleteBlogPost>a"); + private final By addCommentButton = By.cssSelector(".onAddCommentClick button"); + private final By commentAuthorName = By.xpath("//span[@class = 'info']/a"); + private final By editCommentButton = By.xpath("//a[@title='Edit Comment']"); + private final By deleteCommentButton = By.xpath("//a[@title = 'Delete Comment']"); + private final By newPostButton = By.cssSelector("button[id$='_default-create-button-button']"); + @FindAll (@FindBy (css = ".tag>a")) private List blogTags; - private By commentAuthorName = By.xpath("//span[@class = 'info']/a"); - private By editCommentButton = By.xpath("//a[@title='Edit Comment']"); - private By deleteCommentButton = By.xpath("//a[@title = 'Delete Comment']"); public BlogPostViewPage(ThreadLocal webDriver) { @@ -53,80 +44,45 @@ public String getRelativePath() return String.format("share/page/site/%s/blog-postview", getCurrentSiteName()); } - /** - * Method to get the blog post title - * - * @return - */ public String getBlogPostTitle() { - return blogPostTitle.getText(); + return getElementText(blogPostTitle); } - /** - * Method to get the blog post content - * - * @return - */ public String getBlogPostContent() { - return blogPostContent.getText(); + return getElementText(blogPostContent); } - /** - * Method to get the blog post Author name - * - * @return - */ - public String getBlogPostAuthor() { - return blogPostAuthor.getText(); + return getElementText(blogPostAuthor); } - /** - * Method to get the blog post (Draft) note for the blog post that needs to be checked - * - * @return - */ public String getBlogPostNote() { - return blogPostNote.getText(); + return getElementText(blogPostNote); } - /** - * Method to click the blog post list button - * - * @return - */ - public BlogPostListPage clickBlogPostListButton() + public BlogPostListPage navigateBackToBlogList() { - blogPostListButton.click(); + log.info("Navigate back to blog list"); + clickElement(blogPostListButton); return new BlogPostListPage(webDriver); } - /** - * Method to click the New Post button - */ public CreateBlogPostPage clickNewPostButton() { - newPostButton.click(); + clickElement(newPostButton); return new CreateBlogPostPage(webDriver); } - /** - * Method to click the Edit button - */ public EditBlogPostPage clickEditButton() { - editButton.click(); + clickElement(editButton); return new EditBlogPostPage(webDriver); } - /** - * Method to click the Delete button for the selected blog post. The blog post is selected by title - */ - public DeleteDialog clickDeleteButton() { waitUntilElementIsVisible(deleteButton); @@ -134,13 +90,10 @@ public DeleteDialog clickDeleteButton() return new DeleteDialog(webDriver); } - /** - * Method to click the Add Comment button - */ - - public BlogPromptWindow clickAddCommentButton() + public BlogPromptWindow openCommentEditor() { - addCommentButton.click(); + log.info("Open add comment editor"); + clickElement(addCommentButton); return new BlogPromptWindow(webDriver); } @@ -149,11 +102,6 @@ private WebElement selectComment(String user) return findElement(By.xpath("//tr[contains(@class, 'yui-dt-rec ')]//a[text() = '" + user + "']/../..")); } - /** - * Method to get the blog post Tags - * - * @return - */ public List getBlogPostTags() { List tagsList = new ArrayList<>(); @@ -164,37 +112,22 @@ public List getBlogPostTags() return tagsList; } - - /** - * Method to get the Comment author name - */ - public String commentAuthorName(String user) { - return selectComment(user).findElement(commentAuthorName).getText(); + return getElementText(selectComment(user).findElement(commentAuthorName)); } - /** - * Method to get the comment text - */ - public String getCommentText(String user) { - return selectComment(user).findElement(commentText).getText(); + return getElementText(selectComment(user).findElement(commentText)); } - /** - * Method to click on the Edit button for comment - */ public void clickEditComment(String user) { mouseOver(selectComment(user)); clickElement(editCommentButton); } - /** - * Method to click on the Delete button for comment - */ public DeleteDialog clickDeleteComment(String user) { mouseOver(selectComment(user)); @@ -202,12 +135,8 @@ public DeleteDialog clickDeleteComment(String user) return new DeleteDialog(webDriver); } - /** - * Method to get the text displayed for comments when no comments are available - */ - public String getNoCommentsText() { - return noCommentsText.getText(); + return getElementText(noCommentsText); } } \ No newline at end of file diff --git a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/site/blog/BlogPromptWindow.java b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/site/blog/BlogPromptWindow.java index 30be5ad284..d573d36dbd 100644 --- a/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/site/blog/BlogPromptWindow.java +++ b/alfresco-tas-share-test/src/main/java/org/alfresco/po/share/site/blog/BlogPromptWindow.java @@ -1,23 +1,27 @@ package org.alfresco.po.share.site.blog; +import lombok.extern.slf4j.Slf4j; import org.alfresco.po.share.TinyMce.TinyMceEditor; import org.alfresco.po.share.site.SiteCommon; -import org.alfresco.utility.web.annotation.RenderWebElement; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import static org.testng.Assert.assertEquals; + +@Slf4j public class BlogPromptWindow extends SiteCommon { private TinyMceEditor tinyMceEditor; - @RenderWebElement private final By addCommentBoxLabel = By.xpath("//div[@class = 'comment-form']//h2[text()='Add Your Comment...']"); private final By addCommentButton = By.xpath("//button[contains(@id, '_default-add-submit-button')]"); private final By cancelButtonCommentWindow = By.xpath("//button[contains(@id, '_default-add-cancel')]"); private final By saveButtonEditCommentWindow = By.xpath("//button[text()='Save']"); private final By cancelButtonEditCommentWindow = By.xpath("//button[text()='Cancel']"); private final By editCommentBoxLabel = By.xpath("//div[@class = 'comment-form']//h2[text()='Edit Comment...']"); + private final By editorIframe = By.xpath("//div[@class = 'comment-form']//form[contains(@id, '_default-add-form')]//div[@class = 'mce-tinymce mce-container mce-panel']//iframe"); + private final By editor = By.id("tinymce"); public BlogPromptWindow(ThreadLocal webDriver) { @@ -31,24 +35,30 @@ public String getRelativePath() return null; } - public void writeComment(String blogComment) + public BlogPromptWindow writePostComment(String postComment) { - switchTo().frame(findElement(By.xpath( - "//div[@class = 'comment-form']//form[contains(@id, '_default-add-form')]//div[@class = 'mce-tinymce mce-container mce-panel']//iframe"))); - WebElement element = findElement(By.id("tinymce")); - element.clear(); - element.sendKeys(blogComment); + log.info("Write post comment {}", postComment); + switchTo().frame(findElement(editorIframe)); + WebElement addCommentEditor = findElement(editor); + clearAndType(addCommentEditor, postComment); switchTo().defaultContent(); + return this; } - public String getAddCommentLable() + public BlogPromptWindow assertAddCommentLabelEqualsTo(String expectedLabel) { - return getElementText(addCommentBoxLabel); + log.info("Assert Add comment label equals to {}", expectedLabel); + String actualLabel = getElementText(addCommentBoxLabel); + assertEquals(actualLabel, expectedLabel, String.format("Add comment label not equals %s", expectedLabel)); + return this; } - public void clickAddCommentButton() + public BlogPromptWindow addPostComment() { - findElement(addCommentButton).click(); + log.info("Add post comment"); + clickElement(addCommentButton); + waitUntilNotificationMessageDisappears(); + return this; } public void clickCancelOnAddCommentWindow() diff --git a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/AccessBlogTests.java b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/AccessBlogTests.java index fa1e63ca0e..53d7c57cd0 100644 --- a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/AccessBlogTests.java +++ b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/AccessBlogTests.java @@ -144,7 +144,7 @@ public void shouldDisplayBlogPostDetailedView() blogPostListPage .assertBlogAuthorPostEqualsTo(blogTitle, language.translate(AUTHOR_LABEL), authorValue) .assertBlogContentEqualsTo(blogContent) - .assertBlogPostNumberOfRepliesEqualTo(blogTitle, language.translate(ZERO_REPLIES)) + .assertPostNumberOfRepliesEqualTo(blogTitle, language.translate(ZERO_REPLIES)) .assertBlogPostHaveTagEqualsTo(blogTitle, tag); } diff --git a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/BlogPostAddCommentTests.java b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/BlogPostAddCommentTests.java index 8821f2804b..1ee617fda9 100644 --- a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/BlogPostAddCommentTests.java +++ b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/BlogPostAddCommentTests.java @@ -1,118 +1,119 @@ package org.alfresco.share.sitesFeatures.blog; -import java.util.Collections; -import java.util.List; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; import org.alfresco.dataprep.DashboardCustomization.Page; +import org.alfresco.dataprep.SitePagesService; import org.alfresco.dataprep.SiteService; import org.alfresco.po.share.site.blog.BlogPostListPage; import org.alfresco.po.share.site.blog.BlogPostViewPage; import org.alfresco.po.share.site.blog.BlogPromptWindow; -import org.alfresco.share.ContextAwareWebTest; +import org.alfresco.share.BaseTest; import org.alfresco.testrail.TestRail; -import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; -import org.openqa.selenium.By; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; +import org.alfresco.utility.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -public class BlogPostAddCommentTests extends ContextAwareWebTest +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class BlogPostAddCommentTests extends BaseTest { - //@Autowired - BlogPostListPage blogPage; + private final String ADD_YOUR_COMMENT_LABEL = "Add Your Comment..."; + private final String EXPECTED_NUMBER_OF_REPLIES = "1"; - //@Autowired - BlogPostViewPage blogPostView; + @Autowired + private SiteService siteService; - //@Autowired - BlogPromptWindow commentWindow; + @Autowired + protected SitePagesService sitePagesService; - private String user = String.format("C6011User%s", RandomData.getRandomAlphanumeric()); - private String siteName = String.format("C6011SiteName%s", RandomData.getRandomAlphanumeric()); - private String description = String.format("C6011SiteDescription%s", RandomData.getRandomAlphanumeric()); - private String blogPostContentText = "C6011 post content text"; - private List tags = Collections.singletonList("tagc6011"); - private String blogPostTitleC6011 = "C6011 blog post title"; - private String comment = "C6011 comment text"; - private String commentUser = user + " " + user; + private BlogPostViewPage blogPostViewPage; + private BlogPostListPage blogPostListPage; + private BlogPromptWindow blogPromptWindow; - @BeforeClass (alwaysRun = true) + private final ThreadLocal userModel = new ThreadLocal<>(); + private final ThreadLocal siteModel = new ThreadLocal<>(); + + private final String blogTitle = "Blog Title ".concat(randomAlphanumeric(5)); + private final String blogContent = "Blog Content ".concat(randomAlphanumeric(5)); + private final String blogComment = "Blog Comment ".concat(randomAlphanumeric(5)); + private final List noTags = Collections.synchronizedList(new ArrayList<>()); + + @BeforeMethod(alwaysRun = true) public void setupTest() { - userService.create(adminUser, adminPassword, user, password, user + domain, user, user); - siteService.create(user, password, domain, siteName, description, SiteService.Visibility.PUBLIC); - siteService.addPageToSite(user, password, siteName, Page.BLOG, null); - setupAuthenticatedSession(user, password); + userModel.set(getDataUser().usingAdmin().createRandomTestUser()); + siteModel.set(getDataSite().usingUser(userModel.get()).createPublicRandomSite()); + siteService.addPageToSite(userModel.get().getUsername(), userModel.get().getPassword(), + siteModel.get().getId(), Page.BLOG, null); + + authenticateUsingCookies(userModel.get()); + + blogPostViewPage = new BlogPostViewPage(webDriver); + blogPostListPage = new BlogPostListPage(webDriver); + blogPromptWindow = new BlogPromptWindow(webDriver); } - @AfterClass (alwaysRun = true) - public void cleanup() + @TestRail(id = "C6011") + @Test(groups = {TestGroup.SANITY, TestGroup.SITES_FEATURES}) + public void shouldAddCommentToBlogPost() { - userService.delete(adminUser, adminPassword, user); - contentService.deleteTreeByPath(adminUser, adminPassword, "/User Homes/" + user); - siteService.delete(adminUser, adminPassword, siteName); + sitePagesService.createBlogPost(userModel.get().getUsername(), userModel.get().getPassword(), + siteModel.get().getId(), blogTitle, blogContent, false, noTags); + + blogPostListPage + .navigate(siteModel.get()) + .readPost(blogTitle) + .openCommentEditor() + .assertAddCommentLabelEqualsTo(ADD_YOUR_COMMENT_LABEL); + + blogPromptWindow + .writePostComment(blogComment) + .addPostComment(); + + blogPostViewPage + .navigateBackToBlogList() + .assertPostNumberOfRepliesEqualTo(blogTitle, EXPECTED_NUMBER_OF_REPLIES); } - @TestRail (id = "C6011") - @Test (groups = { TestGroup.SANITY, TestGroup.SITES_FEATURES }) - - public void addingACommentToABlogPost() + @TestRail(id = "C6035") + @Test(groups = {TestGroup.SANITY, TestGroup.SITES_FEATURES}) + public void addCommentToDraftBlogPost() { - LOG.info("Preconditions: "); - sitePagesService.createBlogPost(user, password, siteName, blogPostTitleC6011, blogPostContentText, false, tags); - blogPage.navigate(siteName); - getBrowser().waitUntilWebElementIsDisplayedWithRetry(blogPage.selectBlogPostWithTitle(blogPostTitleC6011)); - blogPage.clickReadBlogPost(blogPostTitleC6011); - - LOG.info("Step 1: Click Add comment button"); - blogPostView.clickAddCommentButton(); - Assert.assertEquals(commentWindow.getAddCommentLable(), "Add Your Comment..."); - - LOG.info("Step 2: Type your comment in the Add Your Comment box."); - commentWindow.writeComment(comment); - - LOG.info("Step 3: Click the Add Comment button"); - commentWindow.clickAddCommentButton(); - getBrowser().waitUntilElementVisible(blogPostView.commentText); - - LOG.info("Step 4: Click Blog Post List button"); - - blogPostView.clickBlogPostListButton(); - getBrowser().waitUntilElementIsDisplayedWithRetry(By.xpath("//div[@class='nodeContent']//a[text()='" + blogPostTitleC6011 + "']"), 6); - //getBrowser().waitUntilWebElementIsDisplayedWithRetry(blogPostListPage.selectBlogPostWithtitle(blogPostTitleC6011)); -// Assert.assertEquals(blogPage.assertBlogPostNumberOfRepliesEqualTo(blogPostTitleC6011), "(1)", "Blog Post" + blogPostTitleC6011 + "is not displayed"); + sitePagesService.createBlogPost(userModel.get().getUsername(), userModel.get().getPassword(), + siteModel.get().getId(), blogTitle, blogContent, true, noTags); + + blogPostListPage + .navigate(siteModel.get()) + .navigateToMyDrafts() + .readPost(blogTitle); + + blogPostViewPage + .openCommentEditor() + .assertAddCommentLabelEqualsTo(ADD_YOUR_COMMENT_LABEL) + .writePostComment(blogComment) + .addPostComment(); + + blogPostViewPage + .navigateBackToBlogList() + .navigateToMyDrafts() + .assertPostNumberOfRepliesEqualTo(blogTitle, EXPECTED_NUMBER_OF_REPLIES); + + blogPostListPage + .navigateToAllFilter() + .assertPostNumberOfRepliesEqualTo(blogTitle, EXPECTED_NUMBER_OF_REPLIES); } - @TestRail (id = "C6035") - @Test (groups = { TestGroup.SANITY, TestGroup.SITES_FEATURES }) - - public void addCommentToDraftBlogPost() + @AfterMethod(alwaysRun = true) + public void cleanupTest() { - String blogPostTitleC6035 = "C6035 blog post title"; - sitePagesService.createBlogPost(user, password, siteName, blogPostTitleC6035, blogPostContentText, true, tags); - - blogPage.navigate(siteName); - blogPage.clickMyDraftsFilter(); - blogPage.clickReadBlogPost(blogPostTitleC6035); - - LOG.info("Step 1: Click Add Comment"); - blogPostView.clickAddCommentButton(); - Assert.assertEquals(commentWindow.getAddCommentLable(), "Add Your Comment..."); - - LOG.info("Step 2: Type your comment in the Add Your Comment box."); - commentWindow.writeComment(comment); - - LOG.info("Step 3: Click the Add Comment button"); - commentWindow.clickAddCommentButton(); - getBrowser().waitUntilElementVisible(blogPostView.commentText); - - LOG.info("Step 4: Click Blog Post List button and My Drafts"); - blogPostView.clickBlogPostListButton(); - blogPage.clickMyDraftsFilter(); -// Assert.assertEquals(blogPage.assertBlogPostNumberOfRepliesEqualTo(blogPostTitleC6035), "(1)"); - blogPage.clickAllFilter(); -// Assert.assertEquals(blogPage.assertBlogPostNumberOfRepliesEqualTo(blogPostTitleC6035), "(1)"); + deleteUsersIfNotNull(userModel.get()); + deleteSitesIfNotNull(siteModel.get()); } } diff --git a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/BlogPostEditCommentsTests.java b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/BlogPostEditCommentsTests.java index 471735bec5..b389746e4e 100644 --- a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/BlogPostEditCommentsTests.java +++ b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/BlogPostEditCommentsTests.java @@ -13,7 +13,6 @@ import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.TestGroup; import org.openqa.selenium.By; -import org.springframework.beans.factory.annotation.Autowired; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -67,7 +66,7 @@ public void editBlogPostComment() sitePagesService.commentBlog(user, password, siteName, blogPostTitleC6061, false, comment); blogPage.navigate(siteName); - blogPage.clickReadBlogPost(blogPostTitleC6061); + blogPage.readPost(blogPostTitleC6061); LOG.info("Step 1: Click Edit to the right of the comment."); blogPostView.clickEditComment(commentUser); @@ -97,8 +96,8 @@ public void editDraftBlogPostComment() LOG.info("Step 1: Click edit for Draft Comment"); blogPage.navigate(siteName); - blogPage.clickMyDraftsFilter(); - blogPage.clickReadBlogPost(blogPostTitleC6062); + blogPage.navigateToMyDrafts(); + blogPage.readPost(blogPostTitleC6062); blogPostView.clickEditComment(commentUser); getBrowser().waitUntilElementVisible(By.xpath("//div[@class = 'comment-form']//h2[text()='Edit Comment...']")); Assert.assertEquals(commentWindow.getEditCommentBoxLabel(), "Edit Comment..."); diff --git a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/BrowsingBlogPostsTests.java b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/BrowsingBlogPostsTests.java index d830b5897d..9e79a74956 100644 --- a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/BrowsingBlogPostsTests.java +++ b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/BrowsingBlogPostsTests.java @@ -76,7 +76,7 @@ public void browseTheBlogPosts() blogPage.navigate(siteName); LOG.info("Step 1: Click the 'All' view."); - blogPage.clickAllFilter(); + blogPage.navigateToAllFilter(); LOG.info("Step 2: Check that all published blog posts are displayed"); assertEquals(blogPage.getPageTitle(), "All Posts"); @@ -94,7 +94,7 @@ public void browseTheBlogPosts() public void browseTheBlogPostsLatestPosts() { blogPage.navigate(siteName); - blogPage.clickAllFilter(); + blogPage.navigateToAllFilter(); LOG.info("Step 1: Click on Latest filter"); blogPage.clickLatestFilter(); @@ -116,7 +116,7 @@ public void browseTheBlogPostsMyDrafts() blogPage.navigate(siteName); LOG.info("Step 1: Click on My Drafts filter"); - blogPage.clickMyDraftsFilter(); + blogPage.navigateToMyDrafts(); LOG.info("Step 2: Check that only the draft blog posts of user1 are displayed"); assertEquals(blogPage.getPageTitle(), "My Draft Posts"); diff --git a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/CreatingABlogPostTests.java b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/CreatingABlogPostTests.java index a2d16c0204..06fdde9d72 100644 --- a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/CreatingABlogPostTests.java +++ b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/CreatingABlogPostTests.java @@ -159,7 +159,7 @@ public void creatingANewDraftPost() Assert.assertFalse(blogPostList.isBlogPostDisplayed(blogPostTitleC5541), "Blog post is displayed on the Blog Post List View"); LOG.info("Step 6: Click the All filter'"); - blogPostList.clickAllFilter(); + blogPostList.navigateToAllFilter(); Assert.assertTrue(blogPostList.isBlogPostDisplayed(blogPostTitleC5541), "Blog post is not displayed on the Blog Post List View when All filter is applied"); } @@ -191,7 +191,7 @@ public void creatingANewBlogPostFromBlogPostView() Assert.assertEquals(blogPostView.getBlogPostTitle(), blogPostTitleC6119); LOG.info("Step 4 : Navigate to blog post list"); - blogPostView.clickBlogPostListButton(); + blogPostView.navigateBackToBlogList(); Assert.assertTrue(blogPostList.isBlogPostDisplayed(blogPostTitleC6119), "Blog Post is not displayed on the blog post list page"); } @@ -219,11 +219,11 @@ public void creatingANewDraftBlogPostFromBlogPostView() Assert.assertEquals(blogPostView.getBlogPostTitle(), blogPostTitleC6120); LOG.info("Step 4: Navigate to blog post list"); - blogPostView.clickBlogPostListButton(); + blogPostView.navigateBackToBlogList(); Assert.assertFalse(blogPostList.isBlogPostDisplayed(blogPostTitleC6120), "Draft blog post is displayed on the Blog Post List page."); LOG.info("Step 5: Click All filter"); - blogPostList.clickAllFilter(); + blogPostList.navigateToAllFilter(); Assert.assertTrue(blogPostList.isBlogPostDisplayed(blogPostTitleC6120), "Draft blog post is not displayed when All filter is applied."); } } diff --git a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/DeletingABlogPostTests.java b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/DeletingABlogPostTests.java index 087ca75fa6..adc662fd97 100644 --- a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/DeletingABlogPostTests.java +++ b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/DeletingABlogPostTests.java @@ -87,7 +87,7 @@ public void deletingADraftBlogPostDirectlyFromBlogPage() List tags = Collections.singletonList("c5957tag"); sitePagesService.createBlogPost(user, password, siteName, blogPostTitleC5957, blogPostContentTextC5957, true, tags); blogPage.navigate(siteName); - blogPage.clickMyDraftsFilter(); + blogPage.navigateToMyDrafts(); LOG.info("Test steps"); LOG.info("Step 1: Click Delete for draft blog post"); @@ -98,7 +98,7 @@ public void deletingADraftBlogPostDirectlyFromBlogPage() LOG.info("Step 2: Click Delete button on the Delete Blog Post prompt"); deleteDialog.clickDelete(); // TODO get popup text for Post Deleted - blogPage.clickMyDraftsFilter(); + blogPage.navigateToMyDrafts(); getBrowser().waitUntilElementContainsText(getBrowser().findElement(By.cssSelector("tbody.yui-dt-message")), "No blog posts found"); Assert.assertEquals(blogPage.assertBlogContentEqualsTo(""), "No blog posts found"); } @@ -124,7 +124,7 @@ public void deletingABlogPostFromBlogPostView() getBrowser().waitUntilElementContainsText(blogPage.pageTitle, "New Posts"); Assert.assertEquals(blogPage.assertBlogContentEqualsTo(""), "No blog posts found"); // TODO get popup text for Post Deleted - blogPage.clickAllFilter(); + blogPage.navigateToAllFilter(); getBrowser().waitUntilElementContainsText(blogPage.pageTitle, "All Posts"); Assert.assertEquals(blogPage.assertBlogContentEqualsTo(""), "No blog posts found"); } @@ -138,8 +138,8 @@ public void deletingABlogDraftPostFromBlogPostView() String blogPostTitleC5967 = "C5967 blog post title"; sitePagesService.createBlogPost(user, password, siteName, blogPostTitleC5967, blogPostContentText, true, tags); blogPage.navigate(siteName); - blogPage.clickMyDraftsFilter(); - blogPage.clickReadBlogPost(blogPostTitleC5967); + blogPage.navigateToMyDrafts(); + blogPage.readPost(blogPostTitleC5967); LOG.info("Test Steps"); LOG.info("Step 1: Click Delete for blog post"); @@ -152,7 +152,7 @@ public void deletingABlogDraftPostFromBlogPostView() getBrowser().waitUntilElementContainsText(blogPage.pageTitle, "New Posts"); Assert.assertEquals(blogPage.getPageTitle(), "New Posts"); Assert.assertEquals(blogPage.assertBlogContentEqualsTo(""), "No blog posts found"); - blogPage.clickMyDraftsFilter(); + blogPage.navigateToMyDrafts(); getBrowser().waitUntilElementContainsText(getBrowser().findElement(By.cssSelector("tbody.yui-dt-message")), "No blog posts found"); Assert.assertEquals(blogPage.assertBlogContentEqualsTo(""), "No blog posts found"); } diff --git a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/DeletingACommentTests.java b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/DeletingACommentTests.java index 4e7a2737c2..a3e077cf4f 100644 --- a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/DeletingACommentTests.java +++ b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/DeletingACommentTests.java @@ -12,7 +12,6 @@ import org.alfresco.testrail.TestRail; import org.alfresco.utility.data.RandomData; import org.alfresco.utility.model.TestGroup; -import org.springframework.beans.factory.annotation.Autowired; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -64,7 +63,7 @@ public void deletingACommentOfABlogPost() sitePagesService.createBlogPost(user, password, siteName, blogPostTitleC6063, blogPostContentText, false, tags); sitePagesService.commentBlog(user, password, siteName, blogPostTitleC6063, false, comment); blogPage.navigate(siteName); - blogPage.clickReadBlogPost(blogPostTitleC6063); + blogPage.readPost(blogPostTitleC6063); LOG.info("Step 1: Click Delete Comment to the right of the comment."); blogPostView.clickDeleteComment(commentUser); @@ -86,8 +85,8 @@ public void deletingACommentOfADraftPost() sitePagesService.commentBlog(user, password, siteName, blogPostTitleC6064, true, comment); blogPage.navigate(siteName); - blogPage.clickMyDraftsFilter(); - blogPage.clickReadBlogPost(blogPostTitleC6064); + blogPage.navigateToMyDrafts(); + blogPage.readPost(blogPostTitleC6064); LOG.info("Step 1: Click Delete Comment to the right of the comment."); blogPostView.clickDeleteComment(commentUser); diff --git a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/EditingABlogPostTests.java b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/EditingABlogPostTests.java index f0961b58b5..4f097f62e5 100644 --- a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/EditingABlogPostTests.java +++ b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/EditingABlogPostTests.java @@ -96,7 +96,7 @@ public void editBlogPostFromBlogPostView() String blogPostTitleC5561 = "C5561 blog post title"; sitePagesService.createBlogPost(user, password, siteName, blogPostTitleC5561, blogPostContentText, false, tags); blogPage.navigate(siteName); - blogPage.clickReadBlogPost(blogPostTitleC5561); + blogPage.readPost(blogPostTitleC5561); LOG.info("Step 1: Click 'Edit' button."); blogPostView.clickEditButton(); @@ -134,7 +134,7 @@ public void editABlogDraftPostDirectlyFromBlogPage() LOG.info("Test steps"); LOG.info("Step 1: Select the draft post and click the Edit button"); - blogPage.clickAllFilter(); + blogPage.navigateToAllFilter(); blogPage.selectBlogPostWithTitle(blogTitle); blogPage.clickEditButton(blogTitle); Assert.assertEquals(editBlogPost.getEditBlogPostPageTitle(), expectedPageTitle); @@ -162,8 +162,8 @@ private void editBlogDraftPostFromBlogPostView() String blogPostTitleC6108 = "C5967 blog post title"; sitePagesService.createBlogPost(user, password, siteName, blogPostTitleC6108, blogPostContentText, true, tags); blogPage.navigate(siteName); - blogPage.clickMyDraftsFilter(); - blogPage.clickReadBlogPost(blogPostTitleC6108); + blogPage.navigateToMyDrafts(); + blogPage.readPost(blogPostTitleC6108); String newTitle = "C6108 edited title"; String newContent = "C6108 edited content"; @@ -206,7 +206,7 @@ public void editABlogDraftPostAndPublishIt() LOG.info("Test steps"); LOG.info("Step 1: Select the draft post and click the Edit button"); - blogPage.clickAllFilter(); + blogPage.navigateToAllFilter(); blogPage.selectBlogPostWithTitle(blogTitle); blogPage.clickEditButton(blogTitle); Assert.assertEquals(editBlogPost.getEditBlogPostPageTitle(), expectedPageTitle); @@ -223,9 +223,9 @@ public void editABlogDraftPostAndPublishIt() Assert.assertEquals(blogPostView.getBlogPostTags(), Arrays.asList("c6110tag", newTag)); LOG.info("Step 3: Go to Blog post list"); - blogPostView.clickBlogPostListButton(); + blogPostView.navigateBackToBlogList(); Assert.assertTrue(blogPage.isBlogPostDisplayed(newTitle), "The blog post is not visible in the Latest view"); - blogPage.clickMyDraftsFilter(); + blogPage.navigateToMyDrafts(); getBrowser().waitUntilElementsVisible(By.xpath("//td[@class = 'yui-dt-empty']//div[text() = 'No blog posts found']")); Assert.assertFalse(blogPage.isBlogPostDisplayed(newTitle), "The blog post is still displayed in My Drafts view"); Assert.assertFalse(blogPage.isBlogPostDisplayed(blogTitle), "The original draft blog post is still displayed in My Drafts view"); diff --git a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/ViewingABlogPostTests.java b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/ViewingABlogPostTests.java index 8eb5222619..6900a83916 100644 --- a/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/ViewingABlogPostTests.java +++ b/alfresco-tas-share-test/src/test/java/org/alfresco/share/sitesFeatures/blog/ViewingABlogPostTests.java @@ -75,12 +75,12 @@ public void viewingABlogPostSmallAmountOfContent() blogPostListPage.navigate(siteName); LOG.info("Step 1: Click 'Read' beneath the Post1."); - blogPostListPage.clickReadBlogPost(blogTitleUser1Published); + blogPostListPage.readPost(blogTitleUser1Published); assertEquals(blogPostViewPage.getBlogPostTitle(), blogTitleUser1Published); assertEquals(blogPostViewPage.getBlogPostContent(), blogContent, "The post view displays the selected blog post entirely."); LOG.info("Step 2: Click 'Blog Post List'."); - blogPostViewPage.clickBlogPostListButton(); + blogPostViewPage.navigateBackToBlogList(); String expectedRelativePath = "share/page/site/" + siteName + "/blog-postlist"; assertEquals(blogPostListPage.getRelativePath(), expectedRelativePath); @@ -94,7 +94,7 @@ public void viewingABlogPostSmallAmountOfContent() LOG.info("Step 5: Go back on Blog page and set view toggle button on 'Detailed View'."); - blogPostViewPage.clickBlogPostListButton(); + blogPostViewPage.navigateBackToBlogList(); assertEquals(blogPostListPage.getBlogPostContent(blogTitleUser1Published), sampleBlogContentDetailedView, "A sample of the content is showing in the blog list."); @@ -110,7 +110,7 @@ public void visibilityOfPublishedDraft() blogPostListPage.navigate(siteName); LOG.info("Step 1: Click 'All' view."); - blogPostListPage.clickAllFilter(); + blogPostListPage.navigateToAllFilter(); assertEquals(blogPostListPage.assertBlogContentEqualsTo(""), "No blog posts found"); assertFalse(blogPostListPage.isBlogPostDisplayed(blogTitleUser2Draft), "Blog post draft of user 2 is visible for user one before it was published"); @@ -118,7 +118,7 @@ public void visibilityOfPublishedDraft() userService.logout(); setupAuthenticatedSession(user2, password); blogPostListPage.navigate(siteName); - blogPostListPage.clickMyDraftsFilter(); + blogPostListPage.navigateToMyDrafts(); Assert.assertTrue(blogPostListPage.isBlogPostDisplayed(blogTitleUser2Draft), "Draft blog post of user 2 is not displayed"); @@ -136,7 +136,7 @@ public void visibilityOfPublishedDraft() userService.logout(); setupAuthenticatedSession(user1, password); blogPostListPage.navigate(siteName); - blogPostListPage.clickAllFilter(); + blogPostListPage.navigateToAllFilter(); // assertEquals(blogPostListPage.getBlogPostTitle(blogPostListPage.getBlogPostTitle(blogTitleUser2Draft)), blogTitleUser2Draft); } }