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.travel.krad.test;
018    
019    import edu.samplu.common.ITUtil;
020    import org.junit.Test;
021    
022    import static junit.framework.Assert.assertEquals;
023    import static junit.framework.Assert.assertTrue;
024    import static junit.framework.Assert.fail;
025    import edu.samplu.common.WebDriverITBase;
026    
027    /**
028     * test that dirty fields check happens for all pages in a view
029     * 
030     * @author Kuali Rice Team (rice.collab@kuali.org)
031     */
032    public class DirtyFieldsCheckIT extends WebDriverITBase {
033            @Override
034            public String getTestUrl() {
035                    // open Other Examples page in kitchen sink view
036                    return "/kr-krad/uicomponents?viewId=UifCompView_KNS&methodToCall=start&readOnlyFields=field91";
037            }
038    
039            @Test
040            public void testDirtyFieldsCheck() throws Exception {
041                    checkForIncidentReport(getTestUrl());
042                    Thread.sleep(5000);
043                    
044                    waitAndTypeByName("field1", "test 1");
045                    waitAndTypeByName("field102", "test 2");
046                    
047                    assertCancelConfirmation(); 
048            
049                    // testing manually
050                    waitForElementPresentByName("field100");
051                    waitAndTypeByName("field100", "here");
052                    waitAndTypeByName("field103", "there");
053                    
054                // 'Validation' navigation link
055                    assertCancelConfirmation();
056            
057                    // testing manually
058                    waitForElementPresentByName("field106");
059                    // //Asserting text-field style to uppercase. This style would display
060                    // input text in uppercase.
061                    assertEquals("text-transform: uppercase;",getAttributeByName("field112", "style"));
062                    assertCancelConfirmation(); 
063                    waitForElementPresentByName("field101");
064                    assertEquals("val", getAttributeByName("field101","value")); 
065                    clearTextByName("field101");
066                    waitAndTypeByName("field101", "1");
067                    waitAndTypeByName("field104", "");
068    
069                    assertEquals("1", getAttributeByName("field101","value"));
070                    waitAndTypeByName("field104", "2");
071                    // 'Progressive Disclosure' navigation link
072                    assertCancelConfirmation();
073                                                                            
074            }
075    
076            private void assertCancelConfirmation() throws InterruptedException {
077                    waitAndClickByLinkText("Cancel");
078                    dismissAlert();
079            }
080    }