001 /*
002 * Copyright 2006-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package edu.samplu.krad.compview;
018
019 import edu.samplu.common.UpgradedSeleniumITBase;
020 import junit.framework.Assert;
021 import org.junit.Test;
022
023 /**
024 * @author Kuali Rice Team (rice.collab@kuali.org)
025 */
026 public class ContraintsIT extends UpgradedSeleniumITBase {
027
028 @Override
029 public String getTestUrl() {
030 return "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page3";
031 }
032
033 @Test
034 public void testContraintsIT() throws Exception {
035 checkForIncidentReport("name=field9");
036 focus("name=field9");
037 waitAndType("name=field9", "1");
038 fireEvent("name=field9", "blur");
039 Assert.assertTrue(getAttribute("name=field9@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
040 focus("name=field9");
041 waitAndType("name=field9", "12345");
042 fireEvent("name=field9", "blur");
043 Assert.assertTrue(getAttribute("name=field9@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
044 focus("name=field10");
045 waitAndType("name=field10", "2");
046 fireEvent("name=field10", "blur");
047 Assert.assertTrue(getAttribute("name=field10@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
048 focus("name=field10");
049 waitAndType("name=field10", "51");
050 fireEvent("name=field10", "blur");
051 Assert.assertTrue(getAttribute("name=field10@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
052 focus("name=field10");
053 waitAndType("name=field10", "25");
054 fireEvent("name=field10", "blur");
055 Assert.assertTrue(getAttribute("name=field10@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
056 focus("name=field6");
057 waitAndType("name=field6", "A");
058 fireEvent("name=field6", "blur");
059 fireEvent("name=field7", "blur");
060 Assert.assertTrue(getAttribute("name=field7@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
061 waitAndType("name=field7", "B");
062 fireEvent("name=field7", "blur");
063 Assert.assertTrue(getAttribute("name=field7@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
064 fireEvent("name=field8", "blur");
065 Assert.assertTrue(getAttribute("name=field8@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
066 waitAndType("name=field8", "C");
067 fireEvent("name=field8", "blur");
068 Assert.assertTrue(getAttribute("name=field8@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
069 waitAndType("name=field6", "");
070 fireEvent("name=field6", "blur");
071 Assert.assertTrue(getAttribute("name=field6@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
072 waitAndType("name=field7", "");
073 fireEvent("name=field7", "blur");
074 Assert.assertTrue(getAttribute("name=field7@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
075 waitAndType("name=field8", "");
076 fireEvent("name=field8", "blur");
077 Assert.assertTrue(getAttribute("name=field6@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
078 Assert.assertTrue(getAttribute("name=field7@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
079 Assert.assertTrue(getAttribute("name=field8@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
080 waitAndType("name=field8", "C");
081 fireEvent("name=field8", "blur");
082 Assert.assertTrue(getAttribute("name=field6@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
083 Assert.assertTrue(getAttribute("name=field7@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
084 Assert.assertTrue(getAttribute("name=field8@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
085 waitAndType("name=field6", "A");
086 fireEvent("name=field6", "blur");
087 Assert.assertTrue(getAttribute("name=field6@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
088 Assert.assertTrue(getAttribute("name=field7@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
089 Assert.assertTrue(getAttribute("name=field8@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
090 waitAndType("name=field14", "A");
091 fireEvent("name=field14", "blur");
092 Assert.assertTrue(getAttribute("name=field14@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
093 waitAndType("name=field11", "A");
094 fireEvent("name=field11", "blur");
095 Assert.assertTrue(getAttribute("name=field11@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
096 Assert.assertTrue(getAttribute("name=field14@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
097 waitAndType("name=field11", "");
098 fireEvent("name=field11", "blur");
099 Assert.assertTrue(getAttribute("name=field14@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
100 waitAndType("name=field12", "A");
101 fireEvent("name=field12", "blur");
102 Assert.assertTrue(getAttribute("name=field14@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
103 waitAndType("name=field13", "A");
104 fireEvent("name=field13", "blur");
105 Assert.assertTrue(getAttribute("name=field13@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
106 Assert.assertTrue(getAttribute("name=field14@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
107 waitAndType("name=field11", "A");
108 fireEvent("name=field11", "blur");
109 Assert.assertTrue(getAttribute("name=field11@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
110 Assert.assertTrue(getAttribute("name=field14@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
111 waitAndType("name=field18", "A");
112 fireEvent("name=field18", "blur");
113 Assert.assertTrue(getAttribute("name=field18@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
114 waitAndType("name=field15", "A");
115 fireEvent("name=field15", "blur");
116 Assert.assertTrue(getAttribute("name=field15@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
117 Assert.assertTrue(getAttribute("name=field18@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
118 waitAndType("name=field15", "");
119 fireEvent("name=field15", "blur");
120 Assert.assertTrue(getAttribute("name=field18@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
121 waitAndType("name=field16", "A");
122 fireEvent("name=field16", "blur");
123 Assert.assertTrue(getAttribute("name=field18@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
124 waitAndType("name=field17", "A");
125 fireEvent("name=field17", "blur");
126 Assert.assertTrue(getAttribute("name=field17@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
127 Assert.assertTrue(getAttribute("name=field18@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
128 waitAndType("name=field15", "A");
129 fireEvent("name=field15", "blur");
130 Assert.assertTrue(getAttribute("name=field18@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
131 waitAndType("name=field23", "A");
132 fireEvent("name=field23", "blur");
133 Assert.assertTrue(getAttribute("name=field23@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
134 waitAndType("name=field19", "A");
135 fireEvent("name=field19", "blur");
136 Assert.assertTrue(getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
137 waitAndType("name=field19", "");
138 fireEvent("name=field19", "blur");
139 waitAndType("name=field20", "B");
140 fireEvent("name=field20", "blur");
141 Assert.assertTrue(getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
142 waitAndType("name=field20", "");
143 fireEvent("name=field20", "blur");
144 Assert.assertTrue(getAttribute("name=field23@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
145 waitAndType("name=field21", "C");
146 fireEvent("name=field21", "blur");
147 Assert.assertTrue(getAttribute("name=field23@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
148 waitAndType("name=field22", "D");
149 fireEvent("name=field22", "blur");
150 Assert.assertTrue(getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
151 waitAndType("name=field19", "D");
152 fireEvent("name=field19", "blur");
153 Assert.assertTrue(getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
154 waitAndType("name=field20", "D");
155 fireEvent("name=field20", "blur");
156 Assert.assertTrue(getAttribute("name=field23@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
157 check("name=field24 value=case1");
158 waitAndType("name=field25", "");
159 fireEvent("name=field25", "blur");
160 Assert.assertTrue(getAttribute("name=field25@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
161 check("name=field24 value=case4");
162 fireEvent("name=field24", "blur");
163 for (int second = 0; ; second++) {
164 if (second >= 60) {
165 Assert.fail("timeout");
166 }
167 try {
168 if (getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
169 break;
170 }
171 } catch (Exception e) {
172 }
173 Thread.sleep(1000);
174 }
175
176 Assert.assertTrue(getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
177 check("name=field24 value=case1");
178 fireEvent("name=field24", "blur");
179 waitAndType("name=field25", "$100");
180 fireEvent("name=field25", "blur");
181 for (int second = 0; ; second++) {
182 if (second >= 60) {
183 Assert.fail("timeout");
184 }
185 try {
186 if (getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
187 break;
188 }
189 } catch (Exception e) {
190 }
191 Thread.sleep(1000);
192 }
193
194 Assert.assertTrue(getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
195 check("name=field24 value=case2");
196 fireEvent("name=field24", "blur");
197 for (int second = 0; ; second++) {
198 if (second >= 60) {
199 Assert.fail("timeout");
200 }
201 try {
202 if (getAttribute("name=field25@class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
203 break;
204 }
205 } catch (Exception e) {
206 }
207 Thread.sleep(1000);
208 }
209
210 Assert.assertTrue(getAttribute("name=field25@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
211 waitAndType("name=field25", "A100");
212 fireEvent("name=field25", "blur");
213 Assert.assertTrue(getAttribute("name=field25@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
214 check("name=field24 value=case3");
215 fireEvent("name=field24", "blur");
216 waitAndType("name=field26", "6000");
217 fireEvent("name=field26", "blur");
218 for (int second = 0; ; second++) {
219 if (second >= 60) {
220 Assert.fail("timeout");
221 }
222 try {
223 if (getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
224 break;
225 }
226 } catch (Exception e) {
227 }
228 Thread.sleep(1000);
229 }
230
231 Assert.assertTrue(getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
232 waitAndType("name=field26", "501");
233 fireEvent("name=field26", "blur");
234 Assert.assertTrue(getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
235 waitAndType("name=field26", "499");
236 fireEvent("name=field26", "blur");
237 Assert.assertTrue(getAttribute("name=field26@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
238 waitAndType("name=field26", "6000");
239 fireEvent("name=field26", "blur");
240 check("name=field24 value=case3");
241 fireEvent("name=field24", "blur");
242 for (int second = 0; ; second++) {
243 if (second >= 60) {
244 Assert.fail("timeout");
245 }
246 try {
247 if (getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
248 break;
249 }
250 } catch (Exception e) {
251 }
252 Thread.sleep(1000);
253 }
254
255 Assert.assertTrue(getAttribute("name=field26@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
256 check("name=field24 value=case4");
257 waitAndType("name=field27", "A");
258 fireEvent("name=field27", "blur");
259 waitAndType("name=field28", "");
260 fireEvent("name=field28", "blur");
261 for (int second = 0; ; second++) {
262 if (second >= 60) {
263 Assert.fail("timeout");
264 }
265 try {
266 if (getAttribute("name=field28@class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
267 break;
268 }
269 } catch (Exception e) {
270 }
271 Thread.sleep(1000);
272 }
273
274 Assert.assertTrue(getAttribute("name=field28@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
275 check("name=field24 value=case3");
276 fireEvent("name=field24", "blur");
277 for (int second = 0; ; second++) {
278 if (second >= 60) {
279 Assert.fail("timeout");
280 }
281 try {
282 if (getAttribute("name=field28@class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
283 break;
284 }
285 } catch (Exception e) {
286 }
287 Thread.sleep(1000);
288 }
289
290 Assert.assertTrue(getAttribute("name=field28@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
291 waitAndType("name=field28", "B");
292 fireEvent("name=field28", "blur");
293 check("name=field24 value=case4");
294 fireEvent("name=field24", "blur");
295 for (int second = 0; ; second++) {
296 if (second >= 60) {
297 Assert.fail("timeout");
298 }
299 try {
300 if (getAttribute("name=field28@class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
301 break;
302 }
303 } catch (Exception e) {
304 }
305 Thread.sleep(1000);
306 }
307
308 Assert.assertTrue(getAttribute("name=field28@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
309 waitAndType("name=field31", "B");
310 waitAndType("name=field32", "B");
311 fireEvent("name=field33", "blur");
312 Assert.assertTrue(getAttribute("name=field33@class").matches("^[\\s\\S]*error[\\s\\S]*$"));
313 waitAndType("name=field33", "B");
314 fireEvent("name=field33", "blur");
315 Assert.assertTrue(getAttribute("name=field33@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
316 waitAndType("name=field32", "A");
317 waitAndType("name=field33", "");
318 fireEvent("name=field33", "blur");
319 Assert.assertTrue(getAttribute("name=field33@class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
320 }
321 }