From 66196cc2acafa8415b56abfcc5cd20137d1cc034 Mon Sep 17 00:00:00 2001 From: araschitor <71637144+araschitor@users.noreply.github.com> Date: Tue, 30 Mar 2021 13:28:02 +0300 Subject: [PATCH] Updated blog post edit comments tests (#96) * 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 * feature/APPS-871: Adjusted helper methods, cleanup the code from unused methods/imports and renamed few methods * feature/APPS-871: Added loggers and cleanup PageObject class * feature/APPS-871: Renamed methods and decoupled chaining methods from different objects * feature/APPS-871: Updated BlogPostEditCommentsTests * Added BlogPostFilters and let only one method which is called filterPostBy(BlogPostFilters filters) * deleted .html file --- ...ommentTests_addCommentToDraftBlogPost.html | 627 ------------------ .../alfresco/po/enums/BlogPostFilters.java | 28 + .../po/share/site/blog/BlogPostListPage.java | 34 +- .../po/share/site/blog/BlogPostViewPage.java | 20 +- .../po/share/site/blog/BlogPromptWindow.java | 55 +- .../blog/BlogPostAddCommentTests.java | 23 +- .../blog/BlogPostEditCommentsTests.java | 177 ++--- .../blog/BrowsingBlogPostsTests.java | 15 +- .../blog/CreatingABlogPostTests.java | 7 +- .../blog/DeletingABlogPostTests.java | 13 +- .../blog/DeletingACommentTests.java | 2 +- .../blog/EditingABlogPostTests.java | 21 +- .../blog/ViewingABlogPostTests.java | 8 +- 13 files changed, 212 insertions(+), 818 deletions(-) delete mode 100644 alfresco-tas-share-test/Test Results - BlogPostAddCommentTests_addCommentToDraftBlogPost.html create mode 100644 alfresco-tas-share-test/src/main/java/org/alfresco/po/enums/BlogPostFilters.java diff --git a/alfresco-tas-share-test/Test Results - BlogPostAddCommentTests_addCommentToDraftBlogPost.html b/alfresco-tas-share-test/Test Results - BlogPostAddCommentTests_addCommentToDraftBlogPost.html deleted file mode 100644 index 9fcb0e9441..0000000000 --- a/alfresco-tas-share-test/Test Results - BlogPostAddCommentTests_addCommentToDraftBlogPost.html +++ /dev/null @@ -1,627 +0,0 @@ - - - - - Test Results — BlogPostAddCommentTests.addCommentToDraftBlogPost - - - - - - - - - -
- -
- -
-
- - - diff --git a/alfresco-tas-share-test/src/main/java/org/alfresco/po/enums/BlogPostFilters.java b/alfresco-tas-share-test/src/main/java/org/alfresco/po/enums/BlogPostFilters.java new file mode 100644 index 0000000000..ad5f78de63 --- /dev/null +++ b/alfresco-tas-share-test/src/main/java/org/alfresco/po/enums/BlogPostFilters.java @@ -0,0 +1,28 @@ +package org.alfresco.po.enums; + +public enum BlogPostFilters +{ + MY_DRAFTS_POSTS("ul.filterLink span.mydrafts>a", "My Draft Posts"), + MY_PUBLISHED_POSTS("ul.filterLink span.mypublished>a", "My Published Posts"), + LATEST_POSTS("ul.filterLink span.new>a", "New Posts"), + ALL_POSTS("ul.filterLink span.all>a", "All Posts"); + + private final String locator; + private final String expectedFilterLabel; + + BlogPostFilters(String locator, String expectedFilterLabel) + { + this.locator = locator; + this.expectedFilterLabel = expectedFilterLabel; + } + + public String getLocator() + { + return locator; + } + + public String getExpectedFilterLabel() + { + return expectedFilterLabel; + } +} 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 3ad7490070..13917fde07 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 @@ -12,6 +12,7 @@ import java.util.List; import java.util.Locale; import lombok.extern.slf4j.Slf4j; +import org.alfresco.po.enums.BlogPostFilters; import org.alfresco.po.share.site.SiteCommon; import org.alfresco.utility.exception.PageOperationException; import org.openqa.selenium.By; @@ -38,19 +39,13 @@ public class BlogPostListPage extends SiteCommon private final By noBlogPostsFound = By.xpath(".//tbody[@class='yui-dt-message']"); private final By simpleViewButton = By.cssSelector("button[id$='_default-simpleView-button-button']"); private final By newPostButton = By.cssSelector("div.new-blog span[id*='_default-create-button']"); - private final By defaultBlogPostList = By.cssSelector("div[id$='_default-postlist']"); 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"); private final String postRowPath = "//tr[contains(@class, 'yui-dt-rec')]//div[@class = 'nodeContent']//span/a[text() = '%s']/../../../.."; @@ -304,32 +299,15 @@ public boolean isBlogPostDisplayed(String title) return isElementDisplayed(getBlogPostRow(title)); } - public BlogPostListPage navigateToAllFilter() + public BlogPostListPage filterPostBy(BlogPostFilters blogPostFilters) { - log.info("Navigate to all filter"); - clickElement(allFilter); + log.info("Filter blog post by {}", blogPostFilters); + By filter = By.cssSelector(blogPostFilters.getLocator()); + clickElement(filter); + waitUntilElementContainsText(listTitle, blogPostFilters.getExpectedFilterLabel()); return this; } - public void clickLatestFilter() - { - clickElement(latestFilter); - waitUntilElementContainsText(listTitle, "New Posts"); - } - - public BlogPostListPage navigateToMyDrafts() - { - clickElement(myDraftsFilter); - waitUntilElementContainsText(listTitle, "My Draft Posts"); - return this; - } - - public void clickMyPublishedFilter() - { - clickElement(myPublished); - waitUntilElementContainsText(listTitle, "My Published Posts"); - } - public void clickTag(String tag) { mouseOver(selectTagsByTagName(tag)); 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 3f7de0c58d..07dedf8602 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 @@ -1,5 +1,7 @@ package org.alfresco.po.share.site.blog; +import static org.testng.Assert.assertEquals; + import java.util.ArrayList; import java.util.List; @@ -15,8 +17,8 @@ @Slf4j public class BlogPostViewPage extends SiteCommon { - public final By commentText = By.cssSelector("div[class ='comment-content'] p"); public final By noCommentsText = By.xpath("//tbody[@class = 'yui-dt-message']//div[@class = 'yui-dt-liner']"); + private final By commentText = By.cssSelector("div[class ='comment-content'] p"); 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"); @@ -25,7 +27,6 @@ public class BlogPostViewPage extends SiteCommon 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']"); @@ -112,18 +113,17 @@ public List getBlogPostTags() return tagsList; } - public String commentAuthorName(String user) - { - return getElementText(selectComment(user).findElement(commentAuthorName)); - } - - public String getCommentText(String user) + public BlogPostViewPage assertCommentEqualsTo(String user, String expectedComment) { - return getElementText(selectComment(user).findElement(commentText)); + log.info("Assert comment equals {}", expectedComment); + String actualComment = getElementText(selectComment(user).findElement(commentText)); + assertEquals(actualComment, expectedComment, String.format("Comment not equals %s ", expectedComment)); + return this; } - public void clickEditComment(String user) + public void openEditCommentEditor(String user) { + log.info("Open edit comment editor"); mouseOver(selectComment(user)); clickElement(editCommentButton); } 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 d573d36dbd..ca247cb8eb 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,5 +1,7 @@ package org.alfresco.po.share.site.blog; +import static org.testng.Assert.assertEquals; + import lombok.extern.slf4j.Slf4j; import org.alfresco.po.share.TinyMce.TinyMceEditor; import org.alfresco.po.share.site.SiteCommon; @@ -7,22 +9,16 @@ 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; - - 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"); + private final String commentBoxLabel = "//div[@class = 'comment-form']//h2[text()='%s']"; + public BlogPromptWindow(ThreadLocal webDriver) { super(webDriver); @@ -31,8 +27,7 @@ public BlogPromptWindow(ThreadLocal webDriver) @Override public String getRelativePath() { - // TODO Auto-generated method stub - return null; + return "Empty relative path!"; } public BlogPromptWindow writePostComment(String postComment) @@ -45,11 +40,11 @@ public BlogPromptWindow writePostComment(String postComment) return this; } - public BlogPromptWindow assertAddCommentLabelEqualsTo(String expectedLabel) + public BlogPromptWindow assertCommentBoxLabelEqualsTo(String expectedLabel) { - 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)); + log.info("Assert comment box label equals to {}", expectedLabel); + String actualLabel = getElementText(By.xpath(String.format(commentBoxLabel, expectedLabel))); + assertEquals(actualLabel, expectedLabel, String.format("Comment box label not equals %s", expectedLabel)); return this; } @@ -61,34 +56,18 @@ public BlogPromptWindow addPostComment() return this; } - public void clickCancelOnAddCommentWindow() + public void saveEditedComment() { - findElement(cancelButtonCommentWindow).click(); - } - - public void clickSaveButtonOnEditComment() - { - findElement(saveButtonEditCommentWindow).click(); - } - - - public void clickCancelButtonOnEditComment() - { - findElement(cancelButtonEditCommentWindow).click(); - } - - public boolean isEditCommentDisplayed() - { - return isElementDisplayed(By.xpath("//div[@class = 'comment-form']//h2[text()='Edit Comment...']")); - } - - public String getEditCommentBoxLabel() - { - return findElement(editCommentBoxLabel).getText(); + log.info("Save edited comment"); + clickElement(saveButtonEditCommentWindow); + waitUntilNotificationMessageDisappears(); } - public void testEditComment(String comment) + public BlogPromptWindow editComment(String comment) { + log.info("Edit comment {}", comment); + TinyMceEditor tinyMceEditor = new TinyMceEditor(webDriver); tinyMceEditor.setText(comment); + return this; } } 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 1ee617fda9..dff8356172 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,10 +1,13 @@ package org.alfresco.share.sitesFeatures.blog; +import static org.alfresco.po.enums.BlogPostFilters.ALL_POSTS; +import static org.alfresco.po.enums.BlogPostFilters.MY_DRAFTS_POSTS; 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.enums.BlogPostFilters; import org.alfresco.po.share.site.blog.BlogPostListPage; import org.alfresco.po.share.site.blog.BlogPostViewPage; import org.alfresco.po.share.site.blog.BlogPromptWindow; @@ -69,11 +72,13 @@ public void shouldAddCommentToBlogPost() blogPostListPage .navigate(siteModel.get()) - .readPost(blogTitle) - .openCommentEditor() - .assertAddCommentLabelEqualsTo(ADD_YOUR_COMMENT_LABEL); + .readPost(blogTitle); + + blogPostViewPage + .openCommentEditor(); blogPromptWindow + .assertCommentBoxLabelEqualsTo(ADD_YOUR_COMMENT_LABEL) .writePostComment(blogComment) .addPostComment(); @@ -91,22 +96,24 @@ public void addCommentToDraftBlogPost() blogPostListPage .navigate(siteModel.get()) - .navigateToMyDrafts() + .filterPostBy(MY_DRAFTS_POSTS) .readPost(blogTitle); blogPostViewPage - .openCommentEditor() - .assertAddCommentLabelEqualsTo(ADD_YOUR_COMMENT_LABEL) + .openCommentEditor(); + + blogPromptWindow + .assertCommentBoxLabelEqualsTo(ADD_YOUR_COMMENT_LABEL) .writePostComment(blogComment) .addPostComment(); blogPostViewPage .navigateBackToBlogList() - .navigateToMyDrafts() + .filterPostBy(MY_DRAFTS_POSTS) .assertPostNumberOfRepliesEqualTo(blogTitle, EXPECTED_NUMBER_OF_REPLIES); blogPostListPage - .navigateToAllFilter() + .filterPostBy(ALL_POSTS) .assertPostNumberOfRepliesEqualTo(blogTitle, EXPECTED_NUMBER_OF_REPLIES); } 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 b389746e4e..c10ef3e0cc 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 @@ -1,115 +1,128 @@ package org.alfresco.share.sitesFeatures.blog; +import static org.alfresco.po.enums.BlogPostFilters.MY_DRAFTS_POSTS; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; + +import java.util.ArrayList; import java.util.Collections; import java.util.List; 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 BlogPostEditCommentsTests extends ContextAwareWebTest +public class BlogPostEditCommentsTests extends BaseTest { - //@Autowired - BlogPostListPage blogPage; - - //@Autowired - BlogPostViewPage blogPostView; - - //@Autowired - BlogPromptWindow commentWindow; - - private String user = String.format("C6061User%s", RandomData.getRandomAlphanumeric()); - private String siteName = String.format("C6061SiteName%s", RandomData.getRandomAlphanumeric()); - private String description = String.format("C6061SiteDescription%s", RandomData.getRandomAlphanumeric()); - private String blogPostContentText = "C6061 post content text"; - private List tags = Collections.singletonList("tagc6011"); - private String blogPostTitleC6061 = "C6061 blog post title"; - private String comment = "C6061 comment text"; - private String commentUser = user + " " + user; - private String editedComment = "C6061 edited comment text"; - - @BeforeClass (alwaysRun = true) + private final String EMPTY_SPACE = " "; + private final String EDIT_COMMENT_LABEL = "Edit Comment..."; + + @Autowired + private SiteService siteService; + + @Autowired + protected SitePagesService sitePagesService; + + private BlogPostListPage blogPostListPage; + private BlogPostViewPage blogPostViewPage; + private BlogPromptWindow blogPromptWindow; + + 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<>()); + + private String fullUsername; + private String editedComment = "Edited Comment".concat(randomAlphanumeric(5)); + + @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); + + fullUsername = userModel.get().getFirstName().concat(EMPTY_SPACE).concat(userModel.get().getLastName()); + + authenticateUsingCookies(userModel.get()); + + blogPostViewPage = new BlogPostViewPage(webDriver); + blogPostListPage = new BlogPostListPage(webDriver); + blogPromptWindow = new BlogPromptWindow(webDriver); } - @AfterClass (alwaysRun = true) - public void cleanup() + @TestRail(id = "C6061") + @Test(groups = {TestGroup.SANITY, TestGroup.SITES_FEATURES}) + public void shouldEditBlogPostComment() { - 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); + + sitePagesService.commentBlog(userModel.get().getUsername(), userModel.get().getPassword(), + siteModel.get().getId(), blogTitle, false, blogComment); + blogPostListPage + .navigate(siteModel.get()) + .readPost(blogTitle); - @TestRail (id = "C6061") - @Test (groups = { TestGroup.SANITY, TestGroup.SITES_FEATURES }) + blogPostViewPage + .openEditCommentEditor(fullUsername); - public void editBlogPostComment() + blogPromptWindow + .assertCommentBoxLabelEqualsTo(EDIT_COMMENT_LABEL) + .editComment(editedComment) + .saveEditedComment(); + + blogPostViewPage + .assertCommentEqualsTo(fullUsername, editedComment); + } + + @TestRail(id = "C6062") + @Test(groups = {TestGroup.SANITY, TestGroup.SITES_FEATURES}) + public void shouldEditDraftBlogPostComment() { - sitePagesService.createBlogPost(user, password, siteName, blogPostTitleC6061, blogPostContentText, false, tags); - sitePagesService.commentBlog(user, password, siteName, blogPostTitleC6061, false, comment); + sitePagesService.createBlogPost(userModel.get().getUsername(), userModel.get().getPassword(), + siteModel.get().getId(), blogTitle, blogContent, true, noTags); - blogPage.navigate(siteName); - blogPage.readPost(blogPostTitleC6061); + sitePagesService.commentBlog(userModel.get().getUsername(), userModel.get().getPassword(), + siteModel.get().getId(), blogTitle, true, blogComment); - LOG.info("Step 1: Click Edit to the right of the comment."); - blogPostView.clickEditComment(commentUser); - getBrowser().waitUntilElementVisible(By.xpath("//div[@class = 'comment-form']//h2[text()='Edit Comment...']")); - Assert.assertEquals(commentWindow.getEditCommentBoxLabel(), "Edit Comment..."); + blogPostListPage + .navigate(siteModel.get()) + .filterPostBy(MY_DRAFTS_POSTS) + .readPost(blogTitle); - LOG.info("Step 2: Type your comment in the Add Your Comment box."); - commentWindow.testEditComment(editedComment); + blogPostViewPage + .openEditCommentEditor(fullUsername); - LOG.info("Step 3: Click the Save button"); - commentWindow.clickSaveButtonOnEditComment(); - getBrowser().waitUntilElementVisible(blogPostView.commentText); - Assert.assertEquals(blogPostView.getCommentText(commentUser), editedComment); - } + blogPromptWindow + .assertCommentBoxLabelEqualsTo(EDIT_COMMENT_LABEL) + .editComment(editedComment) + .saveEditedComment(); - @TestRail (id = "C6062") - @Test (groups = { TestGroup.SANITY, TestGroup.SITES_FEATURES }) + blogPostViewPage + .assertCommentEqualsTo(fullUsername, editedComment); + } - public void editDraftBlogPostComment() + @AfterMethod(alwaysRun = true) + public void cleanupTest() { - LOG.info("Test setup"); - String blogPostTitleC6062 = "C6062 Blog post title"; - String commentC6062 = "C6062 Comment"; - String C6062editedComment = "C6062 edited comment"; - sitePagesService.createBlogPost(user, password, siteName, blogPostTitleC6062, blogPostContentText, true, tags); - sitePagesService.commentBlog(user, password, siteName, blogPostTitleC6062, true, commentC6062); - - LOG.info("Step 1: Click edit for Draft Comment"); - blogPage.navigate(siteName); - 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..."); - - LOG.info("Step 2: Type your comment in the Add Your Comment box."); - commentWindow.testEditComment(C6062editedComment); - - LOG.info("Step 3: Click the Save button"); - commentWindow.clickSaveButtonOnEditComment(); - getBrowser().waitUntilElementVisible(blogPostView.commentText); - getBrowser().waitUntilElementContainsText(getBrowser().findElement(blogPostView.commentText), C6062editedComment); - Assert.assertEquals(blogPostView.getCommentText(commentUser), C6062editedComment); + deleteSitesIfNotNull(siteModel.get()); + deleteUsersIfNotNull(userModel.get()); } - } 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 9e79a74956..c4a5c6bf0e 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 @@ -1,5 +1,9 @@ package org.alfresco.share.sitesFeatures.blog; +import static org.alfresco.po.enums.BlogPostFilters.ALL_POSTS; +import static org.alfresco.po.enums.BlogPostFilters.LATEST_POSTS; +import static org.alfresco.po.enums.BlogPostFilters.MY_DRAFTS_POSTS; +import static org.alfresco.po.enums.BlogPostFilters.MY_PUBLISHED_POSTS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -10,6 +14,7 @@ import org.alfresco.dataprep.DashboardCustomization.Page; import org.alfresco.dataprep.SiteService; +import org.alfresco.po.enums.BlogPostFilters; import org.alfresco.po.share.site.blog.BlogPostListPage; import org.alfresco.share.ContextAwareWebTest; import org.alfresco.testrail.TestRail; @@ -76,7 +81,7 @@ public void browseTheBlogPosts() blogPage.navigate(siteName); LOG.info("Step 1: Click the 'All' view."); - blogPage.navigateToAllFilter(); + blogPage.filterPostBy(ALL_POSTS); LOG.info("Step 2: Check that all published blog posts are displayed"); assertEquals(blogPage.getPageTitle(), "All Posts"); @@ -94,10 +99,10 @@ public void browseTheBlogPosts() public void browseTheBlogPostsLatestPosts() { blogPage.navigate(siteName); - blogPage.navigateToAllFilter(); + blogPage.filterPostBy(ALL_POSTS); LOG.info("Step 1: Click on Latest filter"); - blogPage.clickLatestFilter(); + blogPage.filterPostBy(LATEST_POSTS); LOG.info("Step 2: Check that only published blog posts are displayed. Drafts should not be displayed"); assertEquals(blogPage.getPageTitle(), "New Posts"); @@ -116,7 +121,7 @@ public void browseTheBlogPostsMyDrafts() blogPage.navigate(siteName); LOG.info("Step 1: Click on My Drafts filter"); - blogPage.navigateToMyDrafts(); + blogPage.filterPostBy(MY_DRAFTS_POSTS); LOG.info("Step 2: Check that only the draft blog posts of user1 are displayed"); assertEquals(blogPage.getPageTitle(), "My Draft Posts"); @@ -133,7 +138,7 @@ public void browseTheBlogPostsMyPublishedPosts() blogPage.navigate(siteName); LOG.info("Step 1: Click on My Published Filter"); - blogPage.clickMyPublishedFilter(); + blogPage.filterPostBy(MY_PUBLISHED_POSTS); LOG.info("Step 2 : Check that only blog posts published by User1 are displayed"); assertEquals(blogPage.getPageTitle(), "My Published 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 06fdde9d72..dde4af4502 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 @@ -1,9 +1,12 @@ package org.alfresco.share.sitesFeatures.blog; +import static org.alfresco.po.enums.BlogPostFilters.ALL_POSTS; + import java.util.Collections; import org.alfresco.dataprep.DashboardCustomization.Page; import org.alfresco.dataprep.SiteService; +import org.alfresco.po.enums.BlogPostFilters; import org.alfresco.po.share.site.blog.BlogPostListPage; import org.alfresco.po.share.site.blog.BlogPostViewPage; import org.alfresco.po.share.site.blog.CreateBlogPostPage; @@ -159,7 +162,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.navigateToAllFilter(); + blogPostList.filterPostBy(ALL_POSTS); Assert.assertTrue(blogPostList.isBlogPostDisplayed(blogPostTitleC5541), "Blog post is not displayed on the Blog Post List View when All filter is applied"); } @@ -223,7 +226,7 @@ public void creatingANewDraftBlogPostFromBlogPostView() Assert.assertFalse(blogPostList.isBlogPostDisplayed(blogPostTitleC6120), "Draft blog post is displayed on the Blog Post List page."); LOG.info("Step 5: Click All filter"); - blogPostList.navigateToAllFilter(); + blogPostList.filterPostBy(ALL_POSTS); 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 adc662fd97..7171192c8c 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 @@ -1,10 +1,13 @@ package org.alfresco.share.sitesFeatures.blog; +import static org.alfresco.po.enums.BlogPostFilters.ALL_POSTS; + import java.util.Collections; import java.util.List; import org.alfresco.dataprep.DashboardCustomization.Page; import org.alfresco.dataprep.SiteService; +import org.alfresco.po.enums.BlogPostFilters; import org.alfresco.po.share.DeleteDialog; import org.alfresco.po.share.site.blog.BlogPostListPage; import org.alfresco.po.share.site.blog.BlogPostViewPage; @@ -87,7 +90,7 @@ public void deletingADraftBlogPostDirectlyFromBlogPage() List tags = Collections.singletonList("c5957tag"); sitePagesService.createBlogPost(user, password, siteName, blogPostTitleC5957, blogPostContentTextC5957, true, tags); blogPage.navigate(siteName); - blogPage.navigateToMyDrafts(); +// blogPage.filterPostBy(); LOG.info("Test steps"); LOG.info("Step 1: Click Delete for draft blog post"); @@ -98,7 +101,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.navigateToMyDrafts(); +// blogPage.filterPostBy(); getBrowser().waitUntilElementContainsText(getBrowser().findElement(By.cssSelector("tbody.yui-dt-message")), "No blog posts found"); Assert.assertEquals(blogPage.assertBlogContentEqualsTo(""), "No blog posts found"); } @@ -124,7 +127,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.navigateToAllFilter(); + blogPage.filterPostBy(ALL_POSTS); getBrowser().waitUntilElementContainsText(blogPage.pageTitle, "All Posts"); Assert.assertEquals(blogPage.assertBlogContentEqualsTo(""), "No blog posts found"); } @@ -138,7 +141,7 @@ public void deletingABlogDraftPostFromBlogPostView() String blogPostTitleC5967 = "C5967 blog post title"; sitePagesService.createBlogPost(user, password, siteName, blogPostTitleC5967, blogPostContentText, true, tags); blogPage.navigate(siteName); - blogPage.navigateToMyDrafts(); +// blogPage.filterPostBy(); blogPage.readPost(blogPostTitleC5967); LOG.info("Test Steps"); @@ -152,7 +155,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.navigateToMyDrafts(); +// blogPage.filterPostBy(); 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 a3e077cf4f..fd16cfd3ac 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 @@ -85,7 +85,7 @@ public void deletingACommentOfADraftPost() sitePagesService.commentBlog(user, password, siteName, blogPostTitleC6064, true, comment); blogPage.navigate(siteName); - blogPage.navigateToMyDrafts(); +// blogPage.filterPostBy(); blogPage.readPost(blogPostTitleC6064); LOG.info("Step 1: Click Delete Comment to the right of the comment."); 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 4f097f62e5..6a1f3f30b3 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 @@ -1,11 +1,14 @@ package org.alfresco.share.sitesFeatures.blog; +import static org.alfresco.po.enums.BlogPostFilters.ALL_POSTS; + import java.util.Arrays; import java.util.Collections; import java.util.List; import org.alfresco.dataprep.DashboardCustomization.Page; import org.alfresco.dataprep.SiteService; +import org.alfresco.po.enums.BlogPostFilters; import org.alfresco.po.share.site.blog.BlogPostListPage; import org.alfresco.po.share.site.blog.BlogPostViewPage; import org.alfresco.po.share.site.blog.EditBlogPostPage; @@ -134,7 +137,7 @@ public void editABlogDraftPostDirectlyFromBlogPage() LOG.info("Test steps"); LOG.info("Step 1: Select the draft post and click the Edit button"); - blogPage.navigateToAllFilter(); + blogPage.filterPostBy(ALL_POSTS); blogPage.selectBlogPostWithTitle(blogTitle); blogPage.clickEditButton(blogTitle); Assert.assertEquals(editBlogPost.getEditBlogPostPageTitle(), expectedPageTitle); @@ -161,9 +164,9 @@ private void editBlogDraftPostFromBlogPostView() LOG.info("Test Setup"); String blogPostTitleC6108 = "C5967 blog post title"; sitePagesService.createBlogPost(user, password, siteName, blogPostTitleC6108, blogPostContentText, true, tags); - blogPage.navigate(siteName); - blogPage.navigateToMyDrafts(); - blogPage.readPost(blogPostTitleC6108); +// blogPage.navigate(siteName); +// blogPage.filterPostBy(); +// blogPage.readPost(blogPostTitleC6108); String newTitle = "C6108 edited title"; String newContent = "C6108 edited content"; @@ -202,13 +205,13 @@ public void editABlogDraftPostAndPublishIt() String newContent = "C6110 edited content"; String newTag = "c6110editedtag"; sitePagesService.createBlogPost(user, password, siteName, blogTitle, blogContent, true, tags); - blogPage.navigate(siteName); +// blogPage.navigate(siteName); LOG.info("Test steps"); LOG.info("Step 1: Select the draft post and click the Edit button"); - blogPage.navigateToAllFilter(); - blogPage.selectBlogPostWithTitle(blogTitle); - blogPage.clickEditButton(blogTitle); +// blogPage.navigateToAllFilter(); +// blogPage.selectBlogPostWithTitle(blogTitle); +// blogPage.clickEditButton(blogTitle); Assert.assertEquals(editBlogPost.getEditBlogPostPageTitle(), expectedPageTitle); LOG.info("Step 2: Update title, content, tag then click Publish Internally button."); @@ -225,7 +228,7 @@ public void editABlogDraftPostAndPublishIt() LOG.info("Step 3: Go to Blog post list"); blogPostView.navigateBackToBlogList(); Assert.assertTrue(blogPage.isBlogPostDisplayed(newTitle), "The blog post is not visible in the Latest view"); - blogPage.navigateToMyDrafts(); +// blogPage.filterPostBy(); 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 6900a83916..ae3c9d7765 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 @@ -1,5 +1,6 @@ package org.alfresco.share.sitesFeatures.blog; +import static org.alfresco.po.enums.BlogPostFilters.ALL_POSTS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -8,6 +9,7 @@ import org.alfresco.dataprep.DashboardCustomization.Page; import org.alfresco.dataprep.SiteService; +import org.alfresco.po.enums.BlogPostFilters; import org.alfresco.po.share.site.blog.BlogPostListPage; import org.alfresco.po.share.site.blog.BlogPostViewPage; import org.alfresco.po.share.site.blog.EditBlogPostPage; @@ -110,7 +112,7 @@ public void visibilityOfPublishedDraft() blogPostListPage.navigate(siteName); LOG.info("Step 1: Click 'All' view."); - blogPostListPage.navigateToAllFilter(); + blogPostListPage.filterPostBy(ALL_POSTS); 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 +120,7 @@ public void visibilityOfPublishedDraft() userService.logout(); setupAuthenticatedSession(user2, password); blogPostListPage.navigate(siteName); - blogPostListPage.navigateToMyDrafts(); +// blogPostListPage.filterPostBy(); Assert.assertTrue(blogPostListPage.isBlogPostDisplayed(blogTitleUser2Draft), "Draft blog post of user 2 is not displayed"); @@ -136,7 +138,7 @@ public void visibilityOfPublishedDraft() userService.logout(); setupAuthenticatedSession(user1, password); blogPostListPage.navigate(siteName); - blogPostListPage.navigateToAllFilter(); + blogPostListPage.filterPostBy(ALL_POSTS); // assertEquals(blogPostListPage.getBlogPostTitle(blogPostListPage.getBlogPostTitle(blogTitleUser2Draft)), blogTitleUser2Draft); } }