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

File VersionTest.java

 

Code metrics

0
24
2
1
122
59
2
0.08
12
2
1

Classes

Class Line # Actions
VersionTest 37 24 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

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.test.ui;
21   
22    import org.junit.Assert;
23    import org.junit.Rule;
24    import org.junit.Test;
25    import org.xwiki.test.ui.browser.IgnoreBrowser;
26    import org.xwiki.test.ui.browser.IgnoreBrowsers;
27    import org.xwiki.test.ui.po.HistoryPane;
28    import org.xwiki.test.ui.po.ViewPage;
29    import org.xwiki.test.ui.po.editor.WikiEditPage;
30   
31    /**
32    * Verify versioning features of documents and attachments.
33    *
34    * @version $Id: 10c8fc668134ef7d1efba61352a545c7a8a2bab8 $
35    * @since 3.1M2
36    */
 
37    public class VersionTest extends AbstractTest
38    {
39    @Rule
40    public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil());
41   
42    private static final String PAGE_NAME = "HistoryTest";
43   
44    private static final String SPACE_NAME = "HistorySpaceTest";
45   
46    private static final String TITLE = "Page Title";
47   
48    private static final String CONTENT1 = "First version of Content";
49   
50    private static final String CONTENT2 = "Second version of Content";
51   
 
52  1 toggle @Test
53    @IgnoreBrowsers({
54    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See http://jira.xwiki.org/browse/XE-1146"),
55    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See http://jira.xwiki.org/browse/XE-1177")
56    })
57    public void testRollbackToFirstVersion() throws Exception
58    {
59  1 getUtil().rest().deletePage(SPACE_NAME, PAGE_NAME);
60   
61    // Create first version of the page
62  1 ViewPage vp = getUtil().createPage(SPACE_NAME, PAGE_NAME, CONTENT1, TITLE);
63   
64    // Adds second version
65  1 WikiEditPage wikiEditPage = vp.editWiki();
66  1 wikiEditPage.setContent(CONTENT2);
67  1 wikiEditPage.clickSaveAndView();
68   
69    // TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
70    // view mode) is fixed.
71  1 vp.waitForDocExtraPaneActive("comments");
72   
73    // Verify that we can rollback to the first version
74  1 HistoryPane historyTab = vp.openHistoryDocExtraPane();
75  1 vp = historyTab.rollbackToVersion("1.1");
76   
77    // Rollback doesn't wait...
78    // Wait for the comment tab to be selected since we're currently on the history tab and rolling
79    // back is going to load a new page and make the focus active on the comments tab.
80  1 vp.waitForDocExtraPaneActive("comments");
81   
82  1 Assert.assertEquals("First version of Content", vp.getContent());
83   
84  1 historyTab = vp.openHistoryDocExtraPane();
85  1 Assert.assertEquals("Rollback to version 1.1", historyTab.getCurrentVersionComment());
86  1 Assert.assertEquals("Administrator", historyTab.getCurrentAuthor());
87    }
88   
89    /**
90    * See XWIKI-8781
91    */
 
92  1 toggle @Test
93    @IgnoreBrowsers({
94    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See http://jira.xwiki.org/browse/XE-1146"),
95    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See http://jira.xwiki.org/browse/XE-1177")
96    })
97    public void testDeleteLatestVersion() throws Exception
98    {
99  1 getUtil().rest().deletePage(SPACE_NAME, PAGE_NAME);
100   
101    // Create first version of the page
102  1 ViewPage vp = getUtil().createPage(SPACE_NAME, PAGE_NAME, CONTENT1, TITLE);
103   
104    // Adds second version
105  1 WikiEditPage wikiEditPage = vp.editWiki();
106  1 wikiEditPage.setContent(CONTENT2);
107  1 wikiEditPage.clickSaveAndView();
108   
109    // TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
110    // view mode) is fixed.
111  1 vp.waitForDocExtraPaneActive("comments");
112   
113    // Verify and delete the latest version.
114  1 HistoryPane historyTab = vp.openHistoryDocExtraPane();
115  1 Assert.assertEquals("2.1", historyTab.getCurrentVersion());
116  1 historyTab = historyTab.deleteVersion("2.1");
117   
118    // Verify that the current version is now the previous one.
119  1 Assert.assertEquals("1.1", historyTab.getCurrentVersion());
120  1 Assert.assertEquals("Administrator", historyTab.getCurrentAuthor());
121    }
122    }