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

File SpacesTest.java

 

Code metrics

0
19
1
1
90
42
1
0.05
19
1
1

Classes

Class Line # Actions
SpacesTest 41 19 0% 1 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.index.test.ui;
21   
22    import org.junit.Test;
23    import org.xwiki.index.test.po.SpaceIndexPage;
24    import org.xwiki.index.test.po.SpacesMacroPage;
25    import org.xwiki.test.ui.AbstractTest;
26    import org.xwiki.test.ui.browser.IgnoreBrowser;
27    import org.xwiki.test.ui.browser.IgnoreBrowsers;
28    import org.xwiki.test.ui.po.LiveTableElement;
29    import org.xwiki.test.ui.po.ViewPage;
30    import org.xwiki.test.ui.po.editor.WYSIWYGEditPage;
31   
32    import static org.junit.Assert.assertEquals;
33    import static org.junit.Assert.assertTrue;
34   
35    /**
36    * Tests the Spaces Macro.
37    *
38    * @version $Id: d5ad2c8f420e2e563c3238fc5be0689d2aa29d41 $
39    * @since 7.0RC1
40    */
 
41    public class SpacesTest extends AbstractTest
42    {
 
43  1 toggle @Test
44    @IgnoreBrowsers({
45    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"),
46    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
47    })
48    public void spacesMacro()
49    {
50    // Create a page with special characters in space name
51    // See XE-1228: Broken links displayed in the Spaces widget if a space name contains a colon
52    // See XE-1298: Spaces macro doesn't list spaces that contain a colon in their name
53  1 String spaceName = getTestClassName() + ":" + getTestMethodName() + "&";
54  1 String referenceEscapedSpaceName = getTestClassName() + "\\:" + getTestMethodName() + "&";
55    // Make sure the new space's WebHome page doesn't exist.
56  1 getUtil().deletePage(spaceName, "WebHome");
57   
58    // Create the new space using the UI and verify it leads to the page being edited in WYSIWYG mode
59  1 SpacesMacroPage macroPage = SpacesMacroPage.gotoPage();
60  1 macroPage.getSpacesMacroPane().createSpace(spaceName).clickCreate();
61  1 WYSIWYGEditPage editPage = new WYSIWYGEditPage();
62   
63    // Verify that space creation uses the space name as the space home page's title
64  1 assertEquals(spaceName, editPage.getDocumentTitle());
65   
66    // Verify that the space created is correct by looking at the generate metadata in the HTML header
67    // (they contain the space reference amongst other data).
68    // Note: the value will be escaped since it is the space reference, not the space name.
69  1 assertEquals(referenceEscapedSpaceName, editPage.getMetaDataValue("space"));
70   
71    // Go back to the Spaces Macro page and verify that the link to space index works
72    // First, save the space's home page
73  1 editPage.clickSaveAndContinue();
74   
75  1 macroPage = SpacesMacroPage.gotoPage();
76  1 macroPage.getSpacesMacroPane().clickSpaceIndex(referenceEscapedSpaceName);
77   
78    // Assert the content of the space index live table.
79  1 LiveTableElement spaceIndexLiveTable = new SpaceIndexPage().getLiveTable();
80  1 spaceIndexLiveTable.waitUntilReady();
81  1 assertEquals(1, spaceIndexLiveTable.getRowCount());
82  1 assertTrue(spaceIndexLiveTable.hasRow("Page", "WebHome"));
83  1 assertTrue(spaceIndexLiveTable.hasRow("Space", referenceEscapedSpaceName));
84   
85    // Go back to the Spaces Macro page and this time verify that the link to the space home page works
86  1 macroPage = SpacesMacroPage.gotoPage();
87  1 ViewPage spaceHomePage = macroPage.getSpacesMacroPane().clickSpaceHome(referenceEscapedSpaceName);
88  1 assertEquals(spaceName, spaceHomePage.getDocumentTitle());
89    }
90    }