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

File AllDocsTest.java

 

Code metrics

2
71
1
1
146
83
2
0.03
71
1
2

Classes

Class Line # Actions
AllDocsTest 31 71 0% 2 1
0.986486598.6%
 

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.test.selenium;
21   
22    import org.junit.Assert;
23    import org.junit.Test;
24    import org.xwiki.test.selenium.framework.AbstractXWikiTestCase;
25   
26    /**
27    * Verify the table view for AllDocs wiki document.
28    *
29    * @version $Id: 25f25cbbe718bbb825826de461e2c3b72a3ee7ee $
30    */
 
31    public class AllDocsTest extends AbstractXWikiTestCase
32    {
33    /**
34    * This method makes the following tests :
35    * <ul>
36    * <li>Validate presence of "Actions" column in table view for administrator.</li>
37    * <li>Validate absence of "Actions" column for users without administration rights.</li>
38    * <li>Validate input suggest for Page field.</li>
39    * <li>Validate input suggest for Space field.</li>
40    * <li>Validate input suggest for Last Author field.</li>
41    * <li>Validate Copy link action.</li>
42    * <li>Validate Rename link action.</li>
43    * <li>Validate Delete link action.</li>
44    * <li>Validate Rights link action.</li>
45    * </ul>
46    */
 
47  1 toggle @Test
48    public void testTableViewActions()
49    {
50    // Validate absence of "Actions" column for users without administration rights and verify there are
51    // elements in the table
52  1 open("Main", "AllDocs");
53    // We verify we have a least 2 pages displayed
54  1 waitForTextContains("//span[@class='xwiki-livetable-pagination-content']", "1 2");
55  1 if (isAuthenticated()) {
56  1 logout();
57    }
58  1 assertElementNotPresent("//td[text()='Actions']");
59   
60    // Create a new page that will be used in this test.
61  1 loginAsAdmin();
62  1 String spaceName = this.getClass().getSimpleName();
63  1 String pageName = getTestMethodName();
64  1 open(spaceName, pageName, "edit", "editor=wiki&title=Actions+test");
65  1 clickEditSaveAndContinue();
66   
67    // Validate presence of "Actions" column in table view for administrator.
68  1 open("Main", "AllDocs");
69  1 waitForTextContains("//span[@class='xwiki-livetable-pagination-content']", "1 2");
70  1 assertElementPresent("//th[normalize-space(text())='Actions']");
71   
72    // Validate input suggest for Location field.
73  1 getSelenium().focus("doc.location");
74  1 getSelenium().typeKeys("doc.location", "ViewActions");
75    // Note: We wait on the pagination result since it's the last element updated and it's done after the
76    // table rows have been updated so this allows us to wait on it. In the code below "1" represents the
77    // displayed pages.
78  1 waitForTextPresent("//span[@class='xwiki-livetable-pagination-content']", "1");
79  1 assertElementPresent("//td[contains(@class, 'doc_location')]//a[text()='" + pageName + "']");
80   
81    // Validate input suggest for Last Author field.
82  1 open("Main", "AllDocs");
83  1 waitForTextContains("//span[@class='xwiki-livetable-pagination-content']", "1 2");
84  1 getSelenium().focus("doc.author");
85  1 getSelenium().typeKeys("doc.author", "SomeUnknownAuthor");
86  1 waitForTextPresent("//span[@class='xwiki-livetable-pagination-content']", "");
87  1 assertElementNotPresent("//td[contains(@class, 'doc_location')]//a[text()='" + pageName + "']");
88   
89    // Validate Copy link action.
90  1 open("Main", "AllDocs");
91  1 waitForTextContains("//span[@class='xwiki-livetable-pagination-content']", "1 2");
92  1 getSelenium().focus("doc.location");
93  1 getSelenium().typeKeys("doc.location", "view");
94  1 waitForTextPresent("//span[@class='xwiki-livetable-pagination-content']", "1");
95  1 assertElementPresent("//td[contains(@class, 'doc_location')]//a[text()='" + pageName + "']");
96  1 clickLinkWithLocator("//a[contains(@class, 'actioncopy') and contains(@href, '" + pageName + "')]");
97    // The copy page form doesn't allow us to copy to a new space.
98  1 setFieldValue("targetSpaceName", "Sandbox");
99  1 setFieldValue("targetPageName", pageName + "New");
100  1 clickLinkWithLocator("//input[@value='Copy']");
101  1 open("Main", "AllDocs");
102  1 getSelenium().focus("doc.location");
103  1 getSelenium().typeKeys("doc.location", "Sandbox");
104  1 waitForTextPresent("//span[@class='xwiki-livetable-pagination-content']", "1");
105  1 assertElementPresent("//td[contains(@class, 'doc_location')]//a[text()='" + pageName + "New']");
106   
107    // Validate Rename link action.
108  1 open("Main", "AllDocs");
109  1 waitForTextContains("//span[@class='xwiki-livetable-pagination-content']", "1 2");
110  1 getSelenium().focus("doc.location");
111  1 getSelenium().typeKeys("doc.location", "actionsNew");
112  1 waitForTextPresent("//span[@class='xwiki-livetable-pagination-content']", "1");
113  1 clickLinkWithLocator("//tbody/tr/td/a[text()='rename']");
114  1 setFieldValue("newPageName", pageName + "NewRenamed");
115  1 clickLinkWithLocator("//input[@value='Rename']");
116  1 open("Main", "AllDocs");
117  1 getSelenium().focus("doc.location");
118  1 getSelenium().typeKeys("doc.location", "renamed");
119  1 waitForTextPresent("//span[@class='xwiki-livetable-pagination-content']", "1");
120  1 assertElementPresent("//td[contains(@class, 'doc_location')]//a[text()='" + pageName + "NewRenamed']");
121   
122    // Validate Delete link action.
123  1 open("Main", "AllDocs");
124  1 waitForTextContains("//span[@class='xwiki-livetable-pagination-content']", "1 2");
125  1 getSelenium().focus("doc.location");
126  1 getSelenium().typeKeys("doc.location", "renamed");
127  1 waitForTextPresent("//span[@class='xwiki-livetable-pagination-content']", "1");
128  1 clickLinkWithLocator("//tbody/tr/td/a[text()='delete']");
129  1 clickLinkWithLocator("//button[contains(text(), 'Yes')]");
130  1 assertTextPresent("The page has been deleted.");
131  1 open("Main", "AllDocs");
132  1 getSelenium().focus("doc.location");
133  1 getSelenium().typeKeys("doc.location", "actions");
134  1 waitForTextPresent("//span[@class='xwiki-livetable-pagination-content']", "1");
135  1 assertElementNotPresent("//td[contains(@class, 'doc_location')]//a[text()='" + pageName + "NewRenamed']");
136   
137    // Validate Rights link action.
138  1 open("Main", "AllDocs");
139  1 waitForTextContains("//span[@class='xwiki-livetable-pagination-content']", "1 2");
140  1 getSelenium().focus("doc.location");
141  1 getSelenium().typeKeys("doc.location", pageName);
142  1 waitForTextPresent("//span[@class='xwiki-livetable-pagination-content']", "1");
143  1 clickLinkWithLocator("//tbody/tr/td/a[text()='rights']");
144  1 Assert.assertEquals("Editing access rights for Actions test", getTitle());
145    }
146    }