Skip to content

Commit

Permalink
Fixed some ajax bugs (drag-drop, add). All tests pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Jan 30, 2012
1 parent 9e2a7b2 commit 7ccc951
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 90 deletions.
4 changes: 2 additions & 2 deletions lib/zena/use/forms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,9 @@ def get_input_params(params = @params)
end

if node.dom_prefix && !params[:param]
res[:id] = "#{node.dom_prefix}_#{attribute}"
res[:id] = params[:id] || "#{@context[:form_prefix]}_#{attribute}"
else
res[:id] = params[:id] if params[:id]
res[:id] = params[:id] if params[:id]
end

if params[:type] == 'checkbox' && sub_attr_ruby
Expand Down
25 changes: 25 additions & 0 deletions test/fixtures/files/TestNode.zafu
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,31 @@
</table>
</div>

<div class='test' id='filter1' do='selenium'>
<h3>filter1</h3>
<p>Ajax live filter.</p>
<div id='filter1_form' do='filter' live='true'>
<input name='f' id='filter1_in' value=''/>
</div>
<ul id='filter1_list' do='block' do='nodes where title like "%#{params[:f]}%" in site limit 2'>
<li id='fil1_#{id}' do='each' do='title'/>
</ul>
</div>

<div class='test' id='filter2' do='selenium'>
<h3>filter2</h3>
<p>Ajax live filter (remote target).</p>
<div do='parent'>
<b do='title'/> //! Filter is not in same parent as filtered list. Explicit target.
<div id='filter2_form' do='filter' live='true' update='filter2_list'>
<input name='f' id='filter2_in' value=''/>
</div>
</div>
<ul id='filter2_list' do='block' do='nodes where title like "%#{params[:f]}%" in site limit 2'>
<li id='fil2_#{id}' do='each' do='title'/>
</ul>
</div>

<div class='test' id='form1' do='selenium'>
<h3>form1</h3>
<p>Form in [new] to create objects.</p>
Expand Down
4 changes: 2 additions & 2 deletions test/integration/zafu_compiler/ajax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ each_in_each_form:
each_in_each_dom_id:
# should render correct form
src: "<r:pages do='each'><r:title/><r:edit/><r:pages do='each'><r:title/><r:edit/></r:pages></r:pages>"
tem: "/list2_#\{var.\.zip\}_#\{var.\.zip\}/"
tem: "/list1_#\{var.\.zip\}_#\{var.\.zip\}/"

default_focus_field:
src: "<ol do='comments'><li do='each'/><li do='form'><input name='author_name'/> ... <input name='text'/></li><li do='add'/></ol>"
Expand Down Expand Up @@ -220,7 +220,7 @@ drag_with_form:
<td class='edit'> <r:edit class='edit'>éditer</r:edit></td>
</tr>
</table>"
tem: "/<span class='drag' id='<%= %Q\{list2_#\{var2.zip\}\}.*<% add_drag_id\(%Q\{list2_#\{var2.zip\}\}/"
tem: "/<span class='drag' id='<%= %Q\{list3_#\{var2.zip\}\}.*<% add_drag_id\(%Q\{list3_#\{var2.zip\}\}/"
drag_with_form_not_in_form:
src: "<table do='pages in site'>
Expand Down
2 changes: 1 addition & 1 deletion test/integration/zafu_compiler/forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ input_new:
context:
node: 'ant'
src: "<r:contacts><r:each/><r:form><r:input name='first_name'/></r:form><r:add/></r:contacts>"
res: "/name='node\[first_name\]' [^>]*id='list1_first_name'/"
res: "/name='node\[first_name\]' [^>]*id='list2_first_name'/"

