1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.index.test.ui; |
21 |
|
|
22 |
|
import java.io.ByteArrayInputStream; |
23 |
|
import java.util.Arrays; |
24 |
|
import java.util.List; |
25 |
|
|
26 |
|
import org.junit.Assert; |
27 |
|
import org.junit.Test; |
28 |
|
import org.openqa.selenium.By; |
29 |
|
import org.openqa.selenium.WebElement; |
30 |
|
import org.xwiki.index.test.po.AllDocsPage; |
31 |
|
import org.xwiki.index.tree.test.po.DocumentTreeElement; |
32 |
|
import org.xwiki.test.ui.AbstractTest; |
33 |
|
import org.xwiki.test.ui.TestUtils; |
34 |
|
import org.xwiki.test.ui.browser.IgnoreBrowser; |
35 |
|
import org.xwiki.test.ui.browser.IgnoreBrowsers; |
36 |
|
import org.xwiki.test.ui.po.LiveTableElement; |
37 |
|
import org.xwiki.tree.test.po.TreeNodeElement; |
38 |
|
|
39 |
|
import static org.junit.Assert.assertEquals; |
40 |
|
import static org.junit.Assert.assertFalse; |
41 |
|
import static org.junit.Assert.assertTrue; |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
@version |
47 |
|
@since |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (71) |
Complexity: 6 |
Complexity Density: 0.09 |
|
49 |
|
public class AllDocsTest extends AbstractTest |
50 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
51 |
1 |
@Test... |
52 |
|
public void tableViewTabActions() throws Exception |
53 |
|
{ |
54 |
|
|
55 |
|
|
56 |
1 |
getUtil().createUserAndLogin(getTestClassName() + "_" + getTestMethodName(), "password"); |
57 |
1 |
AllDocsPage page = AllDocsPage.gotoPage(); |
58 |
1 |
LiveTableElement livetable = page.clickIndexTab(); |
59 |
1 |
assertTrue("No Actions column found", livetable.hasColumn("Actions")); |
60 |
|
|
61 |
|
|
62 |
1 |
getUtil().forceGuestUser(); |
63 |
|
|
64 |
1 |
page = AllDocsPage.gotoPage(); |
65 |
1 |
livetable = page.clickIndexTab(); |
66 |
1 |
assertFalse("Actions column shouldn't be visible for guests", livetable.hasColumn("Actions")); |
67 |
|
|
68 |
|
|
69 |
1 |
livetable = page.clickIndexTab(); |
70 |
1 |
livetable.filterColumn("xwiki-livetable-alldocs-filter-2", getTestMethodName()); |
71 |
|
|
72 |
1 |
assertEquals(1, livetable.getRowCount()); |
73 |
1 |
assertTrue(livetable.hasRow("Title", getTestClassName() + "_" + getTestMethodName())); |
74 |
|
} |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
76 |
1 |
@Test... |
77 |
|
public void recycleBinTab() throws Exception |
78 |
|
{ |
79 |
1 |
getUtil().loginAsSuperAdminAndGotoPage(AllDocsPage.getURL()); |
80 |
1 |
AllDocsPage page = new AllDocsPage(); |
81 |
1 |
assertTrue("Deleted documents tab is not visible to Admin", page.hasDeletedDocsTab()); |
82 |
1 |
assertTrue("Deleted attachments tab is not visible to Admin", page.hasDeletedAttachmentsTab()); |
83 |
|
|
84 |
|
|
85 |
1 |
getUtil().forceGuestUser(); |
86 |
|
|
87 |
1 |
assertFalse("Deleted documents shouldn't be visible to guests", page.hasDeletedDocsTab()); |
88 |
1 |
assertFalse("Deleted attachments shouldn't be visible to guests", page.hasDeletedAttachmentsTab()); |
89 |
|
|
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
95 |
1 |
@Test... |
96 |
|
public void treeViewTab() throws Exception |
97 |
|
{ |
98 |
|
|
99 |
1 |
String spaceName = getTestMethodName(); |
100 |
1 |
getUtil().createPage(spaceName, "WebHome", null, null); |
101 |
1 |
getUtil().createPageWithAttachment(Arrays.asList(spaceName, "A", "B"), "C", null, "Child Page", null, null, |
102 |
|
"file.txt", getClass().getResourceAsStream("/file.txt"), TestUtils.SUPER_ADMIN_CREDENTIALS); |
103 |
|
|
104 |
1 |
DocumentTreeElement tree = AllDocsPage.gotoPage().clickTreeTab(); |
105 |
|
|
106 |
1 |
TreeNodeElement root = tree.getDocumentNode(spaceName, "WebHome"); |
107 |
1 |
assertEquals(spaceName, root.getLabel()); |
108 |
|
|
109 |
1 |
assertFalse(tree.hasDocument(spaceName, "A", "WebHome")); |
110 |
1 |
root.open().waitForIt(); |
111 |
1 |
TreeNodeElement alice = tree.getDocumentNode(spaceName, "A", "WebHome"); |
112 |
1 |
assertEquals("A", alice.getLabel()); |
113 |
|
|
114 |
1 |
assertFalse(tree.hasDocument(spaceName, "A", "B", "WebHome")); |
115 |
1 |
alice.open().waitForIt(); |
116 |
1 |
TreeNodeElement bob = tree.getDocumentNode(spaceName, "A", "B", "WebHome"); |
117 |
1 |
assertEquals("B", bob.getLabel()); |
118 |
|
|
119 |
1 |
assertFalse(tree.hasDocument(spaceName, "A", "B", "C")); |
120 |
1 |
bob.open().waitForIt(); |
121 |
1 |
TreeNodeElement child = tree.getDocumentNode(spaceName, "A", "B", "C"); |
122 |
1 |
assertEquals("Child Page", child.getLabel()); |
123 |
|
|
124 |
1 |
assertFalse(tree.hasAttachment(spaceName, "A", "B", "C", "file.txt")); |
125 |
|
|
126 |
1 |
child.open().waitForIt().getChildren().get(0).open().waitForIt(); |
127 |
1 |
TreeNodeElement file = tree.getAttachmentNode(spaceName, "A", "B", "C", "file.txt"); |
128 |
1 |
assertEquals("file.txt", file.getLabel()); |
129 |
|
} |
130 |
|
|
131 |
|
|
132 |
|
@see |
133 |
|
|
134 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
135 |
1 |
@Test... |
136 |
|
public void treeViewTabWithSpecialCharactersInEntityNames() |
137 |
|
{ |
138 |
|
|
139 |
1 |
String spaceName = getTestMethodName() + ".0"; |
140 |
1 |
getUtil().createPage(Arrays.asList(spaceName, "Level.1", "Level{[(2)]}", "Level@3"), "End", null, null); |
141 |
|
|
142 |
1 |
DocumentTreeElement tree = AllDocsPage.gotoPage().clickTreeTab(); |
143 |
1 |
tree.openToDocument(spaceName, "Level.1", "Level{[(2)]}", "Level@3", "End"); |
144 |
|
|
145 |
1 |
assertTrue(tree.hasDocument(spaceName, "Level.1", "WebHome")); |
146 |
1 |
assertTrue(tree.hasDocument(spaceName, "Level.1", "Level{[(2)]}", "WebHome")); |
147 |
1 |
assertTrue(tree.hasDocument(spaceName, "Level.1", "Level{[(2)]}", "Level@3", "WebHome")); |
148 |
|
} |
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 2 |
Complexity Density: 0.12 |
1PASS
|
|
154 |
1 |
@Test... |
155 |
|
@IgnoreBrowsers({ |
156 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See http://jira.xwiki.org/browse/XE-1146"), |
157 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See http://jira.xwiki.org/browse/XE-1177")}) |
158 |
|
public void attachmentsTabFiltering() throws Exception |
159 |
|
{ |
160 |
|
|
161 |
|
|
162 |
1 |
getUtil().createPageWithAttachment(getTestClassName(), "Page", null, null, "attachment1.txt", |
163 |
|
new ByteArrayInputStream("attachment content1".getBytes()), TestUtils.SUPER_ADMIN_CREDENTIALS); |
164 |
1 |
getUtil().createPageWithAttachment(getTestClassName(), "OtherPage", null, null, "attachment2.txt", |
165 |
|
new ByteArrayInputStream("attachment content2".getBytes()), TestUtils.SUPER_ADMIN_CREDENTIALS); |
166 |
|
|
167 |
1 |
AllDocsPage docsPage = AllDocsPage.gotoPage(); |
168 |
1 |
LiveTableElement liveTable = docsPage.clickAttachmentsTab(); |
169 |
|
|
170 |
1 |
Assert.assertTrue("No Filename column found", liveTable.hasColumn("Filename")); |
171 |
1 |
Assert.assertTrue("No Space column found", liveTable.hasColumn("Space")); |
172 |
1 |
Assert.assertTrue("No Date column found", liveTable.hasColumn("Date")); |
173 |
1 |
Assert.assertTrue("No Author column found", liveTable.hasColumn("Author")); |
174 |
1 |
Assert.assertTrue("No Type column found", liveTable.hasColumn("Type")); |
175 |
1 |
Assert.assertTrue("No Page column found", liveTable.hasColumn("Page")); |
176 |
|
|
177 |
|
|
178 |
1 |
liveTable.filterColumn("xwiki-livetable-allattachments-filter-2", "th"); |
179 |
1 |
List<WebElement> pageResults = getDriver().findElements(By.xpath("//td[@class='pagename']")); |
180 |
1 |
Assert.assertEquals(1, pageResults.size()); |
181 |
|
|
182 |
|
|
183 |
|
|
184 |
2 |
for (int i = 0; i < pageResults.size(); i++) { |
185 |
1 |
String text = pageResults.get(i).getText(); |
186 |
1 |
Assert.assertTrue("This [" + text + "] should not be here !", text.toLowerCase().contains("th")); |
187 |
|
} |
188 |
|
} |
189 |
|
} |