| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.test.ui.appwithinminutes; |
| 21 |
|
|
| 22 |
|
import org.apache.commons.lang.RandomStringUtils; |
| 23 |
|
import org.junit.Assert; |
| 24 |
|
import org.junit.Before; |
| 25 |
|
import org.junit.Rule; |
| 26 |
|
import org.junit.Test; |
| 27 |
|
import org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage; |
| 28 |
|
import org.xwiki.appwithinminutes.test.po.ApplicationCreatePage; |
| 29 |
|
import org.xwiki.appwithinminutes.test.po.ApplicationHomeEditPage; |
| 30 |
|
import org.xwiki.appwithinminutes.test.po.ApplicationHomePage; |
| 31 |
|
import org.xwiki.appwithinminutes.test.po.EntryEditPage; |
| 32 |
|
import org.xwiki.appwithinminutes.test.po.EntryNamePane; |
| 33 |
|
import org.xwiki.test.ui.AbstractTest; |
| 34 |
|
import org.xwiki.test.ui.AdminAuthenticationRule; |
| 35 |
|
import org.xwiki.test.ui.po.LiveTableElement; |
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
@version |
| 41 |
|
@since |
| 42 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (61) |
Complexity: 4 |
Complexity Density: 0.07 |
|
| 43 |
|
public class LiveTableGeneratorTest extends AbstractTest |
| 44 |
|
{ |
| 45 |
|
@Rule |
| 46 |
|
public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil()); |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
private ApplicationClassEditPage classEditPage; |
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
private String appName; |
| 57 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 58 |
2 |
@Before... |
| 59 |
|
public void setUp() throws Exception |
| 60 |
|
{ |
| 61 |
2 |
appName = RandomStringUtils.randomAlphabetic(6); |
| 62 |
2 |
ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage(); |
| 63 |
2 |
appCreatePage.setApplicationName(appName); |
| 64 |
2 |
appCreatePage.waitForApplicationNamePreview(); |
| 65 |
2 |
classEditPage = appCreatePage.clickNextStep(); |
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
@see |
| 70 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
| 71 |
1 |
@Test... |
| 72 |
|
public void filterStaticList() |
| 73 |
|
{ |
| 74 |
|
|
| 75 |
1 |
classEditPage.addField("Static List"); |
| 76 |
1 |
ApplicationHomeEditPage homeEditPage = classEditPage.clickNextStep().clickNextStep().waitUntilPageIsLoaded(); |
| 77 |
1 |
homeEditPage.addLiveTableColumn("Static List"); |
| 78 |
|
|
| 79 |
|
|
| 80 |
1 |
EntryNamePane entryNamePane = homeEditPage.clickFinish().clickAddNewEntry(); |
| 81 |
1 |
entryNamePane.setName("Foo"); |
| 82 |
1 |
EntryEditPage entryEditPage = entryNamePane.clickAdd(); |
| 83 |
1 |
entryEditPage.setValue("staticList1", "value1"); |
| 84 |
1 |
entryEditPage.clickSaveAndView().clickBreadcrumbLink(appName); |
| 85 |
|
|
| 86 |
|
|
| 87 |
1 |
entryNamePane = new ApplicationHomePage().clickAddNewEntry(); |
| 88 |
1 |
entryNamePane.setName("Bar"); |
| 89 |
1 |
entryEditPage = entryNamePane.clickAdd(); |
| 90 |
1 |
entryEditPage.setValue("staticList1", "value2"); |
| 91 |
1 |
entryEditPage.clickSaveAndView().clickBreadcrumbLink(appName); |
| 92 |
|
|
| 93 |
|
|
| 94 |
1 |
LiveTableElement liveTable = new ApplicationHomePage().getEntriesLiveTable(); |
| 95 |
1 |
liveTable.waitUntilReady(); |
| 96 |
1 |
Assert.assertEquals(2, liveTable.getRowCount()); |
| 97 |
1 |
String filterInputId = getFilterInputId(liveTable.getColumnIndex("Static List")); |
| 98 |
1 |
liveTable.filterColumn(filterInputId, "Second Choice"); |
| 99 |
1 |
Assert.assertEquals(1, liveTable.getRowCount()); |
| 100 |
1 |
Assert.assertTrue(liveTable.hasRow("Page Title", "Bar")); |
| 101 |
1 |
liveTable.filterColumn(filterInputId, "First Choice"); |
| 102 |
1 |
Assert.assertEquals(1, liveTable.getRowCount()); |
| 103 |
1 |
Assert.assertTrue(liveTable.hasRow("Page Title", "Foo")); |
| 104 |
1 |
liveTable.filterColumn(filterInputId, "All"); |
| 105 |
1 |
Assert.assertEquals(2, liveTable.getRowCount()); |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
|
| 109 |
|
@see |
| 110 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
| 111 |
1 |
@Test... |
| 112 |
|
public void titleField() |
| 113 |
|
{ |
| 114 |
|
|
| 115 |
1 |
classEditPage.addField("Title"); |
| 116 |
1 |
ApplicationHomeEditPage homeEditPage = classEditPage.clickNextStep().clickNextStep().waitUntilPageIsLoaded(); |
| 117 |
1 |
homeEditPage.addLiveTableColumn("Title"); |
| 118 |
1 |
homeEditPage.moveLiveTableColumnBefore("Title", "Page Title"); |
| 119 |
|
|
| 120 |
|
|
| 121 |
1 |
EntryNamePane entryNamePane = homeEditPage.clickFinish().clickAddNewEntry(); |
| 122 |
1 |
entryNamePane.setName("Foo"); |
| 123 |
1 |
EntryEditPage entryEditPage = entryNamePane.clickAdd(); |
| 124 |
1 |
entryEditPage.setTitle("The Mighty Foo"); |
| 125 |
1 |
entryEditPage.clickSaveAndView().clickBreadcrumbLink(appName); |
| 126 |
|
|
| 127 |
|
|
| 128 |
1 |
entryNamePane = new ApplicationHomePage().clickAddNewEntry(); |
| 129 |
1 |
entryNamePane.setName("Bar"); |
| 130 |
1 |
entryEditPage = entryNamePane.clickAdd(); |
| 131 |
1 |
entryEditPage.setTitle("The Empty Bar"); |
| 132 |
1 |
entryEditPage.clickSaveAndView().clickBreadcrumbLink(appName); |
| 133 |
|
|
| 134 |
|
|
| 135 |
1 |
LiveTableElement liveTable = new ApplicationHomePage().getEntriesLiveTable(); |
| 136 |
1 |
liveTable.waitUntilReady(); |
| 137 |
1 |
Assert.assertEquals(2, liveTable.getRowCount()); |
| 138 |
1 |
String filterInputId = getFilterInputId(0); |
| 139 |
1 |
liveTable.filterColumn(filterInputId, "mighty"); |
| 140 |
1 |
Assert.assertEquals(1, liveTable.getRowCount()); |
| 141 |
1 |
Assert.assertTrue(liveTable.hasRow("Location", appName + "Foo")); |
| 142 |
1 |
liveTable.filterColumn(filterInputId, "empty"); |
| 143 |
1 |
Assert.assertEquals(1, liveTable.getRowCount()); |
| 144 |
1 |
Assert.assertTrue(liveTable.hasRow("Location", appName + "Bar")); |
| 145 |
1 |
liveTable.filterColumn(filterInputId, ""); |
| 146 |
1 |
Assert.assertEquals(2, liveTable.getRowCount()); |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
|
| 150 |
|
@param |
| 151 |
|
@return |
| 152 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 153 |
2 |
private String getFilterInputId(int columnIndex)... |
| 154 |
|
{ |
| 155 |
2 |
return String.format("xwiki-livetable-%s-filter-%s", appName.toLowerCase(), columnIndex + 1); |
| 156 |
|
} |
| 157 |
|
} |