Renamed VEHICLES and ORDNANCE as OB_VEHICLES and OB_ORDNANCE.

master
Pacman Ghost 6 years ago
parent 30df02d542
commit e320f6513a
  1. 2
      vasl_templates/webapp/data/default-template-pack/ob_ordnance.j2
  2. 2
      vasl_templates/webapp/data/default-template-pack/ob_vehicles.j2
  3. 12
      vasl_templates/webapp/static/css/tabs-ob.css
  4. 38
      vasl_templates/webapp/static/main.js
  5. 2
      vasl_templates/webapp/static/simple_notes.js
  6. 82
      vasl_templates/webapp/static/snippets.js
  7. 8
      vasl_templates/webapp/static/sortable.js
  8. 6
      vasl_templates/webapp/static/vo.js
  9. 32
      vasl_templates/webapp/templates/index.html
  10. 2
      vasl_templates/webapp/tests/fixtures/data/default-template-pack/ob_ordnance.j2
  11. 2
      vasl_templates/webapp/tests/fixtures/data/default-template-pack/ob_vehicles.j2
  12. 16
      vasl_templates/webapp/tests/fixtures/new-default-scenario.json
  13. 1
      vasl_templates/webapp/tests/fixtures/template-packs/full/ob_ordnance.j2
  14. 1
      vasl_templates/webapp/tests/fixtures/template-packs/full/ob_vehicles.j2
  15. 1
      vasl_templates/webapp/tests/fixtures/template-packs/full/ordnance.j2
  16. 1
      vasl_templates/webapp/tests/fixtures/template-packs/full/vehicles.j2
  17. 1
      vasl_templates/webapp/tests/fixtures/template-packs/new-default/ob_ordnance.j2
  18. 1
      vasl_templates/webapp/tests/fixtures/template-packs/new-default/ob_vehicles.j2
  19. 1
      vasl_templates/webapp/tests/fixtures/template-packs/new-default/ordnance.j2
  20. 1
      vasl_templates/webapp/tests/fixtures/template-packs/new-default/vehicles.j2
  21. 16
      vasl_templates/webapp/tests/test_default_scenario.py
  22. 8
      vasl_templates/webapp/tests/test_dirty_scenario_checks.py
  23. 8
      vasl_templates/webapp/tests/test_players.py
  24. 48
      vasl_templates/webapp/tests/test_scenario_persistence.py
  25. 20
      vasl_templates/webapp/tests/test_vehicles_ordnance.py
  26. 19
      vasl_templates/webapp/tests/utils.py

@ -8,7 +8,7 @@ td { margin: 0 ; padding: 0 ; }
</head>
<table style="
{%if ORDNANCE_WIDTH%} width: {{ORDNANCE_WIDTH}} ; {%endif%}
{%if OB_ORDNANCE_WIDTH%} width: {{OB_ORDNANCE_WIDTH}} ; {%endif%}
">
<tr>

@ -8,7 +8,7 @@ td { margin: 0 ; padding: 0 ; }
</head>
<table style="
{%if VEHICLES_WIDTH%} width: {{VEHICLES_WIDTH}} ; {%endif%}
{%if OB_VEHICLES_WIDTH%} width: {{OB_VEHICLES_WIDTH}} ; {%endif%}
">
<tr>

@ -12,12 +12,12 @@
/* -------------------------------------------------------------------- */
.panel-vehicles { height: 100% ; display: flex ; flex-direction: column ; }
.panel-vehicles .content { flex-grow: 1 ; }
.panel-vehicles .footer { margin-top: 0.5em ; display: flex ; align-items: center ; }
.panel-ob_vehicles { height: 100% ; display: flex ; flex-direction: column ; }
.panel-ob_vehicles .content { flex-grow: 1 ; }
.panel-ob_vehicles .footer { margin-top: 0.5em ; display: flex ; align-items: center ; }
/* -------------------------------------------------------------------- */
.panel-ordnance { height: 100% ; display: flex ; flex-direction: column ; }
.panel-ordnance .content { flex-grow: 1 ; }
.panel-ordnance .footer { margin-top: 0.5em ; display: flex ; align-items: center ; }
.panel-ob_ordnance { height: 100% ; display: flex ; flex-direction: column ; }
.panel-ob_ordnance .content { flex-grow: 1 ; }
.panel-ob_ordnance .footer { margin-top: 0.5em ; display: flex ; align-items: center ; }

