1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.watchlist.test.ui

File AutoWatchTest.java

 

Code metrics

0
28
2
1
123
59
2
0.07
14
2
1

Classes

Class Line # Actions
AutoWatchTest 35 28 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.watchlist.test.ui;
21   
22    import org.junit.Assert;
23    import org.junit.Before;
24    import org.junit.Test;
25    import org.xwiki.test.ui.AbstractTest;
26    import org.xwiki.test.ui.browser.IgnoreBrowser;
27    import org.xwiki.watchlist.test.po.WatchlistUserProfilePage;
28    import org.xwiki.watchlist.test.po.editor.WatchlistPreferencesEditPage;
29   
30    /**
31    * Tests Watchlist application features.
32    *
33    * @version $Id: 21a3dc1a5566146c834905ea8a2443b0e153538f $
34    */
 
35    public class AutoWatchTest extends AbstractTest
36    {
37   
38    private String testUserName = "TestUser";
39   
40    private String testSpace = testUserName + "Test";
41   
42    private String existingPageName = "existingPage";
43   
 
44  1 toggle @Before
45    public void setUp()
46    {
47  1 getUtil().loginAsSuperAdmin();
48  1 getUtil().createPage(this.testSpace, existingPageName, null, null);
49   
50    // Delete the user if it already exists.
51  1 getUtil().deletePage("XWiki", testUserName);
52   
53  1 getUtil().createUserAndLogin(testUserName, "password");
54    }
55   
 
56  1 toggle @Test
57    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See http://jira.xwiki.org/browse/XE-1177")
58    public void testAutomaticWatchDefaultAndNone()
59    {
60    /*
61    * Scenario 1: 'Default' autowatch mode should watch new and modified documents.
62    */
63  1 WatchlistUserProfilePage watchlistPage = WatchlistUserProfilePage.gotoPage(testUserName);
64   
65  1 String newPageName1 = "testpage";
66   
67    // Ensure the pages are not already watched.
68  1 Assert.assertFalse("The test page should not be already watched when just starting", watchlistPage
69    .getWatchlistMacro().isWatched(this.testSpace, newPageName1));
70  1 Assert.assertFalse("The test page should not be already watched when just starting", watchlistPage
71    .getWatchlistMacro().isWatched(this.testSpace, this.existingPageName));
72   
73    // Set to 'default' automatic watch mode.
74  1 WatchlistPreferencesEditPage preferences = watchlistPage.editPreferences();
75  1 preferences.setAutomaticWatchDefault();
76  1 preferences.clickSaveAndContinue();
77   
78    // Create the new page and modify the existing one.
79  1 getUtil().createPage(this.testSpace, newPageName1, null, null);
80  1 getUtil().gotoPage(this.testSpace, this.existingPageName, "save", "content", "Test content");
81   
82    // Go back to watchlist profile.
83  1 watchlistPage = WatchlistUserProfilePage.gotoPage(testUserName);
84   
85    // Check if they are registered in the watchlist.
86  1 Assert.assertTrue("Newly created page is not watched",
87    watchlistPage.getWatchlistMacro().isWatched(this.testSpace, newPageName1));
88  1 Assert.assertTrue("Newly created page is not watched",
89    watchlistPage.getWatchlistMacro().isWatched(this.testSpace, this.existingPageName));
90   
91    /*
92    * Scenario 2: 'None' autowatch mode should not watch new or modified documents.
93    */
94  1 String newPageName2 = "testpage2";
95   
96    // Cleanup from the previous test. Assume the existing page is unwatched.
97  1 watchlistPage.getWatchlistMacro().unWatch(this.testSpace, this.existingPageName);
98   
99    // Ensure the pages are not already watched.
100  1 Assert.assertFalse("The test page should not be already watched when just starting", watchlistPage
101    .getWatchlistMacro().isWatched(this.testSpace, newPageName2));
102  1 Assert.assertFalse("The test page should not be already watched when just starting", watchlistPage
103    .getWatchlistMacro().isWatched(this.testSpace, this.existingPageName));
104   
105    // Set to 'none' automatic watch mode.
106  1 preferences = watchlistPage.editPreferences();
107  1 preferences.setAutomaticWatchNone();
108  1 preferences.clickSaveAndContinue();
109   
110    // Create the new page and modify the existing one.
111  1 getUtil().createPage(this.testSpace, newPageName2, null, null);
112  1 getUtil().gotoPage(this.testSpace, this.existingPageName, "save", "content", "Test content");
113   
114    // Go back to watchlist profile
115  1 watchlistPage = WatchlistUserProfilePage.gotoPage(testUserName);
116   
117    // Check if it's registered in the watchlist
118  1 Assert.assertFalse("Newly created page is watched even if autowatch is set to 'none'", watchlistPage
119    .getWatchlistMacro().isWatched(this.testSpace, newPageName2));
120  1 Assert.assertFalse("Modified page is watched even if autowatch is set to 'none'", watchlistPage
121    .getWatchlistMacro().isWatched(this.testSpace, this.existingPageName));
122    }
123    }