"""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, \ SCENARIO_IMAGES_SOURCE_THIS_PROGRAM, SCENARIO_IMAGES_SOURCE_INTERNET 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 webapp.control_tests \ .set_data_dir( "{REAL}" ) \ .set_vasl_version( "random", None ) init_webapp( webapp, webdriver, scenario_persistence=1 ) # 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( { "scenario-images-source": SCENARIO_IMAGES_SOURCE_INTERNET } ) 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( { "scenario-images-source": SCENARIO_IMAGES_SOURCE_THIS_PROGRAM } ) btn.click() wait_for_clipboard( 2, expected2 ) # test player flags do_test( "players", re.compile( r'