1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.labs.kitchensink;
17
18 import org.junit.Test;
19 import org.kuali.rice.testtools.selenium.WebDriverUtils;
20
21 import static org.junit.Assert.assertNotSame;
22
23
24
25
26 public class LabsCollectionsAft extends LabsKitchenSinkBase {
27
28
29
30
31 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&pageId=UifCompView-Page7#UifCompView-Page7";
32
33
34
35
36 public static final String FIELD_ELEMENT_NAME = "list4[0].subList[0].field1";
37
38 @Override
39 protected String getBookmarkUrl() {
40 return BOOKMARK_URL;
41 }
42
43 @Override
44 protected void navigate() throws Exception {
45 navigateToKitchenSink("Collections");
46 }
47
48 @Test
49 public void testCollectionsBookmark() throws Exception {
50 testCollections();
51 testSubCollectionSize();
52 testDeleteSubCollectionLine();
53 passed();
54 }
55
56 @Test
57 public void testCollectionsNav() throws Exception {
58 testCollections();
59 testSubCollectionSize();
60 testDeleteSubCollectionLine();
61 passed();
62 }
63
64 protected void testCollections() throws InterruptedException {
65
66 waitForTextPresent("Collection Group rendered as a List", WebDriverUtils.configuredImplicityWait() * 3);
67
68
69 waitForElementPresentByXpath("//table[@class='table table-condensed table-bordered uif-tableCollectionLayout uif-hasAddLine dataTable']/tbody/tr[@class='uif-collectionAddItem odd']",
70 "https://jira.kuali.org/browse/RICEQA-274 AFT Failure update LabsCollectionsAft");
71 assertElementPresentByXpath("//table[@class='table table-condensed table-bordered uif-tableCollectionLayout uif-hasAddLine dataTable']/tbody/tr/td[@class='uif-collection-column-action ']");
72
73
74 assertElementPresentByXpath("//div[@id='collection2_disclosureContent']/div/table[@class='table table-condensed table-bordered uif-tableCollectionLayout uif-hasAddLine dataTable']/tbody/tr[@class='uif-collectionAddItem odd']");
75 assertElementPresentByXpath("//div[@id='collection2_disclosureContent']/div/div[@class='dataTables_length']/label/select");
76 assertElementPresentByXpath("//div[@id='collection2_disclosureContent']/div/table[@class='table table-condensed table-bordered uif-tableCollectionLayout uif-hasAddLine dataTable']/tbody/tr/td[1]/div/fieldset/div/button");
77
78
79 assertElementPresentByXpath("//section[@class='uif-collectionItem uif-tableCollectionItem uif-collectionAddItem']/table[@class='table table-condensed table-bordered uif-gridLayout uif-table-fixed']");
80 assertElementPresentByXpath("//div[@class='dataTables_scrollBody']/table[@class='table table-condensed table-bordered uif-tableCollectionLayout dataTable']/tbody/tr/td[@class='uif-collection-column-action ']");
81
82
83 assertElementPresentByXpath("//div[@id='collection3_disclosureContent']/section/table");
84
85
86 assertElementPresentByXpath("//div[@id='collection4_disclosureContent']/section/table");
87 assertElementPresentByXpath("//div[@id='subCollection1_line0_disclosureContent']");
88
89
90 assertElementPresentByXpath("//ul/li/div[@data-parent='UifCompView-CollectionList']");
91 }
92
93 protected void testSubCollectionSize() throws Exception {
94
95 for (int second = 0;; second++) {
96 if (second >= waitSeconds)
97 jiraAwareFail(TIMEOUT_MESSAGE
98 + " looking for "
99 + SUB_COLLECTION_UIF_DISCLOSURE_SPAN_UIF_HEADER_TEXT_SPAN_XPATH);
100 try {
101 if (isElementPresentByXpath("//span[@class='uif-headerText-span' and contains(text(),'SubCollection - (3 lines)')]")) {
102 break;
103 }
104 } catch (Exception e) {}
105 Thread.sleep(1000);
106 }
107
108
109 waitForElementPresentByXpath("//section[@id='subCollection1_line0']/header/div/label/a/span[contains(text(),'SubCollection - (3 lines)')]]");
110 waitForElementPresentByXpath("//a[@id='subCollection1_line1_toggle']/span");
111 }
112
113 protected void testDeleteSubCollectionLine() throws Exception {
114
115 waitForElementPresentByName(FIELD_ELEMENT_NAME);
116
117
118 waitAndTypeByName(FIELD_ELEMENT_NAME, "selenium");
119
120
121 waitAndClickById("subCollection1_line0_del_line0_line0");
122 Thread.sleep(2000);
123
124
125 for (int second = 0;; second++) {
126 if (second >= waitSeconds)fail(TIMEOUT_MESSAGE);
127
128 try {
129 if (!"selenium".equals(waitAndGetAttributeByName(FIELD_ELEMENT_NAME, "value")))
130 break;
131 } catch (Exception e) {}
132
133 Thread.sleep(1000);
134 }
135
136
137 assertNotSame("selenium", waitAndGetAttributeByName(FIELD_ELEMENT_NAME, "value"));
138 }
139 }