show_in_form:
src: "<r:form><b do='title'/></r:form>"
Expand Down
16 changes: 8 additions & 8 deletions test/selenium/Add/add3.rsel
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Add first element
open '/oo/testnode37.html?test=add3'
assert_not_visible 'add31_title'
assert_not_visible 'add33_title'
click 'css=img[alt=add]'
assert_visible 'add31_title'
type 'add31_title', 'add3'
assert_visible 'add33_title'
type 'add33_title', 'add3'
click 'css=input[type=submit]'
wait_for_not_visible 'add31_title'
wait_for_not_visible 'add33_title'
verify_text 'css=.add3 a', 'add3'
# should have correct parent
verify_text 'css=.add3 span', 'Kill the bugs'

# Add a second element
assert_not_visible 'add31_title'
assert_not_visible 'add33_title'
click 'css=img[alt=add]'
assert_visible 'add31_title'
type 'add31_title', 'add3_2'
assert_visible 'add33_title'
type 'add33_title', 'add3_2'
click 'css=input[type=submit]'
wait_for_not_visible 'add31_title'
wait_for_not_visible 'add33_title'
verify_text 'css=.add3_2 a', 'add3_2'
# should have correct parent
verify_text 'css=.add3_2 span', 'Kill the bugs'
24 changes: 12 additions & 12 deletions test/selenium/Drop/drop1.rsel
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
open "/oo/testnode37.html?test=drop1"
open '/oo/testnode37.html?test=drop1'
assert_element_not_present 'drop13_33'

# Drag & Drop
set_timeout 4000
drag_and_drop_to_object "css=#drop11_33 > span.drag_handle", "drop12"
wait_for_element_present "drop13_33"
verify_text "drop13_33", "Art"
drag_and_drop_to_object 'css=#drop11_33 > span.drag_handle', 'drop12'
wait_for_element_present 'drop13_33'
verify_text 'drop13_33', 'Art'
# Unlink
click "css=img[alt=remove]"
wait_for_element_not_present "drop13_33"
click 'css=img[alt=remove]'
wait_for_element_not_present 'drop13_33'

# Restart

# Drag & Drop
drag_and_drop_to_object "css=#drop11_33 > span.drag_handle", "drop12"
wait_for_element_present "drop13_33"
verify_text "drop13_33", "Art"
drag_and_drop_to_object 'css=#drop11_33 > span.drag_handle', 'drop12'
wait_for_element_present 'drop13_33'
verify_text 'drop13_33', 'Art'

# Make sure the changes are commited to db
open "/oo/testnode37.html?test=drop1"
open '/oo/testnode37.html?test=drop1'
assert_element_present 'drop13_33'
# Unlink
click "css=img[alt=remove]"
wait_for_element_not_present "drop13_33"
click 'css=img[alt=remove]'
wait_for_element_not_present 'drop13_33'
26 changes: 13 additions & 13 deletions test/selenium/Drop/drop2.rsel
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
open "/oo/testnode37.html?test=drop2"
open '/oo/testnode37.html?test=drop2'
assert_element_not_present 'drop22_29_33'

# Drag & Drop
set_timeout 4000
command 'setSpeed', 10
drag_and_drop_to_object "css=#drop21_33 > span.drag_handle", "drop22_29"
wait_for_element_present "drop22_29_33"
verify_text "drop22_29_33", "Art"
drag_and_drop_to_object 'css=#drop21_33 > span.drag_handle', 'drop22_29'
wait_for_element_present 'drop22_29_33'
verify_text 'drop22_29_33', 'Art'
# Unlink
click "css=#drop22_29_33 img[alt=remove]"
wait_for_element_not_present "drop22_29_33"
click 'css=#drop22_29_33 img[alt=remove]'
wait_for_element_not_present 'drop22_29_33'

# Drag in other target

# Drag & Drop
drag_and_drop_to_object "css=#drop21_33 > span.drag_handle", "drop22_21"
wait_for_element_present "drop22_21_33"
verify_text "drop22_21_33", "Art"
drag_and_drop_to_object 'css=#drop21_33 > span.drag_handle', 'drop22_21'
wait_for_element_present 'drop22_21_33'
verify_text 'drop22_21_33', 'Art'

