/xwiki-enterprise-test/xwiki-enterprise-test-ui/src/test/it/org/xwiki/test/ui/EditInlineTest.java
https://github.com/ntallapa/xwiki-enterprise · Java · 132 lines · 88 code · 9 blank · 35 comment · 2 complexity · 306246a6e4255422f9c8aefc1732bb49 MD5 · raw file
- /*
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
- package org.xwiki.test.ui;
- import org.apache.commons.lang.RandomStringUtils;
- import org.junit.Assert;
- import org.junit.Test;
- import org.xwiki.test.po.AbstractAdminAuthenticatedTest;
- import org.xwiki.test.po.administration.ProfileUserProfilePage;
- import org.xwiki.test.po.platform.InlinePage;
- import org.xwiki.test.po.platform.ViewPage;
- import org.xwiki.test.po.platform.editor.WikiEditPage;
- import org.xwiki.test.po.tag.TaggablePage;
- /**
- * Test Inline editing.
- *
- * @version $Id: 51d737b06a52caeb6e3c5fc960d6970a5c2f5bdf $
- * @since 3.0M2
- */
- public class EditInlineTest extends AbstractAdminAuthenticatedTest
- {
- // Note: We're not testing basic inline editing since this is already covered by the User Profile tests
- @Test
- public void testEditButtonTriggersInlineEditing()
- {
- ProfileUserProfilePage pupp = ProfileUserProfilePage.gotoPage("Admin");
- // Clicking edit should perform inline editing.
- pupp.edit();
- pupp.waitForProfileEditionToLoad();
- Assert.assertTrue(new ViewPage().isInlinePage());
- }
- /* See XE-168 */
- @Test
- public void testInlineEditCanChangeTitle()
- {
- String title = RandomStringUtils.randomAlphanumeric(4);
- getUtil().gotoPage("EditInlineTest", "testInlineEditCanChangeTitle", "inline", "title=" + title);
- ViewPage vp = new InlinePage().clickSaveAndView();
- Assert.assertEquals(title, vp.getDocumentTitle());
- }
- /* See XE-168 */
- @Test
- public void testInlineEditCanChangeParent()
- {
- getUtil().gotoPage("EditInlineTest", "testInlineEditCanChangeParent", "inline", "parent=Main.WebHome");
- ViewPage vp = new InlinePage().clickSaveAndView();
- Assert.assertTrue(vp.hasBreadcrumbContent("Wiki Home", false));
- }
- /* See XWIKI-2389 */
- @Test
- public void testInlineEditPreservesTitle()
- {
- String title = RandomStringUtils.randomAlphanumeric(4);
- getUtil().gotoPage("EditInlineTest", "testInlineEditPreservesTitle", "save", "title=" + title);
- ViewPage vp = new ViewPage();
- Assert.assertEquals(title, vp.getDocumentTitle());
- InlinePage ip = vp.editInline();
- ViewPage vp2 = ip.clickSaveAndView();
- Assert.assertEquals(title, vp2.getDocumentTitle());
- }
- /* See XWIKI-2389 */
- @Test
- public void testInlineEditPreservesParent()
- {
- getUtil().gotoPage("EditInlineTest", "testInlineEditPreservesParent", "save", "parent=Blog.WebHome");
- ViewPage vp = new ViewPage();
- Assert.assertTrue(vp.hasBreadcrumbContent("The Wiki Blog", false));
- InlinePage ip = vp.editInline();
- ViewPage vp2 = ip.clickSaveAndView();
- Assert.assertTrue(vp2.hasBreadcrumbContent("The Wiki Blog", false));
- }
- /* See XWIKI-2199 */
- @Test
- public void testInlineEditPreservesTags()
- {
- String tag1 = RandomStringUtils.randomAlphanumeric(4);
- String tag2 = RandomStringUtils.randomAlphanumeric(4);
- getUtil().gotoPage("EditInlineTest", "testInlineEditPreservesTags", "save", "tags=" + tag1 + "|" + tag2);
- TaggablePage taggablePage = new TaggablePage();
- Assert.assertTrue(taggablePage.hasTag(tag1));
- Assert.assertTrue(taggablePage.hasTag(tag2));
- taggablePage.editInline().clickSaveAndView();
- taggablePage = new TaggablePage();
- Assert.assertTrue(taggablePage.hasTag(tag1));
- Assert.assertTrue(taggablePage.hasTag(tag2));
- }
- /**
- * Tests that pages can override the default property display mode using $context.setDisplayMode. See XWIKI-2436.
- */
- @Test
- public void testEditModeCanBeSet()
- {
- String initialContent = null;
- try {
- ProfileUserProfilePage pupp = ProfileUserProfilePage.gotoPage("Admin");
- WikiEditPage wep = pupp.editWiki();
- initialContent = wep.getContent();
- wep.setContent("{{velocity}}$xcontext.setDisplayMode('edit'){{/velocity}}\n" + initialContent);
- wep.clickSaveAndView();
- Assert.assertTrue(getDriver().getPageSource().contains("XWiki.XWikiUsers_0_last_name"));
- } finally {
- if (initialContent != null) {
- getUtil().gotoPage("XWiki", "Admin", "save", "content=" + initialContent);
- }
- }
- }
- }