Select the correct vehicle/ordnance when the OK button is clicked.

master
Pacman Ghost 6 years ago
parent c957f03739
commit 7871cec1e5
  1. 12
      vasl_templates/webapp/static/vo.js
  2. 7
      vasl_templates/webapp/tests/test_vehicles_ordnance.py

@ -31,7 +31,7 @@ function add_vo( vo_type, player_no )
var div_class = "vo-entry" ;
if ( is_small_vasl_piece( vo_entry ) )
div_class += " small-piece" ;
var buf2 = [ "<div class='" + div_class + "'>",
var buf2 = [ "<div class='" + div_class + "' data-index='" + opt.id + "'>",
"<img src='" + _get_vo_image_url(vo_entry,null) + "' class='vasl-image'>",
"<div class='content'><div>",
vo_entry.name,
@ -101,12 +101,14 @@ function add_vo( vo_type, player_no )
buttons: {
OK: function() {
// add the new vehicle/ordnance
var data = $sel.select2( "data" ) ;
if ( ! data )
// FUDGE! $sel.select("data") returns the wrong thing if the entries are filtered?!?!
var $elem = $( "#select-vo .select2-results__option--highlighted" ) ;
if ( $elem.length === 0 )
return ;
var $img = $( "#"+data[0]._resultId ).find( "img[class='vasl-image']" ) ;
var sel_index = $elem.children( ".vo-entry" ).data( "index" ) ;
var $img = $elem.find( "img[class='vasl-image']" ) ;
var vo_image_id = $img.data( "vo-image-id" ) ;
do_add_vo( vo_type, player_no, entries[data[0].id], vo_image_id ) ;
do_add_vo( vo_type, player_no, entries[sel_index], vo_image_id ) ;
$(this).dialog( "close" ) ;
},
Cancel: function() { $(this).dialog( "close" ) ; },

@ -7,6 +7,7 @@ import json
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import WebDriverException
from vasl_templates.webapp.tests.test_scenario_persistence import load_scenario, save_scenario
from vasl_templates.webapp.tests.utils import \
@ -485,9 +486,13 @@ def add_vo( webdriver, vo_type, player_no, name ):
assert len(matches) == 1
elem = matches[0]
webdriver.execute_script( "arguments[0].scrollIntoView()", elem )
# FUDGE! Selecting the required entry is flaky, and we sometimes need to do it twice (Firefox :-/).
ActionChains( webdriver ).click( elem ).perform()
try:
ActionChains( webdriver ).click( elem ).perform()
except WebDriverException as ex:
assert "TypeError: rect is undefined" in str(ex)
if find_child( "#select-vo" ).is_displayed():
# FUDGE! Clicking on the element sometimes make the dialog close :-/
click_dialog_button( "OK" )
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Loading…
Cancel
Save