-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathBlogTests.java
More file actions
126 lines (107 loc) · 6.32 KB
/
BlogTests.java
File metadata and controls
126 lines (107 loc) · 6.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.wikia.webdriver.testcases.blogtests;
import java.util.List;
import com.wikia.webdriver.common.core.annotations.InBrowser;
import com.wikia.webdriver.common.core.helpers.Emulator;
import org.joda.time.DateTime;
import org.testng.annotations.Test;
import com.wikia.webdriver.common.contentpatterns.PageContent;
import com.wikia.webdriver.common.core.Assertion;
import com.wikia.webdriver.common.core.annotations.Execute;
import com.wikia.webdriver.common.core.annotations.RelatedIssue;
import com.wikia.webdriver.common.core.api.ArticleContent;
import com.wikia.webdriver.common.core.helpers.User;
import com.wikia.webdriver.common.dataprovider.ArticleDataProvider;
import com.wikia.webdriver.common.templates.NewTestTemplate;
import com.wikia.webdriver.elements.oasis.components.notifications.Notification;
import com.wikia.webdriver.elements.oasis.components.notifications.NotificationType;
import com.wikia.webdriver.pageobjectsfactory.pageobject.UserProfilePage;
import com.wikia.webdriver.pageobjectsfactory.pageobject.actions.DeletePageObject;
import com.wikia.webdriver.pageobjectsfactory.pageobject.actions.RenamePageObject;
import com.wikia.webdriver.pageobjectsfactory.pageobject.article.editmode.VisualEditModePageObject;
import com.wikia.webdriver.pageobjectsfactory.pageobject.special.SpecialCreatePage;
import com.wikia.webdriver.pageobjectsfactory.pageobject.special.SpecialRestorePageObject;
import com.wikia.webdriver.pageobjectsfactory.pageobject.wikipage.blog.BlogPage;
@Test(groups = "BlogTests")
public class BlogTests extends NewTestTemplate {
private static final String USER_BLOG_PATH_FORMAT = "User_blog:%s/%s";
@Execute(asUser = User.BLOGS)
public void UserCanAddBlogFromProfilePage() {
String blogTitle = PageContent.BLOG_POST_NAME_PREFIX + DateTime.now().getMillis();
String blogContent = PageContent.BLOG_CONTENT + DateTime.now().getMillis();
UserProfilePage userProfile = new UserProfilePage().open(User.BLOGS.getUserName());
userProfile.clickOnBlogTab();
SpecialCreatePage createBlogPage = userProfile.clickOnCreateBlogPost();
VisualEditModePageObject visualEditMode = createBlogPage.populateTitleField(blogTitle);
visualEditMode.addContent(blogContent);
BlogPage blogPage = visualEditMode.submitBlog();
blogPage.getBlogTitle();
blogPage.verifyContent(blogContent);
}
@Test(dataProviderClass = ArticleDataProvider.class, dataProvider = "articleTitles")
@Execute(asUser = User.BLOGS)
public void UserCanCreateBlogsWithSpecialCharacters (String blogTitle) {
String blogContent = PageContent.BLOG_CONTENT + DateTime.now().getMillis();
String randomBlogTitle = blogTitle + DateTime.now().getMillis();
SpecialCreatePage createBlogPage = new SpecialCreatePage().open();
VisualEditModePageObject visualEditMode = createBlogPage.populateTitleField(randomBlogTitle);
visualEditMode.addContent(blogContent);
BlogPage blogPage = visualEditMode.submitBlog();
blogPage.getBlogTitle();
blogPage.verifyContent(blogContent);
}
@Execute(asUser = User.BLOGS)
public void UserCanEditBlogPost() {
String blogTitle = PageContent.BLOG_POST_NAME_PREFIX + DateTime.now().getMillis();
String blogContent = PageContent.BLOG_CONTENT + DateTime.now().getMillis();
new ArticleContent(User.BLOGS).push(blogContent,
String.format(USER_BLOG_PATH_FORMAT, User.BLOGS.getUserName(), blogTitle));
BlogPage blogPage = new BlogPage().open(User.BLOGS.getUserName(), blogTitle);
VisualEditModePageObject visualEditMode = blogPage.openCKModeWithMainEditButton();
visualEditMode.addContent(blogContent);
visualEditMode.submitArticle();
blogPage.getBlogTitle();
blogPage.verifyContent(blogContent);
}
@Execute(asUser = User.STAFF_FORUM)
public void StaffCanDeleteAndUndeleteUsersBlogPost() {
String blogTitle = PageContent.BLOG_POST_NAME_PREFIX + DateTime.now().getMillis();
String blogContent = PageContent.BLOG_CONTENT + DateTime.now().getMillis();
new ArticleContent(User.BLOGS).push(blogContent,
String.format(USER_BLOG_PATH_FORMAT, User.BLOGS.getUserName(), blogTitle));
BlogPage blogPage = new BlogPage().open(User.BLOGS.getUserName(), blogTitle);
DeletePageObject deletePage = blogPage.deleteUsingDropdown();
deletePage.submitDeletion();
List<Notification> confirmNotifications = blogPage.getNotifications(NotificationType.CONFIRM);
Assertion.assertEquals(confirmNotifications.size(), 1,
DeletePageObject.AssertionMessages.INVALID_NUMBER_OF_CONFIRMING_NOTIFICATIONS);
SpecialRestorePageObject restore =
blogPage.getNotifications(NotificationType.CONFIRM).stream().findFirst().get().undelete();
restore.giveReason(blogPage.getTimeStamp());
restore.restorePage();
confirmNotifications = blogPage.getNotifications(NotificationType.CONFIRM);
Assertion.assertEquals(confirmNotifications.size(), 1,
SpecialRestorePageObject.AssertionMessages.INVALID_NUMBER_OF_CONFIRMING_NOTIFICATIONS);
Assertion.assertTrue(confirmNotifications.stream().findFirst().get().isVisible(),
SpecialRestorePageObject.AssertionMessages.BANNER_NOTIFICATION_NOT_VISIBLE);
blogPage.getBlogTitle();
}
@Execute(asUser = User.STAFF_FORUM)
@InBrowser(emulator = Emulator.DESKTOP_BREAKPOINT_LARGE)
public void StaffCanMoveUserBlogPosts() {
String blogTitleMove =
"Renamed - " + PageContent.BLOG_POST_NAME_PREFIX + DateTime.now().getMillis();
String blogTitle = PageContent.BLOG_POST_NAME_PREFIX + DateTime.now().getMillis();
String blogContent = PageContent.BLOG_CONTENT + DateTime.now().getMillis();
new ArticleContent(User.BLOGS).push(blogContent,
String.format(USER_BLOG_PATH_FORMAT, User.BLOGS.getUserName(), blogTitle));
BlogPage blogPage = new BlogPage().open(User.BLOGS.getUserName(), blogTitle);
RenamePageObject renamePage = blogPage.renameUsingDropdown();
renamePage.rename(User.STAFF_FORUM.getUserName() + "/" + blogTitleMove, true);
blogPage.getBlogTitle();
List<Notification> confirmNotifications = blogPage.getNotifications(NotificationType.CONFIRM);
Assertion.assertEquals(confirmNotifications.size(), 1,
RenamePageObject.AssertionMessages.INVALID_NUMBER_OF_CONFIRMING_NOTIFICATIONS);
Assertion.assertTrue(confirmNotifications.stream().findFirst().get().isVisible(),
RenamePageObject.AssertionMessages.BANNER_NOTIFICATION_NOT_VISIBLE);
}
}