# Make sure the changes are commited to db
open "/oo/testnode37.html?test=drop2"
assert_element_present 'drop23_21_33'
open '/oo/testnode37.html?test=drop2'
assert_element_present 'drop22_21_33'
# Should be
# assert_element_present 'drop22_21_33'
# Unlink
click "css=#drop23_21_33 img[alt=remove]"
wait_for_element_not_present "drop23_21_33"
click 'css=#drop22_21_33 img[alt=remove]'
wait_for_element_not_present 'drop22_21_33'

command 'setSpeed', 0
34 changes: 17 additions & 17 deletions test/selenium/Drop/drop3.rsel
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
# Drag from list in each.
open "/oo/testnode37.html?test=drop3"
open '/oo/testnode37.html?test=drop3'
assert_element_not_present 'drop33_26'

# Drag & Drop
set_timeout 4000
drag_and_drop_to_object "css=#drop12_21_26 > span.drag_handle", "drop32"
wait_for_element_present "drop33_26"
verify_text "drop33_26", "crocodiles"
drag_and_drop_to_object 'css=#drop12_21_26 > span.drag_handle', 'drop32'
wait_for_element_present 'drop33_26'
verify_text 'drop33_26', 'crocodiles'
# Unlink
click "css=img[alt=remove]"
wait_for_element_not_present "drop33_26"
click 'css=img[alt=remove]'
wait_for_element_not_present 'drop33_26'

# Restart

# Drag & Drop
drag_and_drop_to_object "css=#drop12_21_26 > span.drag_handle", "drop32"
wait_for_element_present "drop33_26"
verify_text "drop33_26", "crocodiles"
drag_and_drop_to_object 'css=#drop12_21_26 > span.drag_handle', 'drop32'
wait_for_element_present 'drop33_26'
verify_text 'drop33_26', 'crocodiles'

# Drag & Drop from other location
command 'setSpeed', 800
drag_and_drop_to_object "css=#drop12_11_12 > span.drag_handle", "drop32"
wait_for_element_present "drop33_12"
verify_text "drop33_12", "people"
drag_and_drop_to_object 'css=#drop12_11_12 > span.drag_handle', 'drop32'
wait_for_element_present 'drop33_12'
verify_text 'drop33_12', 'people'
command 'setSpeed', 0

# Make sure the changes are commited to db
open "/oo/testnode37.html?test=drop3"
open '/oo/testnode37.html?test=drop3'
assert_element_present 'drop33_26'
assert_element_present 'drop33_12'
# Unlink
click "css=#drop33_26 img[alt=remove]"
wait_for_element_not_present "drop33_26"
click "css=#drop33_12 img[alt=remove]"
wait_for_element_not_present "drop33_12"
click 'css=#drop33_26 img[alt=remove]'
wait_for_element_not_present 'drop33_26'
click 'css=#drop33_12 img[alt=remove]'
wait_for_element_not_present 'drop33_12'
2 changes: 1 addition & 1 deletion test/selenium/Drop/drop4.rsel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Drag from list in each.
open "/oo/testnode37.html?test=drop4"
assert_element_not_present 'drop43_26'
assert_element_not_present 'drop44_26'

# Drag & Drop
set_timeout 4000
Expand Down
18 changes: 9 additions & 9 deletions test/selenium/Edit/edit2.rsel
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@

open '/oo/testnode37.html?test=edit2'
set_timeout 4000
assert_element_not_present 'edit21_title'
assert_element_not_present 'edit22_title'
verify_text "css=#edit21 li.title", @old_title

# edit (does not click on 'v_status' checkbox)
click 'link=edit'
wait_for_element_present 'edit21_title'
type 'edit21_title', @new_title
wait_for_element_present 'edit22_title'
type 'edit22_title', @new_title

# submit
click 'css=input[type=submit]'
wait_for_element_not_present 'edit21_title'
wait_for_element_not_present 'edit22_title'
verify_text "css=#edit21 li.title", @new_title

