parent
721e9bdeae
commit
3b84cc2cf5
@ -0,0 +1,15 @@ |
||||
{ |
||||
|
||||
"PLAYER_1": "german", |
||||
"PLAYER_1_ELR": "5", |
||||
"PLAYER_1_SAN": "2", |
||||
"PLAYER_2": "russian", |
||||
"PLAYER_2_ELR": "5", |
||||
"PLAYER_2_SAN": "2", |
||||
|
||||
"VICTORY_CONDITIONS_WIDTH": "300px", |
||||
"SSR_WIDTH": "300px", |
||||
|
||||
"_OB_NOTE_WIDTH": "200px" |
||||
|
||||
} |
@ -0,0 +1,11 @@ |
||||
{ |
||||
|
||||
"PLAYER_1": "german", |
||||
"PLAYER_1_ELR": "5", |
||||
"PLAYER_1_SAN": "2", |
||||
|
||||
"PLAYER_2": "russian", |
||||
"PLAYER_2_ELR": "5", |
||||
"PLAYER_2_SAN": "2" |
||||
|
||||
} |
@ -0,0 +1,61 @@ |
||||
{ |
||||
|
||||
"SCENARIO_NAME": "default scenario name", |
||||
"SCENARIO_LOCATION": "default location", |
||||
"SCENARIO_DATE": "01/01/2000", |
||||
"SCENARIO_WIDTH": "1px", |
||||
|
||||
"PLAYER_1": "american", |
||||
"PLAYER_1_ELR": "1", |
||||
"PLAYER_1_SAN": "2", |
||||
|
||||
"PLAYER_2": "japanese", |
||||
"PLAYER_2_ELR": "3", |
||||
"PLAYER_2_SAN": "4", |
||||
|
||||
"VICTORY_CONDITIONS": "default victory conditions", |
||||
"VICTORY_CONDITIONS_WIDTH": "123px", |
||||
|
||||
"SCENARIO_NOTES": [ |
||||
{ "caption": "default scenario note #1", "width": "1px" }, |
||||
{ "caption": "default scenario note #2", "width": "2px" }, |
||||
{ "caption": "default scenario note #3", "width": "3px" } |
||||
], |
||||
|
||||
"SSR": [ |
||||
"default SSR #1", |
||||
"default SSR #2", |
||||
"default SSR #3" |
||||
], |
||||
"SSR_WIDTH": "999px", |
||||
|
||||
"OB_SETUPS_1": [ |
||||
{ "caption": "default american OB setup #1", "width": "101px" }, |
||||
{ "caption": "default american OB setup #2", "width": "102px" } |
||||
], |
||||
"OB_NOTES_1": [ |
||||
{ "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_SETUPS_2": [ |
||||
{ "caption": "default japanese OB setup #1", "width": "201px" }, |
||||
{ "caption": "default japanese OB setup #2", "width": "202px" } |
||||
], |
||||
"OB_NOTES_2": [ |
||||
{ "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_SETUP_WIDTH": "900px", |
||||
"_OB_NOTE_WIDTH": "901px" |
||||
|
||||
} |
@ -0,0 +1,108 @@ |
||||
"""Test the loading of the default scenario.""" |
||||
import os |
||||
|
||||
from selenium.webdriver.support.ui import Select |
||||
from selenium.webdriver.common.keys import Keys |
||||
|
||||
from vasl_templates.webapp import main |
||||
from vasl_templates.webapp.tests.utils import select_tab, find_child, get_sortable_entry_text, wait_for |
||||
|
||||
# --------------------------------------------------------------------- |
||||
|
||||
def test_default_scenario( webapp, webdriver, monkeypatch ): |
||||
"""Test loading the default scenario.""" |
||||
|
||||
# configure a new default scenario |
||||
fname = os.path.join( os.path.split(__file__)[0], "fixtures/new-default-scenario.json" ) |
||||
monkeypatch.setattr( main, "default_scenario", fname ) |
||||
|
||||
# initialize |
||||
webdriver.get( webapp.url_for( "main" ) ) |
||||
|
||||
# wait for the scenario to load |
||||
elem = find_child( "input[name='SCENARIO_NAME']" ) |
||||
wait_for( 5, lambda: elem.get_attribute("value") != "" ) |
||||
|
||||
def check_textbox( field_name, expected ): |
||||
"""Check that a field has been loaded correctly.""" |
||||
elem = find_child( "input[name='{}']".format( field_name ) ) |
||||
assert elem.get_attribute( "value" ) == expected |
||||
def check_textarea( field_name, expected ): |
||||
"""Check that a field has been loaded correctly.""" |
||||
elem = find_child( "textarea[name='{}']".format( field_name ) ) |
||||
assert elem.get_attribute( "value" ) == expected |
||||
def check_droplist( field_name, expected ): |
||||
"""Check that a field has been loaded correctly.""" |
||||
elem = find_child( "select[name='{}']".format( field_name ) ) |
||||
assert Select(elem).first_selected_option.get_attribute("value") == expected |
||||
|
||||
select_tab( "scenario" ) |
||||
|
||||
# check the scenario fields |
||||
check_textbox( "SCENARIO_NAME", "default scenario name" ) |
||||
check_textbox( "SCENARIO_LOCATION", "default location" ) |
||||
check_textbox( "SCENARIO_DATE", "01/01/2000" ) |
||||
check_textbox( "SCENARIO_WIDTH", "1px" ) |
||||
|
||||
# check the player fields |
||||
check_droplist( "PLAYER_1", "american" ) |
||||
check_droplist( "PLAYER_1_ELR", "1" ) |
||||
check_droplist( "PLAYER_1_SAN", "2" ) |
||||
check_droplist( "PLAYER_2", "japanese" ) |
||||
check_droplist( "PLAYER_2_ELR", "3" ) |
||||
check_droplist( "PLAYER_2_SAN", "4" ) |
||||
|
||||
# check the victory conditions |
||||
check_textarea( "VICTORY_CONDITIONS", "default victory conditions" ) |
||||
check_textbox( "VICTORY_CONDITIONS_WIDTH", "123px" ) |
||||
|
||||
# check the scenario notes |
||||
assert get_sortable_entry_text( find_child( "#scenario_notes-sortable" ) ) \ |
||||
== [ "default scenario note #{}".format(i) for i in [1,2,3] ] |
||||
# nb: should check the snippet widths as well (not really important for a default scenario) |
||||
|
||||
# check the SSR's |
||||
assert get_sortable_entry_text( find_child( "#ssr-sortable" ) ) \ |
||||
== [ "default SSR #{}".format(i) for i in [1,2,3] ] |
||||
check_textbox( "SSR_WIDTH", "999px" ) |
||||
|
||||
select_tab( "ob1" ) |
||||
|
||||
# check the OB setups/notes (player 1) |
||||
assert get_sortable_entry_text( find_child( "#ob_setups-sortable_1" ) ) \ |
||||
== [ "default american OB setup #{}".format(i) for i in [1,2] ] |
||||
assert get_sortable_entry_text( find_child( "#ob_notes-sortable_1" ) ) \ |
||||
== [ "default american OB note #{}".format(i) for i in [1,2] ] |
||||
# 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" ) |
||||
|
||||
select_tab( "ob2" ) |
||||
|
||||
# check the OB setups/notes (player 2) |
||||
assert get_sortable_entry_text( find_child( "#ob_setups-sortable_2" ) ) \ |
||||
== [ "default japanese OB setup #{}".format(i) for i in [1,2] ] |
||||
assert get_sortable_entry_text( find_child( "#ob_notes-sortable_2" ) ) \ |
||||
== [ "default japanese OB note #{}".format(i) for i in [1,2] ] |
||||
# 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" ) |
||||
|
||||
# check that the default OB setup/note width is being used |
||||
elem = find_child( "#ob_setups-add_2" ) |
||||
elem.click() |
||||
elem = find_child( ".ui-dialog-buttonpane input[name='width']" ) |
||||
assert elem.get_attribute( "value" ) == "900px" |
||||
elem.send_keys( Keys.ESCAPE ) |
||||
elem = find_child( "#ob_notes-add_2" ) |
||||
elem.click() |
||||
elem = find_child( ".ui-dialog-buttonpane input[name='width']" ) |
||||
assert elem.get_attribute( "value" ) == "901px" |
Loading…
Reference in new issue