@ -127,18 +127,18 @@ $(document).ready( function () {
} ) ;
// initialize the OB vehicles
$("#vehicles-sortable_1").sortable2( "init", {
$("#ob_vehicles-sortable_1").sortable2( "init", {
add: function() { add_vo( "vehicles", 1 ) ; },
} ) ;
$("#vehicles-sortable_2").sortable2( "init", {
$("#ob_vehicles-sortable_2").sortable2( "init", {
add: function() { add_vo( "vehicles", 2 ) ; },
} ) ;
// initialize the OB ordnance
$("#ordnance-sortable_1").sortable2( "init", {
$("#ob_ordnance-sortable_1").sortable2( "init", {
add: function() { add_vo( "ordnance", 1 ) ; },
} ) ;
$("#ordnance-sortable_2").sortable2( "init", {
$("#ob_ordnance-sortable_2").sortable2( "init", {
add: function() { add_vo( "ordnance", 2 ) ; },
} ) ;
@ -192,13 +192,13 @@ $(document).ready( function () {
// get the vehicle/ordnance listings
$.getJSON( gVehicleListingsUrl, function(data) {
gVehicleOrdnanceListings.vehicles = data ;
update_page_load_status( "vehicles" ) ;
update_page_load_status( "vehicle-listings" ) ;
} ).fail( function( xhr, status, errorMsg ) {
showErrorMsg( "Can't get the vehicle listings:<div class='pre'>" + escapeHTML(errorMsg) + "</div>" ) ;
} ) ;
$.getJSON( gOrdnanceListingsUrl, function(data) {
gVehicleOrdnanceListings.ordnance = data ;
update_page_load_status( "ordnance" ) ;
update_page_load_status( "ordnance-listings" ) ;
} ).fail( function( xhr, status, errorMsg ) {
showErrorMsg( "Can't get the ordnance listings:<div class='pre'>" + escapeHTML(errorMsg) + "</div>" ) ;
} ) ;
@ -253,10 +253,10 @@ $(document).ready( function () {
var template_id2 ;
if ( template_id.substring(0,9) === "ob_setup_" )
template_id2 = "ob_setup" ;
else if ( template_id.substring(0,9) == "vehicles_" )
template_id2 = "vehicles" ;
else if ( template_id.substring(0,9) == "ordnance_" )
template_id2 = "ordnance" ;
else if ( template_id.substring(0,12) == "ob_vehicles_" )
template_id2 = "ob_vehicles" ;
else if ( template_id.substring(0,12) == "ob_ordnance_" )
template_id2 = "ob_ordnance" ;
else
template_id2 = template_id ;
var buf = [ "<div class='snippet-control' data-id='" + template_id + "'>",
@ -333,10 +333,10 @@ $(document).ready( function () {
var template_id = $(this).attr( "data-id" ) ;
if ( template_id.substring(0,9) === "ob_setup_" )
template_id = "ob_setup" ;
else if ( template_id.substring(0,9) === "vehicles_" )
template_id = "vehicles" ;
else if ( template_id.substring(0,9) === "ordnance_" )
template_id = "ordnance" ;
else if ( template_id.substring(0,12) === "ob_vehicles_" )
template_id = "ob_vehicles" ;
else if ( template_id.substring(0,12) === "ob_ordnance_" )
template_id = "ob_ordnance" ;
$( "<a href='#' class='_edit-template-link_' data-id='" + template_id + "'" +
" onclick='edit_template(\"" + template_id + "\")'" +
"></a>"
@ -351,7 +351,7 @@ $(document).ready( function () {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
gPageLoadStatus = [ "main", "vehicles", "ordnance", "template-pack", "default-scenario" ] ;
gPageLoadStatus = [ "main", "vehicle-listings", "ordnance-listings", "template-pack", "default-scenario" ] ;
function update_page_load_status( id )
{
@ -477,10 +477,10 @@ function on_player_change( player_no )
$( "#ob_setups-sortable_" + player_no ).sortable2( "delete-all" ) ;
$("input[name='OB_SETUP_WIDTH_"+player_no+"']").val( "" ) ;
$( "#ob_notes-sortable_" + player_no ).sortable2( "delete-all" ) ;
$( "#vehicles-sortable_" + player_no ).sortable2( "delete-all" ) ;
$("input[name='VEHICLES_WIDTH_"+player_no+"']").val( "" ) ;
$( "#ordnance-sortable_" + player_no ).sortable2( "delete-all" ) ;
$("input[name='ORDNANCE_WIDTH_"+player_no+"']").val( "" ) ;
$( "#ob_vehicles-sortable_" + player_no ).sortable2( "delete-all" ) ;
$("input[name='OB_VEHICLES_WIDTH_"+player_no+"']").val( "" ) ;
$( "#ob_ordnance-sortable_" + player_no ).sortable2( "delete-all" ) ;
$("input[name='OB_ORDNANCE_WIDTH_"+player_no+"']").val( "" ) ;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

@ -150,6 +150,6 @@ function _get_note_type_for_sortable( $sortable2 )
{
// figure out what type of note the sortable has
var id = $sortable2.prop( "id" ) ;
var match = /^((scenario_notes|ssr|vehicles|ob_setups|ob_notes))-sortable(_\d)?$/.exec( id ) ;
var match = /^((scenario_notes|ssr|ob_vehicles|ob_ordnance|ob_setups|ob_notes))-sortable(_\d)?$/.exec( id ) ;
return match[1] ;
}

@ -59,23 +59,23 @@ function generate_snippet( $btn, extra_params )
}
// set player-specific parameters
if ( template_id == "vehicles_1" ) {
template_id = "vehicles" ;
params.VEHICLES = params.VEHICLES_1 ;
params.VEHICLES_WIDTH = params.VEHICLES_WIDTH_1 ;
} else if ( template_id == "vehicles_2" ) {
template_id = "vehicles" ;
params.VEHICLES = params.VEHICLES_2 ;
params.VEHICLES_WIDTH = params.VEHICLES_WIDTH_2 ;
}
if ( template_id == "ordnance_1" ) {
template_id = "ordnance" ;
params.ORDNANCE = params.ORDNANCE_1 ;
params.ORDNANCE_WIDTH = params.ORDNANCE_WIDTH_1 ;
} else if ( template_id == "ordnance_2" ) {
template_id = "ordnance" ;
params.ORDNANCE = params.ORDNANCE_2 ;
params.ORDNANCE_WIDTH = params.ORDNANCE_WIDTH_2 ;
if ( template_id == "ob_vehicles_1" ) {
template_id = "ob_vehicles" ;
params.OB_VEHICLES = params.OB_VEHICLES_1 ;
params.OB_VEHICLES_WIDTH = params.OB_VEHICLES_WIDTH_1 ;
} else if ( template_id == "ob_vehicles_2" ) {
template_id = "ob_vehicles" ;
params.OB_VEHICLES = params.OB_VEHICLES_2 ;
params.OB_VEHICLES_WIDTH = params.OB_VEHICLES_WIDTH_2 ;
}
if ( template_id == "ob_ordnance_1" ) {
template_id = "ob_ordnance" ;
params.OB_ORDNANCE = params.OB_ORDNANCE_1 ;
params.OB_ORDNANCE_WIDTH = params.OB_ORDNANCE_WIDTH_1 ;
} else if ( template_id == "ob_ordnance_2" ) {
template_id = "ob_ordnance" ;
params.OB_ORDNANCE = params.OB_ORDNANCE_2 ;
params.OB_ORDNANCE_WIDTH = params.OB_ORDNANCE_WIDTH_2 ;
}
// include the player display names
@ -209,7 +209,7 @@ function unload_snippet_params( params, check_date_capabilities )
// collect the vehicles/ordnance
function get_vo( vo_type, player_no, key ) {
var $sortable2 = $( "#" + vo_type + "-sortable_" + player_no ) ;
var $sortable2 = $( "#ob_" + vo_type + "-sortable_" + player_no ) ;
var objs = [] ;
$sortable2.children( "li" ).each( function() {
var entry = $(this).data( "sortable2-data" ).vo_entry ;
@ -241,10 +241,10 @@ function unload_snippet_params( params, check_date_capabilities )
if ( objs.length > 0 )
params[key] = objs ;
}
get_vo( "vehicles", 1, "VEHICLES_1" ) ;
get_vo( "vehicles", 2, "VEHICLES_2" ) ;
get_vo( "ordnance", 1, "ORDNANCE_1" ) ;
get_vo( "ordnance", 2, "ORDNANCE_2" ) ;
get_vo( "vehicles", 1, "OB_VEHICLES_1" ) ;
get_vo( "vehicles", 2, "OB_VEHICLES_2" ) ;
get_vo( "ordnance", 1, "OB_ORDNANCE_1" ) ;
get_vo( "ordnance", 2, "OB_ORDNANCE_2" ) ;
return params ;
}
@ -404,10 +404,10 @@ function get_template( template_id )
function edit_template( template_id )
{
// get the specified template
if ( template_id.substring(0,9) == "ordnance_" )
template_id = "ordnance" ;
else if ( template_id.substring(0,9) == "vehicles_" )
template_id = "vehicles" ;
if ( template_id.substring(0,12) == "ob_ordnance_" )
template_id = "ob_ordnance" ;
else if ( template_id.substring(0,12) == "ob_vehicles_" )
template_id = "ob_vehicles" ;
var template = get_template( template_id ) ;
if ( template === null )
return ;
@ -509,11 +509,16 @@ function do_load_scenario_data( params )
// load the scenario parameters
var params_loaded = {} ;
var warnings = [] ;
var unknown_vo = [] ;
var set_param = function( $elem, key ) {
if ( key === "SCENARIO_DATE" ) {
var scenario_date = $.datepicker.parseDate( "yy-mm-dd", params[key] ) ;
$elem.datepicker( "setDate", scenario_date ) ;
try {
var scenario_date = $.datepicker.parseDate( "yy-mm-dd", params[key] ) ;
$elem.datepicker( "setDate", scenario_date ) ;
} catch( ex ) {
warnings.push( "Invalid scenario date: " + escapeHTML( params[key] ) ) ;
}
}
else
$elem.val( params[key] ) ;
@ -564,10 +569,10 @@ function do_load_scenario_data( params )
params_loaded[key] = true ;
continue ;
}
if ( key === "VEHICLES_1" || key === "ORDNANCE_1" || key === "VEHICLES_2" || key === "ORDNANCE_2" ) {
if ( key === "OB_VEHICLES_1" || key === "OB_ORDNANCE_1" || key === "OB_VEHICLES_2" || key === "OB_ORDNANCE_2" ) {
player_no = key.substring( key.length-1 ) ;
var nat = params[ "PLAYER_" + player_no ] ;
var vo_type = (key.substring(0,9) === "VEHICLES_") ? "vehicles" : "ordnance" ;
var vo_type = (key.substring(0,12) === "OB_VEHICLES_") ? "vehicles" : "ordnance" ;
for ( i=0 ; i < params[key].length ; ++i ) {
var entry = find_vo( vo_type, nat, params[key][i] ) ;
if ( entry )
@ -611,6 +616,15 @@ function do_load_scenario_data( params )
) ) ;
}
// show any other warnings
if ( warnings.length == 1 )
showWarningMsg( warnings[0] ) ;
else if ( warnings.length > 1 ) {
showWarningMsg( makeBulletListMsg(
"", warnings
) ) ;
}
// remember the state of this scenario
gLastSavedScenario = unload_params_for_save() ;
@ -679,10 +693,10 @@ function unload_params_for_save()
params.OB_SETUPS_2 = $("#ob_setups-sortable_2").sortable2( "get-entry-data" ) ;
params.OB_NOTES_1 = $("#ob_notes-sortable_1").sortable2( "get-entry-data" ) ;
params.OB_NOTES_2 = $("#ob_notes-sortable_2").sortable2( "get-entry-data" ) ;
extract_vo_names( "VEHICLES_1" ) ;
extract_vo_names( "ORDNANCE_1" ) ;
extract_vo_names( "VEHICLES_2" ) ;
extract_vo_names( "ORDNANCE_2" ) ;
extract_vo_names( "OB_VEHICLES_1" ) ;
extract_vo_names( "OB_ORDNANCE_1" ) ;
extract_vo_names( "OB_VEHICLES_2" ) ;
extract_vo_names( "OB_ORDNANCE_2" ) ;
// save the scenario date in ISO-8601 format
var scenario_date = $("input[name='SCENARIO_DATE']").datepicker( "getDate" ) ;

@ -3,8 +3,8 @@ SORTABLE_DISPLAY_NAMES = {
ssr: [ "SSR", "SSR's", "a" ],
ob_setups: [ "OB setup note", "OB setup notes", "an" ],
ob_notes: [ "OB setup note", "OB setup notes", "an" ],
vehicles: [ "vehicle", "vehicles", "a" ],
ordnance: [ "ordnance", "ordnance", "an" ],
ob_vehicles: [ "vehicle", "vehicles", "a" ],
ob_ordnance: [ "ordnance", "ordnance", "an" ],
} ;
SORTABLE_HINTS = {
@ -12,8 +12,8 @@ SORTABLE_HINTS = {
ssr: "Add scenario SSR's here.",
ob_setups: "Add setup notes for the player's OB here.",
ob_notes: "Add miscellaneous setup notes here.",
vehicles: "Add vehicles in the player's OB here.",
ordnance: "Add ordnance in the player's OB here.",
ob_vehicles: "Add vehicles in the player's OB here.",
ob_ordnance: "Add ordnance in the player's OB here.",
} ;
// --------------------------------------------------------------------

@ -4,7 +4,7 @@
function add_vo( vo_type, player_no )
{
// get the vehicles/ordnance already added
var $sortable2 = $( "#" + vo_type + "-sortable_" + player_no ) ;
var $sortable2 = $( "#ob_" + vo_type + "-sortable_" + player_no ) ;
var vo_present = [];
$sortable2.children("li").each( function() {
vo_present.push( $(this).text() ) ;
@ -30,7 +30,7 @@ function add_vo( vo_type, player_no )
// let the user select a vehicle/ordnance
$("#select-vo").dialog( {
title: "Add " + SORTABLE_DISPLAY_NAMES[vo_type][0],
title: "Add " + SORTABLE_DISPLAY_NAMES["ob_"+vo_type][0],
dialogClass: "select-vo",
modal: true,
minWidth: 300,
@ -64,7 +64,7 @@ function add_vo( vo_type, player_no )
function do_add_vo( vo_type, player_no, entry )
{
// add the specified vehicle/ordnance
var $sortable2 = $( "#" + vo_type + "-sortable_" + player_no ) ;
var $sortable2 = $( "#ob_" + vo_type + "-sortable_" + player_no ) ;
$sortable2.sortable2( "add", {
content: $( "<div>" + entry.name + "</div>" ),
data: { caption: entry.name, vo_entry: entry },

@ -191,38 +191,38 @@
<div class="right">
<fieldset class="tr"> <legend>Vehicles</legend>
<div id="panel-vehicles_1" class="panel-vehicles">
<div id="panel-ob_vehicles_1" class="panel-ob_vehicles">
<div class="content">
<div id="vehicles-hint_1" class="sortable-hint"></div>
<ul id="vehicles-sortable_1" class="sortable" style="display:none;"></ul>
<div id="ob_vehicles-hint_1" class="sortable-hint"></div>
<ul id="ob_vehicles-sortable_1" class="sortable" style="display:none;"></ul>
</div>
<div class="footer">
<button id="vehicles-add_1" class="sortable-add"></button>
<img id="vehicles-trash_1" class="sortable-trash">
<button id="ob_vehicles-add_1" class="sortable-add"></button>
<img id="ob_vehicles-trash_1" class="sortable-trash">
<span class="spacer"></span>
<span class="small">
<label for="VEHICLES_WIDTH_1">Width:</label>
<input type="text" class="param" name="VEHICLES_WIDTH_1" size="5">
<button class="generate" data-id="vehicles_1">Snippet</button>
<label for="OB_VEHICLES_WIDTH_1">Width:</label>
<input type="text" class="param" name="OB_VEHICLES_WIDTH_1" size="5">
<button class="generate" data-id="ob_vehicles_1">Snippet</button>
</span>
</div>
</div>
</fieldset>
<fieldset class="br"> <legend>Ordnance</legend>
<div id="panel-ordnance_1" class="panel-ordnance">
<div id="panel-ob_ordnance_1" class="panel-ob_ordnance">
<div class="content">
<div id="ordnance-hint_1" class="sortable-hint"></div>
<ul id="ordnance-sortable_1" class="sortable" style="display:none;"></ul>
<div id="ob_ordnance-hint_1" class="sortable-hint"></div>
<ul id="ob_ordnance-sortable_1" class="sortable" style="display:none;"></ul>
</div>
<div class="footer">
<button id="ordnance-add_1" class="sortable-add"></button>
<img id="ordnance-trash_1" class="sortable-trash">
<button id="ob_ordnance-add_1" class="sortable-add"></button>
<img id="ob_ordnance-trash_1" class="sortable-trash">
<span class="spacer"></span>
<span class="small">
<label for="ORDNANCE_WIDTH_1">Width:</label>
<input type="text" class="param" name="ORDNANCE_WIDTH_1" size="5">
<button class="generate" data-id="ordnance_1">Snippet</button>
<label for="OB_ORDNANCE_WIDTH_1">Width:</label>
<input type="text" class="param" name="OB_ORDNANCE_WIDTH_1" size="5">
<button class="generate" data-id="ob_ordnance_1">Snippet</button>
</span>
</div>
</div>

@ -1,4 +1,4 @@
[{{PLAYER_NAME}}] ; width={{ORDNANCE_WIDTH}}{%for ord in ORDNANCE %}
[{{PLAYER_NAME}}] ; width={{OB_ORDNANCE_WIDTH}}{%for ord in OB_ORDNANCE %}
[*] {{ord.name}}: #={{ord.note_number}}{%if ord.notes%}
- notes:{%for n in ord.notes%} "{{n}}"{%endfor%}{%endif%}{%if ord.capabilities%}
- capabilities:{%for c in ord.capabilities%} "{{c}}"{%endfor%}{%endif%}{%if ord.raw_capabilities%}

@ -1,4 +1,4 @@
[{{PLAYER_NAME}}] ; width={{VEHICLES_WIDTH}}{%for veh in VEHICLES %}
[{{PLAYER_NAME}}] ; width={{OB_VEHICLES_WIDTH}}{%for veh in OB_VEHICLES %}
[*] {{veh.name}}: #={{veh.note_number}}{%if veh.notes%}
- notes:{%for n in veh.notes%} "{{n}}"{%endfor%}{%endif%}{%if veh.crew_survival%}
- {{veh.crew_survival}}{%endif%}{%if veh.capabilities%}

@ -37,10 +37,10 @@
{ "caption": "default american OB note #1", "width": "103px" },
{ "caption": "default american OB note #2", "width": "104px" }
],
"VEHICLES_1": [],
"VEHICLES_WIDTH_1": "110px",
"ORDNANCE_1": [],
"ORDNANCE_WIDTH_1": "120px",
"OB_VEHICLES_1": [],
"OB_VEHICLES_WIDTH_1": "110px",
"OB_ORDNANCE_1": [],
"OB_ORDNANCE_WIDTH_1": "120px",
"OB_SETUPS_2": [
{ "caption": "default japanese OB setup #1", "width": "201px" },
@ -50,10 +50,10 @@
{ "caption": "default japanese OB note #1", "width": "203px" },
{ "caption": "default japanese OB note #2", "width": "204px" }
],
"VEHICLES_2": [],
"VEHICLES_WIDTH_2": "210px",
"ORDNANCE_2": [],
"ORDNANCE_WIDTH_2": "211px",
"OB_VEHICLES_2": [],
"OB_VEHICLES_WIDTH_2": "210px",
"OB_ORDNANCE_2": [],
"OB_ORDNANCE_WIDTH_2": "211px",
"_OB_SETUP_WIDTH": "900px",
"_OB_NOTE_WIDTH": "901px"

@ -77,10 +77,10 @@ def test_default_scenario( webapp, webdriver, monkeypatch ):
# nb: should check the snippet widths as well (not really important for a default scenario)
# check the vehicles/ordnance (player 1)
assert get_sortable_entry_text( find_child( "#vehicles-sortable_1" ) ) == []
check_textbox( "VEHICLES_WIDTH_1", "110px" )
assert get_sortable_entry_text( find_child( "#ordnance-sortable_1" ) ) == []
check_textbox( "ORDNANCE_WIDTH_1", "120px" )
assert get_sortable_entry_text( find_child( "#ob_vehicles-sortable_1" ) ) == []
check_textbox( "OB_VEHICLES_WIDTH_1", "110px" )
assert get_sortable_entry_text( find_child( "#ob_ordnance-sortable_1" ) ) == []
check_textbox( "OB_ORDNANCE_WIDTH_1", "120px" )
select_tab( "ob2" )
@ -92,10 +92,10 @@ def test_default_scenario( webapp, webdriver, monkeypatch ):
# nb: should check the snippet widths as well (not really important for a default scenario)
# check the vehicles/ordnance (player 2)
assert get_sortable_entry_text( find_child( "#vehicles-sortable_2" ) ) == []
check_textbox( "VEHICLES_WIDTH_2", "210px" )
assert get_sortable_entry_text( find_child( "#ordnance-sortable_2" ) ) == []
check_textbox( "ORDNANCE_WIDTH_2", "211px" )
assert get_sortable_entry_text( find_child( "#ob_vehicles-sortable_2" ) ) == []
check_textbox( "OB_VEHICLES_WIDTH_2", "210px" )
assert get_sortable_entry_text( find_child( "#ob_ordnance-sortable_2" ) ) == []
check_textbox( "OB_ORDNANCE_WIDTH_2", "211px" )
# check that the default OB setup/note width is being used
elem = find_child( "#ob_setups-add_2" )

@ -30,10 +30,10 @@ def test_dirty_scenario_checks( webapp, webdriver ):
"OB_NOTES_2": "#ob_notes-sortable_2",
}
VEHICLE_ORDNANCE = {
"VEHICLES_1": ( "#vehicles-sortable_1", 1, "a german vehicle" ),
"ORDNANCE_1": ( "#ordnance-sortable_1", 1, "a german ordnance" ),
"VEHICLES_2": ( "#vehicles-sortable_2", 2, "a russian vehicle" ),
"ORDNANCE_2": ( "#ordnance-sortable_2", 2, "a russian ordnance" ),
"OB_VEHICLES_1": ( "#ob_vehicles-sortable_1", 1, "a german vehicle" ),
"OB_ORDNANCE_1": ( "#ob_ordnance-sortable_1", 1, "a german ordnance" ),
"OB_VEHICLES_2": ( "#ob_vehicles-sortable_2", 2, "a russian vehicle" ),
"OB_ORDNANCE_2": ( "#ob_ordnance-sortable_2", 2, "a russian ordnance" ),
}
def change_field( param ):

@ -33,8 +33,8 @@ def test_player_change( webapp, webdriver ):
# check that we can change the player nationalities without being asked to confirm
# nb: the frontend ignores the vehicle/ordnance snippet widths when deciding if to ask for confirmation
VO_WIDTHS = {
"ob1": { "VEHICLES_WIDTH_1": 123 },
"ob2": { "ORDNANCE_WIDTH_2": 456 },
"ob1": { "OB_VEHICLES_WIDTH_1": 123 },
"ob2": { "OB_ORDNANCE_WIDTH_2": 456 },
}
load_scenario_params( VO_WIDTHS )
select_tab( "scenario" )
@ -49,7 +49,7 @@ def test_player_change( webapp, webdriver ):
"OB_SETUPS_1": [ { "caption": "an ob setup", "width": "" } ],
},
"ob2": {
"VEHICLES_2": [ "a german vehicle" ],
"OB_VEHICLES_2": [ "a german vehicle" ],
},
}
load_scenario_params( SCENARIO_PARAMS )
@ -58,7 +58,7 @@ def test_player_change( webapp, webdriver ):
"""Get the contents of the player's OB tab."""
sortables = [
find_child( "#{}-sortable_{}".format( key, player_no ) )
for key in ["ob_setups","ob_notes","vehicles","ordnance"]
for key in ["ob_setups","ob_notes","ob_vehicles","ob_ordnance"]
]
return [ get_sortable_entry_count(s) for s in sortables ]

@ -23,13 +23,13 @@ ALL_SCENARIO_PARAMS = {
],
"ob1": [
"OB_SETUPS_1", "OB_NOTES_1",
"VEHICLES_1", "VEHICLES_WIDTH_1",
"ORDNANCE_1", "ORDNANCE_WIDTH_1",
"OB_VEHICLES_1", "OB_VEHICLES_WIDTH_1",
"OB_ORDNANCE_1", "OB_ORDNANCE_WIDTH_1",
],
"ob2": [
"OB_SETUPS_2", "OB_NOTES_2",
"VEHICLES_2", "VEHICLES_WIDTH_2",
"ORDNANCE_2", "ORDNANCE_WIDTH_2",
"OB_VEHICLES_2", "OB_VEHICLES_WIDTH_2",
"OB_ORDNANCE_2", "OB_ORDNANCE_WIDTH_2",
],
}
@ -84,18 +84,18 @@ def test_scenario_persistence( webapp, webdriver ): #pylint: disable=too-many-st
{ "caption": "ob note 1a", "width": "10em" },
{ "caption": "ob note 1b", "width": "" }
],
"VEHICLES_1": [ "a russian vehicle", "another russian vehicle" ],
"VEHICLES_WIDTH_1": "202",
"ORDNANCE_1": [ "a russian ordnance", "another russian ordnance" ],
"ORDNANCE_WIDTH_1": "203",
"OB_VEHICLES_1": [ "a russian vehicle", "another russian vehicle" ],
"OB_VEHICLES_WIDTH_1": "202",
"OB_ORDNANCE_1": [ "a russian ordnance", "another russian ordnance" ],
"OB_ORDNANCE_WIDTH_1": "203",
},
"ob2": {
"OB_SETUPS_2": [ { "caption": "ob setup 2", "width": "" } ],
"OB_NOTES_2": [ { "caption": "ob note 2", "width": "" } ],
"VEHICLES_2": [ "a german vehicle" ],
"VEHICLES_WIDTH_2": "302",
"ORDNANCE_2": [ "a german ordnance" ],
"ORDNANCE_WIDTH_2": "303",
"OB_VEHICLES_2": [ "a german vehicle" ],
"OB_VEHICLES_WIDTH_2": "302",
"OB_ORDNANCE_2": [ "a german ordnance" ],
"OB_ORDNANCE_WIDTH_2": "303",
},
}
load_scenario_params( SCENARIO_PARAMS )
@ -139,8 +139,8 @@ def test_scenario_persistence( webapp, webdriver ): #pylint: disable=too-many-st
ssrs = find_child( "#ssr-sortable" )
ob_setups1, ob_notes1 = find_child("#ob_setups-sortable_1"), find_child("#ob_notes-sortable_1")
ob_setups2, ob_notes2 = find_child("#ob_setups-sortable_2"), find_child("#ob_notes-sortable_2")
vehicles1, ordnance1 = find_child("#vehicles-sortable_1"), find_child("#ordnance-sortable_1")
vehicles2, ordnance2 = find_child("#vehicles-sortable_2"), find_child("#ordnance-sortable_2")
vehicles1, ordnance1 = find_child("#ob_vehicles-sortable_1"), find_child("#ob_ordnance-sortable_1")
vehicles2, ordnance2 = find_child("#ob_vehicles-sortable_2"), find_child("#ob_ordnance-sortable_2")
elems = {
c.get_attribute("name"): c
for elem_type in ("input","textarea","select") for c in find_children(elem_type)
@ -158,7 +158,7 @@ def test_scenario_persistence( webapp, webdriver ): #pylint: disable=too-many-st
continue # nb: these require special handling, we do it below
if field in ("OB_SETUPS_1","OB_SETUPS_2","OB_NOTES_1","OB_NOTES_2"):
continue # nb: these require special handling, we do it below
if field in ("VEHICLES_1","ORDNANCE_1","VEHICLES_2","ORDNANCE_2"):
if field in ("OB_VEHICLES_1","OB_ORDNANCE_1","OB_VEHICLES_2","OB_ORDNANCE_2"):
continue # nb: these require special handling, we do it below
elem = elems[ field ]
if elem.tag_name == "select":
@ -172,13 +172,13 @@ def test_scenario_persistence( webapp, webdriver ): #pylint: disable=too-many-st
select_tab( "ob1" )
assert get_sortable_entry_text(ob_setups1) == [ obs["caption"] for obs in SCENARIO_PARAMS["ob1"]["OB_SETUPS_1"] ]
assert get_sortable_entry_text(ob_notes1) == [ obs["caption"] for obs in SCENARIO_PARAMS["ob1"]["OB_NOTES_1"] ]
assert get_sortable_entry_text(vehicles1) == SCENARIO_PARAMS["ob1"]["VEHICLES_1"]
assert get_sortable_entry_text(ordnance1) == SCENARIO_PARAMS["ob1"]["ORDNANCE_1"]
assert get_sortable_entry_text(vehicles1) == SCENARIO_PARAMS["ob1"]["OB_VEHICLES_1"]
assert get_sortable_entry_text(ordnance1) == SCENARIO_PARAMS["ob1"]["OB_ORDNANCE_1"]
select_tab( "ob2" )
assert get_sortable_entry_text(ob_setups2) == [ obs["caption"] for obs in SCENARIO_PARAMS["ob2"]["OB_SETUPS_2"] ]
assert get_sortable_entry_text(ob_notes2) == [ obs["caption"] for obs in SCENARIO_PARAMS["ob2"]["OB_NOTES_2"] ]
assert get_sortable_entry_text(vehicles2) == SCENARIO_PARAMS["ob2"]["VEHICLES_2"]
assert get_sortable_entry_text(ordnance2) == SCENARIO_PARAMS["ob2"]["ORDNANCE_2"]
assert get_sortable_entry_text(vehicles2) == SCENARIO_PARAMS["ob2"]["OB_VEHICLES_2"]
assert get_sortable_entry_text(ordnance2) == SCENARIO_PARAMS["ob2"]["OB_ORDNANCE_2"]
# ---------------------------------------------------------------------
@ -219,11 +219,11 @@ def test_unknown_vo( webapp, webdriver ):
# load a scenario that has unknown vehicles/ordnance
SCENARIO_PARAMS = {
"PLAYER_1": "german",
"VEHICLES_1": [ "unknown vehicle 1a", "unknown vehicle 1b" ],
"ORDNANCE_1": [ "unknown ordnance 1a", "unknown ordnance 1b" ],
"OB_VEHICLES_1": [ "unknown vehicle 1a", "unknown vehicle 1b" ],
"OB_ORDNANCE_1": [ "unknown ordnance 1a", "unknown ordnance 1b" ],
"PLAYER_2": "russian",
"VEHICLES_2": [ "unknown vehicle 2" ],
"ORDNANCE_2": [ "unknown ordnance 2" ],
"OB_VEHICLES_2": [ "unknown vehicle 2" ],
"OB_ORDNANCE_2": [ "unknown ordnance 2" ],
}
_ = set_stored_msg_marker( "_last-warning_" )
# nb: we haven't made any changes, so we shouldn't get asked to confirm the "load scenario" operation
@ -231,7 +231,7 @@ def test_unknown_vo( webapp, webdriver ):
last_warning = get_stored_msg( "_last-warning_" )
assert last_warning.startswith( "Unknown vehicles/ordnance:" )
for key,vals in SCENARIO_PARAMS.items():
if not key.startswith( ("VEHICLES_","ORDNANCE_") ):
if not key.startswith( ("OB_VEHICLES_","OB_ORDNANCE_") ):
continue
assert all( v in last_warning for v in vals )

@ -54,7 +54,7 @@ def test_crud( webapp, webdriver ):
def _set_width( vo_type, player_no, width ):
"""Set the snippet width."""
select_tab( "ob{}".format( player_no ) )
elem = find_child( "input[name='{}_WIDTH_{}']".format( vo_type.upper(), player_no ) )
elem = find_child( "input[name='OB_{}_WIDTH_{}']".format( vo_type.upper(), player_no ) )
elem.clear()
if width is not None:
elem.send_keys( str(width) )
@ -64,7 +64,7 @@ def test_crud( webapp, webdriver ):
"""Check the generated vehicle/ordnance snippet."""
# check the snippet
select_tab( "ob{}".format( player_no ) )
btn = find_child( "button[data-id='{}_{}']".format( vo_type, player_no ) )
btn = find_child( "button[data-id='ob_{}_{}']".format( vo_type, player_no ) )
btn.click()
buf = get_clipboard()
names = [
@ -83,7 +83,7 @@ def test_crud( webapp, webdriver ):
def _check_hint( vo_type, player_no ):
"""Check the hint visibility."""
hint = find_child( "#{}-hint_{}".format( vo_type, player_no ) )
hint = find_child( "#ob_{}-hint_{}".format( vo_type, player_no ) )
expected = "none" if _expected[(vo_type,player_no)] else "block"
assert hint.value_of_css_property("display") == expected
@ -133,7 +133,7 @@ def test_snippets( webapp, webdriver ):
vo_type0 = vo_type[:-1] if vo_type.endswith("s") else vo_type
# test a full example
add_vo( vo_type, 1, "a german {}".format(vo_type) )
btn = find_child( "button[data-id='{}_1']".format( vo_type ) )
btn = find_child( "button[data-id='ob_{}_1']".format( vo_type ) )
btn.click()
expected = [
'[German] ; width=',
@ -149,7 +149,7 @@ def test_snippets( webapp, webdriver ):
# test a partial example
add_vo( vo_type, 1, "another german {}".format(vo_type) )
btn = find_child( "button[data-id='{}_1']".format( vo_type ) )
btn = find_child( "button[data-id='ob_{}_1']".format( vo_type ) )
btn.click()
expected = [
'[German] ; width=',
@ -164,7 +164,7 @@ def test_snippets( webapp, webdriver ):
# test a minimal example
add_vo( vo_type, 1, "name only" )
btn = find_child( "button[data-id='{}_1']".format( vo_type ) )
btn = find_child( "button[data-id='ob_{}_1']".format( vo_type ) )
btn.click()
assert get_clipboard() == \
'''[German] ; width=
@ -186,7 +186,7 @@ def test_variable_capabilities( webapp, webdriver ):
add_vo( "vehicles", 2, "Churchill III(b)" )
# change the scenario date and check the generated snippet
vehicles2 = find_child( "button.generate[data-id='vehicles_2']" )
vehicles2 = find_child( "button.generate[data-id='ob_vehicles_2']" )
def do_test( month, year, expected ):
"""Set the date and check the vehicle snippet."""
select_tab( "scenario" )
@ -215,7 +215,7 @@ def add_vo( vo_type, player_no, name ):
# add the vehicle/ordnance
select_tab( "ob{}".format( player_no ) )
elem = find_child( "#{}-add_{}".format( vo_type, player_no ) )
elem = find_child( "#ob_{}-add_{}".format( vo_type, player_no ) )
elem.click()
sel = Select( find_child( "#select-vo select" ) )
sel.select_by_visible_text( name[:-1] if name.endswith("s") else name )
@ -229,10 +229,10 @@ def delete_vo( vo_type, player_no, name, webdriver ):
# delete the vehicle/ordnance
select_tab( "ob{}".format( player_no ) )
elems = [
c for c in find_children( "#{}-sortable_{} li".format( vo_type, player_no ) )
c for c in find_children( "#ob_{}-sortable_{} li".format( vo_type, player_no ) )
if c.text == name
]
assert len(elems) == 1
elem = elems[0]
trash = find_child( "#{}-trash_{}".format( vo_type, player_no ) )
trash = find_child( "#ob_{}-trash_{}".format( vo_type, player_no ) )
ActionChains(webdriver).drag_and_drop( elem, trash ).perform()

@ -17,8 +17,8 @@ from selenium.common.exceptions import NoSuchElementException, StaleElementRefer
# standard templates
_STD_TEMPLATES = {
"scenario": [ "scenario", "players", "victory_conditions", "scenario_notes", "ssr" ],
"ob1": [ "ob_setup_1", "ob_note_1", "vehicles_1", "ordnance_1" ],
"ob2": [ "ob_setup_2", "ob_note_2", "vehicles_2", "ordnance_2" ],
"ob1": [ "ob_setup_1", "ob_note_1", "ob_vehicles_1", "ob_ordnance_1" ],
"ob2": [ "ob_setup_2", "ob_note_2", "ob_vehicles_2", "ob_ordnance_2" ],
}
# nationality-specific templates
@ -63,12 +63,12 @@ def for_each_template( func ): #pylint: disable=too-many-branches
template_id = "ob_setup"
elif template_id.startswith( "ob_note_" ):
template_id = "ob_note"
elif template_id.startswith( "vehicles_" ):
template_id = "vehicles"
elif template_id.startswith( "ordnance_" ):
template_id = "ordnance"
elif template_id.startswith( "ob_vehicles_" ):
template_id = "ob_vehicles"
elif template_id.startswith( "ob_ordnance_" ):
template_id = "ob_ordnance"
func( template_id, orig_template_id )
if orig_template_id not in ("ob_setup_2","ob_note_2","vehicles_2","ordnance_2"):
if orig_template_id not in ("ob_setup_2","ob_note_2","ob_vehicles_2","ob_ordnance_2"):
templates_to_test.remove( template_id )
# test the nationality-specific templates
@ -147,10 +147,11 @@ def set_template_params( params ): #pylint: disable=too-many-branches
continue
# check for vehicles/ordnance (these require special handling)
if key in ("VEHICLES_1","ORDNANCE_1","VEHICLES_2","ORDNANCE_2"):
if key in ("OB_VEHICLES_1","OB_ORDNANCE_1","OB_VEHICLES_2","OB_ORDNANCE_2"):
# add them in (nb: we don't consider any existing vehicles/ordnance)
from vasl_templates.webapp.tests.test_vehicles_ordnance import add_vo #pylint: disable=cyclic-import
vo_type = key[:key.index("_")].lower()
mo = re.search( r"^OB_(VEHICLES|ORDNANCE)_\d$", key )
vo_type = mo.group(1).lower()
for vo_name in val:
add_vo( vo_type, int(key[-1]), vo_name )
continue

Loading…
Cancel
Save