Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4799

Show
Ignore:
Timestamp:
08/21/06 03:31:11 (2 years ago)
Author:
madrobby
Message:

Add integration test for Ajax autocompleter for results with no linebreaks, #4149

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/scriptaculous/CHANGELOG

    r4797 r4799  
    11*SVN* 
     2 
     3* Add integration test for Ajax autocompleter for results with no linebreaks, #4149 
    24 
    35* Fix an issue with redrawing ghosted draggables that are inside a scrolled container, fixes #3860 [thx gkupps, tsukue] 
  • spinoffs/scriptaculous/test/unit/ajax_autocompleter_test.html

    r3028 r4799  
    2424<input id="ac_input" type="text" autocomplete="off" /> 
    2525<div id="ac_update" style="display:none;border:1px solid black;background-color:white;position:relative;"></div> 
     26 
     27<input id="ac_input_br" type="text" autocomplete="off" /> 
     28<div id="ac_update_br" style="display:none;border:1px solid black;background-color:white;position:relative;"></div> 
    2629 
    2730<input id="ac2_input" type="text" autocomplete="off" /> 
     
    149152        }}); 
    150153      }}); 
     154    }}, 
     155     
     156    // Same integration test, results has no linebreaks 
     157    testAjaxAutocompleterNoLinebreaksInResult: function() { with(this) { 
     158      var ac = new Ajax.Autocompleter('ac_input_br','ac_update_br','_autocomplete_result_nobr.html', 
     159        { method: 'get' }); //override so we can use a static for the result 
     160      assertInstanceOf(Ajax.Autocompleter, ac); 
     161 
     162      // box not visible 
     163      assertNotVisible('ac_update_br'); 
     164 
     165      // focus, but box not visible 
     166      Event.simulateMouse('ac_input_br', 'click'); 
     167      assertNotVisible('ac_update_br'); 
     168 
     169      Event.simulateKeys('ac_input_br','abcdefg'); 
     170      assertEqual('abcdefg', $('ac_input_br').value); 
     171 
     172      // check box popping up on input 
     173      wait(1000, function() { with(this) { 
     174        assertVisible('ac_update_br'); 
     175        assertEqual('test1', $('ac_update_br').firstChild.firstChild.innerHTML); 
     176        assertEqual('test2', $('ac_update_br').firstChild.firstChild.nextSibling.innerHTML); 
     177 
     178        // intl. characters return (UTF-8) 
     179        assertEqual('Here we have some international ©∏Á®Äç†∑rß', $('ac_update_br').firstChild.lastChild.innerHTML); 
     180 
     181        // first entry should be selected 
     182        assert(Element.hasClassName($('ac_update_br').firstChild.firstChild, 'selected'),'Selected item should have a className of: selected'); 
     183 
     184        Event.simulateKey('ac_input_br','keypress',{keyCode:Event.KEY_DOWN}); 
     185 
     186        // second entry should be selected 
     187        assert(!Element.hasClassName($('ac_update_br').firstChild.firstChild),'Item shouldn\'t have a className of: selected'); 
     188        assert(Element.hasClassName($('ac_update_br').firstChild.firstChild.nextSibling, 'selected'),'Second entry should have a className of: selected'); 
     189 
     190        // check selecting with <TAB> 
     191        Event.simulateKey('ac_input_br','keypress',{keyCode:Event.KEY_TAB}); 
     192        assertEqual('test2',$('ac_input_br').value); 
     193 
     194        // check box going away 
     195        wait(500, function() { with(this) { 
     196          assertNotVisible('ac_update_br'); 
     197 
     198          // check selecting with mouse click 
     199          Event.simulateKeys('ac_input_br','3'); 
     200          assertEqual('test23', $('ac_input_br').value); 
     201          wait(1000, function() { with(this) { 
     202            assertVisible('ac_update_br'); 
     203            Event.simulateMouse($('ac_update_br').firstChild.childNodes[4],'click'); 
     204 
     205            wait(1000, function() { with(this) { 
     206              // tests if removal of 'informal' nodes and HTML escaping works 
     207              assertEqual('(GET <ME> INSTEAD)',$('ac_input_br').value); 
     208              assertNotVisible('ac_update_br'); 
     209 
     210                // check cancelling with <ESC> 
     211                Event.simulateKeys('ac_input_br','abcdefg'); 
     212 
     213                wait(1000, function() { with(this) { 
     214                  assertVisible('ac_update_br'); 
     215                  assertEqual('(GET <ME> INSTEAD)abcdefg', $('ac_input_br').value); 
     216 
     217                  Event.simulateKey('ac_input_br','keypress',{keyCode:Event.KEY_DOWN}); 
     218                  Event.simulateKey('ac_input_br','keypress',{keyCode:Event.KEY_ESC}); 
     219 
     220                  assertEqual('(GET <ME> INSTEAD)abcdefg', $('ac_input_br').value); 
     221                }}); 
     222            }}); 
     223          }}); 
     224        }}); 
     225      }}); 
    151226    }} 
    152227