parent
0a91f820f3
commit
13e6709420
@ -1,6 +1,8 @@ |
||||
.ui-dialog.user-settings .ui-dialog-titlebar { background: #80d0ff ; } |
||||
.ui-dialog.user-settings .ui-dialog-buttonpane { border: none ; margin-top: 0 !important ; padding-top: 0 !important ; } |
||||
|
||||
.ui-dialog.user-settings fieldset { margin: 1em 0 0 0 ; padding-top: 0.25em ; border-radius: 0 ; } |
||||
.ui-dialog.user-settings .run-as-server-note { margin-bottom: 0.5em ; font-size: 80% ; font-style: italic ; color: #666 ; } |
||||
.ui-dialog.user-settings .run-as-server-note img { float: left ; margin-right: 0.25em ; } |
||||
.ui-dialog.user-settings fieldset { margin: 0.5em 0 0 0 ; padding-top: 0.5em ; border-radius: 0 ; } |
||||
|
||||
.ui-dialog.user-settings img.need-localhost { display: inline-block ; height: 0.75em ; } |
||||
.ui-dialog.user-settings div.need-localhost { float: left ; width: 290px ; font-size: 80% ; font-style: italic ; color: #c02020 ; } |
||||
.ui-dialog.user-settings div.need-localhost img { float: left ; height: 1.5em ; margin-right: 0.25em ; } |
||||
|
Before Width: | Height: | Size: 168 B After Width: | Height: | Size: 168 B |
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,121 @@ |
||||
<!doctype html> <!-- NOTE: For testing porpoises only! --> |
||||
<html lang="en"> |
||||
|
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<title> Counter image URL's ({{NATIONALITY}}) </title> |
||||
<style> |
||||
th, td { text-align: left ; vertical-align: top ; padding-right: 1em ; } |
||||
th { background: #eee ; } |
||||
td { border-bottom: 1px solid #eee ; font-size: 90% ; } |
||||
</style> |
||||
</head> |
||||
|
||||
<body> |
||||
<div id="results" style="display:none;"></div> |
||||
</body> |
||||
|
||||
<script src="{{url_for('static',filename='jquery/jquery-3.3.1.min.js')}}"></script> |
||||
<script src="{{url_for('static',filename='vo.js')}}"></script> |
||||
<script src="{{url_for('static',filename='utils.js')}}"></script> |
||||
|
||||
<script> |
||||
APP_URL_BASE = window.location.origin ; |
||||
gAppConfig = null ; |
||||
gVaslPieceInfo = null ; |
||||
|
||||
$(document).ready( function () { |
||||
|
||||
// initialize |
||||
var counter_image_urls ; |
||||
var on_load_counter = 3 ; |
||||
function on_data_loaded() { |
||||
if ( --on_load_counter == 0 ) |
||||
show_counter_image_urls( counter_image_urls ) ; |
||||
} |
||||
|
||||
// get the app config |
||||
$.getJSON( "{{url_for('get_app_config')}}", function(data) { |
||||
gAppConfig = data ; |
||||
on_data_loaded() ; |
||||
} ).fail( function( xhr, status, errorMsg ) { |
||||
alert( "Can't get the application config:\n\n" + errorMsg ) ; |
||||
} ) ; |
||||
|
||||
// get the VASL piece info |
||||
$.getJSON( "{{url_for('get_vasl_piece_info')}}", function(data) { |
||||
gVaslPieceInfo = data ; |
||||
on_data_loaded() ; |
||||
} ).fail( function( xhr, status, errorMsg ) { |
||||
alert( "Can't get the VASL piece info:\n\n" + errorMsg ) ; |
||||
} ) ; |
||||
|
||||
// get the vehicle/ordnance listings |
||||
var url ; |
||||
if ( "{{VO_TYPE}}" == "ordnance" ) |
||||
url = "{{url_for( 'get_ordnance_listings', report=1 )}}" ; |
||||
else |
||||
url = "{{url_for( 'get_vehicle_listings', report=1 )}}" ; // nb: includes landing craft |
||||
url += "&merge_common=1" ; |
||||
$.getJSON( url, function(data) { |
||||
counter_image_urls = data[ "{{NATIONALITY}}" ] ; |
||||
on_data_loaded() ; |
||||
} ).fail( function( xhr, status, errorMsg ) { |
||||
alert( "Can't get the {{VO_TYPE0}} listings:\n\n" + errorMsg ) ; |
||||
} ) ; |
||||
} ) ; |
||||
|
||||
function show_counter_image_urls( counters ) |
||||
{ |
||||
// initialize |
||||
if ( ! counters ) |
||||
counters = [] ; |
||||
var buf = [] ; |
||||
buf.push( "<table>" ) ; |
||||
buf.push( "<tr>", "<th>ID", "<th>Name", "<th>GPID", "<th>Local URL's", "<th>Online URL's" ) ; |
||||
|
||||
// process each counter |
||||
for ( var i=0 ; i < counters.length ; ++i ) { |
||||
|
||||
var counter = counters[i] ; |
||||
buf.push( "<tr>", |
||||
"<td>", counter.id, |
||||
"<td>", counter.name, |
||||
) ; |
||||
|
||||
// process each counter variant |
||||
var gpids = $.isArray( counter.gpid ) ? counter.gpid : [ counter.gpid ] ; |
||||
var gpids2=[] , local_urls=[] , online_urls=[] ; |
||||
for ( var j=0 ; j < gpids.length ; ++j ) { |
||||
|
||||
if ( gpids[j] === null || [7140,7146].indexOf( gpids[j] ) !== -1 ) { |
||||
buf.push( "<td>", "<td>", "<td>" ) ; |
||||
continue ; |
||||
} |
||||
gpids2.push( gpids[j] ) ; |
||||
|
||||
// NOTE: We don't handle the case where there are multiple images available for a GPID, |
||||
// but this happens so infrequently, we can live with it (see expected-multiple-images.json). |
||||
var index = 0 ; |
||||
|
||||
// generate the counter image URL's |
||||
var url = make_local_counter_image_url( gpids[j], index ) ; |
||||
local_urls.push( "<a href='" + url + "' target='_blank'>" + url + "</a>" ) ; |
||||
url = make_online_counter_image_url( gpids[j], index ) ; |
||||
online_urls.push( "<a href='" + url + "' target='_blank'>" + url + "</a>" ) ; |
||||
} |
||||
|
||||
buf.push( |
||||
"<td>", gpids2.join( "<br>" ), |
||||
"<td>", local_urls.join( "<br>" ), |
||||
"<td>", online_urls.join( "<br>" ), |
||||
) ; |
||||
} |
||||
|
||||
buf.push( "</table>" ) ; |
||||
$("#results").html( buf.join("") ).show() ; |
||||
} |
||||
|
||||
</script> |
||||
|
||||
</html> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,162 @@ |
||||
"""Test using online images in VASL scenarios.""" |
||||
|
||||
import re |
||||
|
||||
from selenium.webdriver.common.action_chains import ActionChains |
||||
|
||||
from vasl_templates.webapp.tests.utils import init_webapp, select_tab, \ |
||||
find_child, find_children, click_dialog_button, wait_for_clipboard, wait_for_elem |
||||
from vasl_templates.webapp.tests.test_user_settings import set_user_settings |
||||
from vasl_templates.webapp.tests.test_scenario_persistence import load_scenario |
||||
|
||||
# --------------------------------------------------------------------- |
||||
|
||||
def test_online_images( webapp, webdriver ): |
||||
"""Test using online images in VASL scenarios.""" |
||||
|
||||
# initialize |
||||
init_webapp( webapp, webdriver, scenario_persistence=1, |
||||
reset = lambda ct: |
||||
ct.set_data_dir( dtype="real" ) \ |
||||
.set_vasl_mod( vmod="random" ) \ |
||||
.set_default_template_pack( dname="real" ) |
||||
) |
||||
|
||||
# load the test scenario |
||||
load_scenario( { |
||||
"PLAYER_1": "german", |
||||
"OB_VEHICLES_1": [ { "name": "PzKpfw IVH" } ], |
||||
} ) |
||||
|
||||
# configure the user settings |
||||
set_user_settings( { |
||||
"include-flags-in-snippets": True, |
||||
"custom-list-bullets": True, |
||||
"include-vasl-images-in-snippets": True, |
||||
} ) |
||||
|
||||
def do_test( snippet_id, expected1, expected2 ): #pylint: disable=missing-docstring |
||||
# generate the snippet with online images enabled |
||||
set_user_settings( { "use-online-images": True } ) |
||||
btn = find_child( "button[data-id='{}']".format( snippet_id ) ) |
||||
btn.click() |
||||
wait_for_clipboard( 2, expected1 ) |
||||
# generate the snippet with online images disabled |
||||
set_user_settings( { "use-online-images": False } ) |
||||
btn.click() |
||||
wait_for_clipboard( 2, expected2 ) |
||||
|
||||
# test player flags |
||||
do_test( "players", |
||||
re.compile( r'<img src="http://vasl-templates.org/.+/flags/german.png">' ), |
||||
re.compile( r'<img src="http://[a-z0-9.]+:\d+/flags/german">' ) |
||||
) |
||||
|
||||
# test custom list bullets |
||||
do_test( "ssr", |
||||
re.compile( r'url\("http://vasl-templates.org/.+/bullet.png"\)' ), |
||||
re.compile( r'url\("http://[a-z0-9.]+:\d+/.+/bullet.png"\)') |
||||
) |
||||
|
||||
# test VASL counter images |
||||
select_tab( "ob1" ) |
||||
do_test( "ob_vehicles_1", |
||||
re.compile( r'<img src="https://raw.githubusercontent.com/.+/ge/veh/pzivh.gif">' ), |
||||
re.compile( r'<img src="http://[a-z0-9.]+:\d+/counter/2584/front">' ) |
||||
) |
||||
|
||||
# --------------------------------------------------------------------- |
||||
|
||||
def test_multiple_images( webapp, webdriver ): |
||||
"""Test handling of VASL counters that have multiple images.""" |
||||
|
||||
# initialize |
||||
init_webapp( webapp, webdriver, scenario_persistence=1, |
||||
reset = lambda ct: |
||||
ct.set_data_dir( dtype="real" ) \ |
||||
.set_vasl_mod( vmod="random" ) \ |
||||
.set_default_template_pack( dname="real" ) |
||||
) |
||||
|
||||
# load the test scenario |
||||
load_scenario( { |
||||
"PLAYER_1": "british", |
||||
"OB_VEHICLES_1": [ { "name": "2pdr Portee" } ], |
||||
} ) |
||||
|
||||
# configure the user settings |
||||
set_user_settings( { |
||||
"use-online-images": True, |
||||
"include-vasl-images-in-snippets": True, |
||||
} ) |
||||
|
||||
# generate a snippet for the vehicle (using the default image) |
||||
select_tab( "ob1" ) |
||||
btn = find_child( "button[data-id='ob_vehicles_1']" ) |
||||
btn.click() |
||||
wait_for_clipboard( 2, |
||||
re.compile( r'<img src="https://raw.githubusercontent.com/.+/br/vehicles/portee.gif">') |
||||
) |
||||
|
||||
# select the second image for the vehicle |
||||
sortable = find_child( "#ob_vehicles-sortable_1" ) |
||||
elems = find_children( "li", sortable ) |
||||
assert len(elems) == 1 |
||||
ActionChains(webdriver).double_click( elems[0] ).perform() |
||||
btn = wait_for_elem( 2, "#edit-vo input.select-vo-image" ) |
||||
btn.click() |
||||
images = find_children( ".ui-dialog.select-vo-image .vo-images img" ) |
||||
assert len(images) == 2 |
||||
images[1].click() |
||||
click_dialog_button( "OK" ) |
||||
|
||||
# generate a snippet for the vehicle (using the new image) |
||||
btn = find_child( "button[data-id='ob_vehicles_1']" ) |
||||
btn.click() |
||||
wait_for_clipboard( 2, |
||||
re.compile( r'<img src="https://raw.githubusercontent.com/.+/br/vehicles/portee0.gif">') |
||||
) |
||||
|
||||
# --------------------------------------------------------------------- |
||||
|
||||
def test_extensions( webapp, webdriver ): |
||||
"""Test handling of VASL counters in extensions.""" |
||||
|
||||
# initialize |
||||
init_webapp( webapp, webdriver, scenario_persistence=1, |
||||
reset = lambda ct: |
||||
ct.set_data_dir( dtype="real" ) \ |
||||
.set_vasl_mod( vmod="random", extns_dtype="real" ) \ |
||||
.set_default_template_pack( dname="real" ) |
||||
) |
||||
|
||||
# load the test scenario |
||||
load_scenario( { |
||||
"PLAYER_1": "russian", |
||||
"OB_VEHICLES_1": [ |
||||
{ "id": "ru/v:078", "image_id": "f97:178/0" }, # Matilda II(b) (4FP variant) |
||||
{ "id": "ru/v:078", "image_id": "f97:184/0" }, # Matilda II(b) (6FP variant) |
||||
{ "id": "ru/v:004", "image_id": "547/0" }, # T-60 M40 (core module) |
||||
{ "id": "ru/v:004", "image_id": "f97:186/0" }, # T-60 M40 (KGS variant) |
||||
], |
||||
} ) |
||||
|
||||
# configure the user settings |
||||
set_user_settings( { |
||||
"use-online-images": True, |
||||
"include-vasl-images-in-snippets": True, |
||||
} ) |
||||
|
||||
# generate a snippet for the vehicles |
||||
select_tab( "ob1" ) |
||||
btn = find_child( "button[data-id='ob_vehicles_1']" ) |
||||
btn.click() |
||||
wait_for_clipboard( 2, re.compile( |
||||
'<img src="http://vasl-templates.org/.+/f97/matii2-4cmg.gif">' |
||||
'.+' |
||||
'<img src="http://vasl-templates.org/.+/f97/matii2-6cmg.gif">' |
||||
'.+' |
||||
'<img src="https://raw.githubusercontent.com/.+/ru/veh/T60M40.gif">' |
||||
'.+' |
||||
'<img src="http://vasl-templates.org/.+/f97/T60M40.gif">' |
||||
, re.DOTALL ) ) |
Loading…
Reference in new issue