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.WebDriverLegacyITBase;
020    
021    import junit.framework.Assert;
022    import org.junit.Test;
023    
024    /**
025     * @author Kuali Rice Team (rice.collab@kuali.org)
026     */
027    public class ContraintsLegacyIT extends WebDriverLegacyITBase {
028    
029        @Override
030        public String getTestUrl() {
031            return "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page3";
032        }
033    
034        @Test
035        public void testContraintsIT() throws Exception {
036            checkForIncidentReport("field9");
037            fireEvent("field9","focus");
038            waitAndTypeByName("field9", "1");
039            fireEvent("field9", "blur");
040            Assert.assertTrue(getAttributeByName("field9","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
041            fireEvent("field9","focus");
042            clearTextByName("field9");
043            waitAndTypeByName("field9", "12345");
044            fireEvent("field9", "blur");
045            Assert.assertTrue(getAttributeByName("field9","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
046            fireEvent("field10","focus");
047            waitAndTypeByName("field10", "2");
048            fireEvent("field10", "blur");
049            Assert.assertTrue(getAttributeByName("field10","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
050            fireEvent("field10","focus");
051            clearTextByName("field10");
052            waitAndTypeByName("field10", "51");
053            fireEvent("field10", "blur");
054            Assert.assertTrue(getAttributeByName("field10","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
055            fireEvent("field10","focus");
056            clearTextByName("field10");
057            waitAndTypeByName("field10", "25");
058            fireEvent("field10", "blur");
059            Assert.assertTrue(getAttributeByName("field10","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
060            fireEvent("field6","focus");
061            waitAndTypeByName("field6", "A");
062            fireEvent("field6", "blur");
063            waitAndTypeByName("field7", "");
064            fireEvent("field7", "blur");
065            Assert.assertTrue(getAttributeByName("field7","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
066            waitAndTypeByName("field7", "B");
067            fireEvent("field7", "blur");
068            Assert.assertTrue(getAttributeByName("field7","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
069            waitAndTypeByName("field8", "");
070            fireEvent("field8", "blur");
071            Assert.assertTrue(getAttributeByName("field8","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
072            clearTextByName("field8");
073            waitAndTypeByName("field8", "C");
074            fireEvent("field8", "blur");
075            Assert.assertTrue(getAttributeByName("field8","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
076            clearTextByName("field6");
077            waitAndTypeByName("field6", "");
078            fireEvent("field6", "blur");
079            Assert.assertTrue(getAttributeByName("field6","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
080            clearTextByName("field7");
081            waitAndTypeByName("field7", "");
082            fireEvent("field7", "blur");
083            Assert.assertTrue(getAttributeByName("field7","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
084            clearTextByName("field8");
085            waitAndTypeByName("field8", "");
086            fireEvent("field8", "blur");
087            Assert.assertTrue(getAttributeByName("field6","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
088            Assert.assertTrue(getAttributeByName("field7","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
089            Assert.assertTrue(getAttributeByName("field8","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
090            clearTextByName("field8");
091            waitAndTypeByName("field8", "C");
092            fireEvent("field8", "blur");
093            Assert.assertTrue(getAttributeByName("field6","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
094            Assert.assertTrue(getAttributeByName("field7","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
095            Assert.assertTrue(getAttributeByName("field8","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
096            clearTextByName("field6");
097            waitAndTypeByName("field6", "A");
098            fireEvent("field6", "blur");
099            Assert.assertTrue(getAttributeByName("field6","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
100            Assert.assertTrue(getAttributeByName("field7","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
101            Assert.assertTrue(getAttributeByName("field8","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
102            waitAndTypeByName("field14", "A");
103            fireEvent("field14", "blur");
104            Assert.assertTrue(getAttributeByName("field14","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
105            clearTextByName("field11");
106            waitAndTypeByName("field11", "A");
107            fireEvent("field11", "blur");
108            Assert.assertTrue(getAttributeByName("field11","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
109            Assert.assertTrue(getAttributeByName("field14","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
110            clearTextByName("field11");
111            waitAndTypeByName("field11", "");
112            fireEvent("field11", "blur");
113            Assert.assertTrue(getAttributeByName("field14","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
114            clearTextByName("field12");
115            waitAndTypeByName("field12", "A");
116            fireEvent("field12", "blur");
117            Assert.assertTrue(getAttributeByName("field14","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
118            clearTextByName("field13");
119            waitAndTypeByName("field13", "A");
120            fireEvent("field13", "blur");
121            Assert.assertTrue(getAttributeByName("field13","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
122            Assert.assertTrue(getAttributeByName("field14","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
123            clearTextByName("field11");
124            waitAndTypeByName("field11", "A");
125            fireEvent("field11", "blur");
126            Assert.assertTrue(getAttributeByName("field11","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
127            Assert.assertTrue(getAttributeByName("field14","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
128            waitAndTypeByName("field18", "A");
129            fireEvent("field18", "blur");
130            Assert.assertTrue(getAttributeByName("field18","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
131            waitAndTypeByName("field15", "A");
132            fireEvent("field15", "blur");
133            Assert.assertTrue(getAttributeByName("field15","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
134            Assert.assertTrue(getAttributeByName("field18","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
135            clearTextByName("field15");
136            waitAndTypeByName("field15", "");
137            fireEvent("field15", "blur");
138            Assert.assertTrue(getAttributeByName("field18","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
139            clearTextByName("field6");
140            waitAndTypeByName("field16", "A");
141            fireEvent("field16", "blur");
142            Assert.assertTrue(getAttributeByName("field18","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
143            clearTextByName("field17");
144            waitAndTypeByName("field17", "A");
145            fireEvent("field17", "blur");
146            Assert.assertTrue(getAttributeByName("field17","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
147            Assert.assertTrue(getAttributeByName("field18","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
148            clearTextByName("field15");
149            waitAndTypeByName("field15", "A");
150            fireEvent("field15", "blur");
151            Assert.assertTrue(getAttributeByName("field18","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
152            waitAndTypeByName("field23", "A");
153            fireEvent("field23", "blur");
154            Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
155            clearTextByName("field19");
156            waitAndTypeByName("field19", "A");
157            fireEvent("field19", "blur");
158            Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
159            clearTextByName("field19");
160            waitAndTypeByName("field19", "");
161            fireEvent("field19", "blur");
162            waitAndTypeByName("field20", "B");
163            fireEvent("field20", "blur");
164            Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
165            clearTextByName("field20");
166            waitAndTypeByName("field20", "");
167            fireEvent("field20", "blur");
168            Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
169            clearTextByName("field21");
170            waitAndTypeByName("field21", "C");
171            fireEvent("field21", "blur");
172            Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
173            clearTextByName("field22");
174            waitAndTypeByName("field22", "D");
175            fireEvent("field22", "blur");
176            Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
177            clearTextByName("field19");
178            waitAndTypeByName("field19", "D");
179            fireEvent("field19", "blur");
180            Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
181            clearTextByName("field20");
182            waitAndTypeByName("field20", "D");
183            fireEvent("field20", "blur");
184            Assert.assertTrue(getAttributeByName("field23","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
185            checkByXpath("//*[@name='field24' and @value='case1']");
186            clearTextByName("field25");
187            waitAndTypeByName("field25", "");
188            fireEvent("field25", "blur");
189            Assert.assertTrue(getAttributeByName("field25","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
190            checkByXpath("//*[@name='field24' and @value='case4']");
191            fireEvent("field24", "blur");
192            for (int second = 0; ; second++) {
193                if (second >= 60) {
194                    Assert.fail("timeout");
195                }
196                try {
197                    if (getAttributeByName("field25","class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
198                        break;
199                    }
200                } catch (Exception e) {
201                }
202                Thread.sleep(1000);
203            }
204    
205            Assert.assertTrue(getAttributeByName("field25","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
206            checkByXpath("//*[@name='field24' and @value='case1']");
207            fireEvent("field24", "blur");
208            clearTextByName("field25");
209            waitAndTypeByName("field25", "$100");
210            fireEvent("field25", "blur");
211            for (int second = 0; ; second++) {
212                if (second >= 60) {
213                    Assert.fail("timeout");
214                }
215                try {
216                    if (getAttributeByName("field25","class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
217                        break;
218                    }
219                } catch (Exception e) {
220                }
221                Thread.sleep(1000);
222            }
223    
224            Assert.assertTrue(getAttributeByName("field25","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
225            checkByXpath("//*[@name='field24' and @value='case2']");
226            fireEvent("field24", "blur");
227            for (int second = 0; ; second++) {
228                if (second >= 60) {
229                    Assert.fail("timeout");
230                }
231                try {
232                    if (getAttributeByName("field25","class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
233                        break;
234                    }
235                } catch (Exception e) {
236                }
237                Thread.sleep(1000);
238            }
239    
240            Assert.assertTrue(getAttributeByName("field25","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
241            clearTextByName("field25");
242            waitAndTypeByName("field25", "A100");
243            fireEvent("field25", "blur");
244            Assert.assertTrue(getAttributeByName("field25","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
245            checkByXpath("//*[@name='field24' and @value='case3']");
246            fireEvent("field24", "blur");
247            clearTextByName("field26");
248            waitAndTypeByName("field26", "6000");
249            fireEvent("field26", "blur");
250            for (int second = 0; ; second++) {
251                if (second >= 60) {
252                    Assert.fail("timeout");
253                }
254                try {
255                    if (getAttributeByName("field26","class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
256                        break;
257                    }
258                } catch (Exception e) {
259                }
260                Thread.sleep(1000);
261            }
262    
263            Assert.assertTrue(getAttributeByName("field26","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
264            clearTextByName("field26");
265            waitAndTypeByName("field26", "501");
266            fireEvent("field26", "blur");
267            Assert.assertTrue(getAttributeByName("field26","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
268            clearTextByName("field26");
269            waitAndTypeByName("field26", "499");
270            fireEvent("field26", "blur");
271            Assert.assertTrue(getAttributeByName("field26","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
272            clearTextByName("field26");
273            waitAndTypeByName("field26", "6000");
274            fireEvent("field26", "blur");
275            checkByXpath("//*[@name='field24' and @value='case3']");
276            fireEvent("field24", "blur");
277            for (int second = 0; ; second++) {
278                if (second >= 60) {
279                    Assert.fail("timeout");
280                }
281                try {
282                    if (getAttributeByName("field26","class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
283                        break;
284                    }
285                } catch (Exception e) {
286                }
287                Thread.sleep(1000);
288            }
289    
290            Assert.assertTrue(getAttributeByName("field26","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
291            checkByXpath("//*[@name='field24' and @value='case4']");
292            clearTextByName("field27");
293            waitAndTypeByName("field27", "A");
294            fireEvent("field27", "blur");
295            clearTextByName("field28");
296            waitAndTypeByName("field28", "");
297            fireEvent("field28", "blur");
298            for (int second = 0; ; second++) {
299                if (second >= 60) {
300                    Assert.fail("timeout");
301                }
302                try {
303                    if (getAttributeByName("field28","class").matches("^[\\s\\S]*error[\\s\\S]*$")) {
304                        break;
305                    }
306                } catch (Exception e) {
307                }
308                Thread.sleep(1000);
309            }
310    
311            Assert.assertTrue(getAttributeByName("field28","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
312            checkByXpath("//*[@name='field24' and @value='case3']");
313            fireEvent("field24", "blur");
314            for (int second = 0; ; second++) {
315                if (second >= 60) {
316                    Assert.fail("timeout");
317                }
318                try {
319                    if (getAttributeByName("field28","class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
320                        break;
321                    }
322                } catch (Exception e) {
323                }
324                Thread.sleep(1000);
325            }
326    
327            Assert.assertTrue(getAttributeByName("field28","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
328            clearTextByName("field28");
329            waitAndTypeByName("field28", "B");
330            fireEvent("field28", "blur");
331            checkByXpath("//*[@name='field24' and @value='case4']");
332            fireEvent("field24", "blur");
333            for (int second = 0; ; second++) {
334                if (second >= 60) {
335                    Assert.fail("timeout");
336                }
337                try {
338                    if (getAttributeByName("field28","class").matches("^[\\s\\S]*valid[\\s\\S]*$")) {
339                        break;
340                    }
341                } catch (Exception e) {
342                }
343                Thread.sleep(1000);
344            }
345    
346            Assert.assertTrue(getAttributeByName("field28","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
347            clearTextByName("field31");
348            waitAndTypeByName("field31", "B");
349            clearTextByName("field32");
350            waitAndTypeByName("field32", "B");
351            waitAndTypeByName("field33", "");
352            fireEvent("field33", "blur");
353            Assert.assertTrue(getAttributeByName("field33","class").matches("^[\\s\\S]*error[\\s\\S]*$"));
354            clearTextByName("field33");
355            waitAndTypeByName("field33", "B");
356            fireEvent("field33", "blur");
357            Assert.assertTrue(getAttributeByName("field33","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
358            clearTextByName("field32");
359            waitAndTypeByName("field32", "A");
360            clearTextByName("field33");
361            waitAndTypeByName("field33", "");
362            fireEvent("field33", "blur");
363            Assert.assertTrue(getAttributeByName("field33","class").matches("^[\\s\\S]*valid[\\s\\S]*$"));
364            passed();
365        }
366    }