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

File LiveTableGeneratorTest.java

 

Code metrics

0
57
4
1
157
94
4
0.07
14.25
4
1

Classes

Class Line # Actions
LiveTableGeneratorTest 43 57 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

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.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    * Tests the live table generator used by the AppWithinMinutes wizard.
39    *
40    * @version $Id: f699c8523b0336118ef2d48ac3e953a1df3e548d $
41    * @since 4.5RC1
42    */
 
43    public class LiveTableGeneratorTest extends AbstractTest
44    {
45    @Rule
46    public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil());
47   
48    /**
49    * The second step of the AppWithinMinutes wizard.
50    */
51    private ApplicationClassEditPage classEditPage;
52   
53    /**
54    * The name of the application.
55    */
56    private String appName;
57   
 
58  2 toggle @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 "XWIKI-8616: Filter a static list in an AWM livetable does not work."
70    */
 
71  1 toggle @Test
72    public void filterStaticList()
73    {
74    // Create an application that has a Static List field and add a corresponding column to the live table.
75  1 classEditPage.addField("Static List");
76  1 ApplicationHomeEditPage homeEditPage = classEditPage.clickNextStep().clickNextStep().waitUntilPageIsLoaded();
77  1 homeEditPage.addLiveTableColumn("Static List");
78   
79    // Add first entry.
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    // Add second entry.
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    // Filter the Static List column of the live table.
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 "XWIKI-8728: AWM home page does not list entries when \"Title\" column is set to be the first one"
110    */
 
111  1 toggle @Test
112    public void titleField()
113    {
114    // Create an application that has a Title field and add a corresponding column to the live table.
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    // Add first entry.
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    // Add second entry.
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    // Filter the Title column of the live table.
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 columnIndex the column index
151    * @return the id of the filter input for the specified column
152    */
 
153  2 toggle private String getFilterInputId(int columnIndex)
154    {
155  2 return String.format("xwiki-livetable-%s-filter-%s", appName.toLowerCase(), columnIndex + 1);
156    }
157    }