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

File EditInlineTest.java

 

Code metrics

0
47
6
1
149
87
6
0.13
7.83
6
1

Classes

Class Line # Actions
EditInlineTest 37 47 0% 6 0
1.0100%
 

Contributing tests

This file is covered by 6 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.apache.commons.lang.RandomStringUtils;
23    import org.junit.Assert;
24    import org.junit.Rule;
25    import org.junit.Test;
26    import org.xwiki.tag.test.po.TaggablePage;
27    import org.xwiki.test.ui.browser.IgnoreBrowser;
28    import org.xwiki.test.ui.po.InlinePage;
29    import org.xwiki.test.ui.po.ViewPage;
30   
31    /**
32    * Test Inline editing.
33    *
34    * @version $Id: 43ab8280d3b9c050a469f1d7acab2a79bb421d57 $
35    * @since 3.0M2
36    */
 
37    public class EditInlineTest extends AbstractTest
38    {
39    @Rule
40    public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil());
41   
42    // Note: We're not testing basic inline editing since this is already covered by the User Profile tests
43   
 
44  1 toggle @Test
45    public void testEditButtonTriggersInlineEditing()
46    {
47    // Go to the Admin user profile page and edit it since editing a user profile page is supposed to go in inline
48    // editing by default
49  1 ViewPage vp = getUtil().gotoPage("XWiki", "Admin");
50  1 vp.edit();
51  1 Assert.assertTrue(new ViewPage().isInlinePage());
52    }
53   
54    /* See XE-168 and XWIKI-6992 */
 
55  1 toggle @Test
56    public void testInlineEditCanChangeTitle()
57    {
58  1 String title = RandomStringUtils.randomAlphanumeric(4);
59  1 getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit", "editor=inline&title=" + title);
60  1 InlinePage inlinePage = new InlinePage();
61    // Check if the title specified on the request is properly displayed.
62  1 Assert.assertEquals(title, inlinePage.getDocumentTitle());
63    // Check if the title specified on the request is displayed in the document hierarchy.
64  1 Assert.assertTrue(inlinePage.getBreadcrumbContent().contains(title));
65    // Save the document and check again the displayed title
66  1 ViewPage viewPage = inlinePage.clickSaveAndView();
67  1 Assert.assertEquals(title, viewPage.getDocumentTitle());
68    }
69   
70    /* See XE-168 */
 
71  1 toggle @Test
72    public void testInlineEditCanChangeParent()
73    {
74    // Use the parentchild hierarchy mode to be able to assert the parent.
75  1 getUtil().setHierarchyMode("parentchild");
76   
77  1 getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit", "editor=inline&parent=Main.SomeParent");
78  1 ViewPage vp = new InlinePage().clickSaveAndView();
79   
80    // Check the new parent in the breadcrumbs.
81  1 Assert.assertTrue(vp.hasBreadcrumbContent("SomeParent", false));
82   
83    // Restore the hierarchy mode.
84  1 getUtil().setHierarchyMode("reference");
85    }
86   
87    /* See XWIKI-2389 */
 
88  1 toggle @Test
89    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
90    public void testInlineEditPreservesTitle()
91    {
92  1 String title = RandomStringUtils.randomAlphanumeric(4);
93  1 getUtil().gotoPage(getTestClassName(), getTestMethodName(), "save", "title=" + title);
94  1 ViewPage vp = new ViewPage();
95  1 Assert.assertEquals(title, vp.getDocumentTitle());
96  1 InlinePage ip = vp.editInline();
97  1 ViewPage vp2 = ip.clickSaveAndView();
98  1 Assert.assertEquals(title, vp2.getDocumentTitle());
99    }
100   
101    /* See XWIKI-2389 */
 
102  1 toggle @Test
103    public void testInlineEditPreservesParent()
104    {
105    // Use the parentchild hierarchy mode to be able to assert the parent.
106  1 getUtil().setHierarchyMode("parentchild");
107   
108  1 getUtil().gotoPage(getTestClassName(), getTestMethodName(), "save", "parent=Blog.WebHome");
109  1 ViewPage vp = new ViewPage();
110  1 Assert.assertTrue(vp.hasBreadcrumbContent("Blog", false));
111   
112  1 InlinePage ip = vp.editInline();
113  1 ViewPage vp2 = ip.clickSaveAndView();
114  1 Assert.assertTrue(vp2.hasBreadcrumbContent("Blog", false));
115   
116    // Now try the same in the default hierarchy mode, to make sure the default mode preserves the parent.
117  1 getUtil().setHierarchyMode("reference");
118   
119  1 getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit", "editor=inline");
120  1 InlinePage ip2 = new InlinePage();
121  1 ip2.clickSaveAndView();
122   
123    // Switch again to the parentchild hierarchy mode to be able to assert the parent.
124  1 getUtil().setHierarchyMode("parentchild");
125   
126  1 ViewPage vp3 = getUtil().gotoPage(getTestClassName(), getTestMethodName());
127  1 Assert.assertTrue(vp3.hasBreadcrumbContent("Blog", false));
128   
129    // Restore the hierarchy mode.
130  1 getUtil().setHierarchyMode("reference");
131    }
132   
133    /* See XWIKI-2199 */
 
134  1 toggle @Test
135    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
136    public void testInlineEditPreservesTags()
137    {
138  1 String tag1 = RandomStringUtils.randomAlphanumeric(4);
139  1 String tag2 = RandomStringUtils.randomAlphanumeric(4);
140  1 getUtil().gotoPage(getTestClassName(), getTestMethodName(), "save", "tags=" + tag1 + "%7C" + tag2);
141  1 TaggablePage taggablePage = new TaggablePage();
142  1 Assert.assertTrue(taggablePage.hasTag(tag1));
143  1 Assert.assertTrue(taggablePage.hasTag(tag2));
144  1 taggablePage.editInline().clickSaveAndView();
145  1 taggablePage = new TaggablePage();
146  1 Assert.assertTrue(taggablePage.hasTag(tag1));
147  1 Assert.assertTrue(taggablePage.hasTag(tag2));
148    }
149    }