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

File EditWikiTest.java

 

Code metrics

0
21
4
1
110
60
4
0.19
5.25
4
1

Classes

Class Line # Actions
EditWikiTest 40 21 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 3 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.apache.commons.lang3.RandomStringUtils;
24    import org.junit.Before;
25    import org.junit.Rule;
26    import org.junit.Test;
27    import org.xwiki.test.ui.browser.IgnoreBrowser;
28    import org.xwiki.test.ui.browser.IgnoreBrowsers;
29    import org.xwiki.test.ui.po.ViewPage;
30    import org.xwiki.test.ui.po.editor.EditPage.Editor;
31    import org.xwiki.test.ui.po.editor.WYSIWYGEditPage;
32    import org.xwiki.test.ui.po.editor.WikiEditPage;
33   
34    /**
35    * Test wiki editing.
36    *
37    * @version $Id: b26a65db968960f97fc5cc7d6e7dd9040cd64fb0 $
38    * @since 2.4M1
39    */
 
40    public class EditWikiTest extends AbstractTest
41    {
42    @Rule
43    public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil());
44   
45    /**
46    * Page used for testing.
47    */
48    private WikiEditPage editPage;
49   
 
50  3 toggle @Before
51    public void setUp() throws Exception
52    {
53  3 getUtil().rest().deletePage(getTestClassName(), getTestMethodName());
54  3 this.editPage = WikiEditPage.gotoPage(getTestClassName(), getTestMethodName());
55    }
56   
57    /** Test that save and continue saves as a minor version. */
 
58  1 toggle @Test
59    public void testSaveAndContinueSavesAsMinorEdit()
60    {
61   
62  1 Assert.assertTrue(this.editPage.isNewDocument());
63  1 this.editPage.setContent("abc1");
64  1 this.editPage.clickSaveAndView();
65  1 Assert.assertEquals("1.1", this.editPage.getMetaDataValue("version"));
66   
67  1 this.editPage = WikiEditPage.gotoPage(getTestClassName(), getTestMethodName());
68  1 Assert.assertFalse(this.editPage.isNewDocument());
69  1 this.editPage.setContent("abc2");
70  1 this.editPage.setMinorEdit(false);
71  1 this.editPage.clickSaveAndContinue();
72  1 this.editPage.clickCancel();
73  1 Assert.assertEquals("1.2", this.editPage.getMetaDataValue("version"));
74    }
75   
76    /**
77    * Tests that the warning about loosing some of the page content when switching to the WYSIWYG editor is not
78    * displayed if the page syntax is xwiki/2.0.
79    */
 
80  1 toggle @Test
81    @IgnoreBrowsers({
82    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"),
83    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
84    })
85    public void testSwitchToWysiwygWithAdvancedContent()
86    {
87    // Place some HTML in the page content.
88  1 this.editPage.setContent("{{html}}<hr/>{{/html}}");
89    // If we are asked to confirm the editor switch then we choose to remain on the wiki editor.
90  1 getDriver().makeConfirmDialogSilent(false);
91    // Switch to WYSIWYG editor.
92  1 WYSIWYGEditPage wysiwygEditPage = this.editPage.editWYSIWYG();
93    // Check that we are indeed in WYSIWYG edit mode.
94  1 Assert.assertEquals(Editor.WYSIWYG, wysiwygEditPage.getEditor());
95    }
96   
97    /**
98    * @see XWIKI-6934: Preview action doesn't displays the page's title
99    */
 
100  1 toggle @Test
101    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146")
102    public void testPreviewDisplaysPageTitle()
103    {
104  1 String title = RandomStringUtils.randomAlphanumeric(3);
105  1 this.editPage.setTitle(title);
106  1 this.editPage.clickPreview();
107    // The preview page has the action buttons but otherwise it is similar to a view page.
108  1 Assert.assertEquals(title, new ViewPage().getDocumentTitle());
109    }
110    }