1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.watchlist.test.ui; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import org.junit.Rule; |
25 |
|
import org.junit.Test; |
26 |
|
import org.xwiki.test.ui.AbstractTest; |
27 |
|
import org.xwiki.test.ui.SuperAdminAuthenticationRule; |
28 |
|
import org.xwiki.user.test.po.NetworkUserProfilePage; |
29 |
|
import org.xwiki.user.test.po.ProfileUserProfilePage; |
30 |
|
|
31 |
|
import static org.junit.Assert.assertEquals; |
32 |
|
import static org.junit.Assert.assertFalse; |
33 |
|
import static org.junit.Assert.assertTrue; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@version |
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 1 |
Complexity Density: 0.05 |
|
40 |
|
public class WatchUsersTest extends AbstractTest |
41 |
|
{ |
42 |
|
@Rule |
43 |
|
public SuperAdminAuthenticationRule superAdminAuthenticationRule = new SuperAdminAuthenticationRule(getUtil()); |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
45 |
1 |
@Test... |
46 |
|
public void testFollowUser() throws Exception |
47 |
|
{ |
48 |
|
|
49 |
1 |
String alice = "Alice"; |
50 |
1 |
getUtil().deletePage("XWiki", alice); |
51 |
1 |
getUtil().createUser(alice, "password", null); |
52 |
|
|
53 |
1 |
String bob = "Bob"; |
54 |
1 |
getUtil().deletePage("XWiki", bob); |
55 |
1 |
getUtil().createUserAndLogin(bob, "password"); |
56 |
|
|
57 |
|
|
58 |
1 |
NetworkUserProfilePage networkPage = NetworkUserProfilePage.gotoPage(bob); |
59 |
1 |
List<String> followedUsers = networkPage.getFollowedUsers(); |
60 |
1 |
assertEquals("The list of followed users should be empty in the start", 0, followedUsers.size()); |
61 |
|
|
62 |
|
|
63 |
1 |
ProfileUserProfilePage profilePage = ProfileUserProfilePage.gotoPage(alice); |
64 |
1 |
assertFalse("Another users should not be followed by default", profilePage.isFollowed()); |
65 |
1 |
profilePage = profilePage.toggleFollowButton(); |
66 |
1 |
assertTrue("After following, the UI should show the unfollow option", profilePage.isFollowed()); |
67 |
|
|
68 |
|
|
69 |
1 |
networkPage = NetworkUserProfilePage.gotoPage(bob); |
70 |
1 |
followedUsers = networkPage.getFollowedUsers(); |
71 |
1 |
assertEquals("There should be 1 user in the list of followed users", 1, followedUsers.size()); |
72 |
1 |
assertTrue("The user Alice should be in the list of followed users", followedUsers.contains(alice)); |
73 |
|
|
74 |
|
|
75 |
1 |
networkPage.unfollowUser(alice); |
76 |
1 |
followedUsers = networkPage.getFollowedUsers(); |
77 |
1 |
assertEquals("There should be no more users in the list of followed users", 0, followedUsers.size()); |
78 |
|
|
79 |
|
|
80 |
1 |
getUtil().deletePage("XWiki", alice); |
81 |
1 |
getUtil().deletePage("XWiki", bob); |
82 |
|
} |
83 |
|
} |