# edit again (click on 'v_status' checkbox)
click 'link=edit'
wait_for_element_present 'edit21_title'
wait_for_element_present 'edit22_title'

# cancel
click 'css=img[alt="cancel"]'
wait_for_element_not_present 'edit21_title'
wait_for_element_not_present 'edit22_title'

# edit again
click 'link=edit'
wait_for_element_present 'edit21_title'
type 'edit21_title', @old_title
wait_for_element_present 'edit22_title'
type 'edit22_title', @old_title
click 'css=#edit2 input[type=checkbox]'

# submit
click 'css=input[type=submit]'
wait_for_element_not_present 'edit21_title'
wait_for_element_not_present 'edit22_title'
verify_text "css=#edit21 li.title", @old_title

# ensure page is published
Expand Down
18 changes: 9 additions & 9 deletions test/selenium/Edit/edit5.rsel
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@

open '/oo/testnode37.html?test=edit5'
set_timeout 4000
assert_element_not_present 'edit51_title'
assert_element_not_present 'edit52_title'
verify_text "css=#edit51_32 .title", @old_title

# edit
click 'link=edit'
wait_for_element_present 'edit51_title'
type 'edit51_title', @new_title
wait_for_element_present 'edit52_title'
type 'edit52_title', @new_title

# submit
click 'css=input[type=submit]'
wait_for_element_not_present 'edit51_title'
wait_for_element_not_present 'edit52_title'
verify_text "css=#edit51_32 .title", @new_title

# edit again
click 'link=edit'
wait_for_element_present 'edit51_title'
wait_for_element_present 'edit52_title'

# cancel
click 'css=img[alt="cancel"]'
wait_for_element_not_present 'edit51_title'
wait_for_element_not_present 'edit52_title'

# edit again
click 'link=edit'
wait_for_element_present 'edit51_title'
wait_for_element_present 'edit52_title'
# Ensure we do proper ajax replacements
assert_element_not_present 'css=#edit5 form form'
type 'edit51_title', @old_title
type 'edit52_title', @old_title

# submit
click 'css=input[type=submit]'
wait_for_element_not_present 'edit51_title'
wait_for_element_not_present 'edit52_title'
verify_text "css=#edit51_32 .title", @old_title

# ensure changes are recorded
Expand Down
16 changes: 8 additions & 8 deletions test/selenium/Edit/edit6.rsel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

open '/oo/testnode37.html?test=edit6'
set_timeout 4000
assert_element_not_present 'edit61_title'
assert_element_not_present 'edit63_title'
verify_text "css=#edit61_32 .title", @old_title

# swap block should work before edit
Expand All @@ -14,8 +14,8 @@ verify_text "css=#edit62_32 span", 'bob'

# edit
click 'link=edit'
wait_for_element_present 'edit61_title'
type 'edit61_title', @new_title
wait_for_element_present 'edit63_title'
type 'edit63_title', @new_title

# submit
click 'css=input[type=submit]'
Expand All @@ -25,22 +25,22 @@ verify_text "css=#edit62_32 span", 'bob'

# edit again
click 'link=edit'
wait_for_element_present 'edit61_title'
wait_for_element_present 'edit63_title'

# cancel
click 'css=img[alt="cancel"]'
wait_for_element_not_present 'edit61_title'
wait_for_element_not_present 'edit63_title'

# edit again
click 'link=edit'
wait_for_element_present 'edit61_title'
wait_for_element_present 'edit63_title'
# Ensure we do proper ajax replacements
assert_element_not_present 'css=#edit6 form form'
type 'edit61_title', @old_title
type 'edit63_title', @old_title

# submit
click 'css=input[type=submit]'
wait_for_element_not_present 'edit61_title'
wait_for_element_not_present 'edit63_title'
verify_text "css=#edit61_32 .title", @old_title

# swap block should work after edit
Expand Down

0 comments on commit 7ccc951

Please sign in to comment.