diff --git a/vasl_templates/webapp/tests/fixtures/data/vehicles/german.json b/vasl_templates/webapp/tests/fixtures/data/vehicles/german.json
index 0e81d8f..910a66c 100644
--- a/vasl_templates/webapp/tests/fixtures/data/vehicles/german.json
+++ b/vasl_templates/webapp/tests/fixtures/data/vehicles/german.json
@@ -26,6 +26,10 @@
"comments": [ "a comment", "another comment" ],
"id": "ge/v:993"
},
+{ "name": "missing multi-applicable note",
+ "notes": [ "A", "Q" ],
+ "id": "ge/v:994"
+},
{ "name": "name only",
"id": "ge/v:999"
}
diff --git a/vasl_templates/webapp/tests/test_user_settings.py b/vasl_templates/webapp/tests/test_user_settings.py
index a72c874..316d67c 100644
--- a/vasl_templates/webapp/tests/test_user_settings.py
+++ b/vasl_templates/webapp/tests/test_user_settings.py
@@ -11,6 +11,7 @@ from vasl_templates.webapp.tests.utils import \
from vasl_templates.webapp.tests.test_vehicles_ordnance import add_vo
from vasl_templates.webapp.tests.test_scenario_persistence import save_scenario, load_scenario
from vasl_templates.webapp.tests.test_template_packs import upload_template_pack_file
+from vasl_templates.webapp.tests.test_vo_notes import extract_ma_notes
# ---------------------------------------------------------------------
@@ -178,6 +179,58 @@ def test_date_format( webapp, webdriver ):
# ---------------------------------------------------------------------
+def test_hide_unavailable_ma_notes( webapp, webdriver ):
+ """Test showing/hiding unavailable multi-applicable notes."""
+
+ # initialize
+ init_webapp( webapp, webdriver, scenario_persistence=1,
+ reset = lambda ct: ct.set_vo_notes_dir( dtype="test" )
+ )
+
+ # load the test vehicle
+ load_scenario( {
+ "PLAYER_1": "german",
+ "OB_VEHICLES_1": [
+ { "name": "missing multi-applicable note" }
+ ]
+ } )
+ select_tab( "ob1" )
+
+ def test_ma_notes( ma_note_q_present ): #pylint: disable=missing-docstring
+ expected = [ ( "A", 'German Multi-Applicable Vehicle Note "A".' ) ]
+ if ma_note_q_present:
+ expected.append( ( "Q", "Unavailable." ) )
+ btn = find_child( "button[data-id='ob_vehicles_ma_notes_1']" )
+ btn.click()
+ wait_for_clipboard( 2, expected, transform=extract_ma_notes )
+
+ # generate the multi-applicable notes
+ test_ma_notes( True )
+
+ # enable "hide unavailable multi-applicable notes"
+ select_menu_option( "user_settings" )
+ elem = find_child( ".ui-dialog.user-settings input[name='hide-unavailable-ma-notes']" )
+ assert not elem.is_selected()
+ elem.click()
+ click_dialog_button( "OK" )
+ _check_cookies( webdriver, "hide-unavailable-ma-notes", True )
+
+ # generate the multi-applicable notes
+ test_ma_notes( False )
+
+ # disable "hide unavailable multi-applicable notes"
+ select_menu_option( "user_settings" )
+ elem = find_child( ".ui-dialog.user-settings input[name='hide-unavailable-ma-notes']" )
+ assert elem.is_selected()
+ elem.click()
+ click_dialog_button( "OK" )
+ _check_cookies( webdriver, "hide-unavailable-ma-notes", False )
+
+ # generate the multi-applicable notes
+ test_ma_notes( True )
+
+# ---------------------------------------------------------------------
+
def _check_cookies( webdriver, name, expected ):
"""Check that a user setting was stored in the cookies correctly."""
cookies = [ c for c in webdriver.get_cookies() if c["name"] == "user-settings" ]
diff --git a/vasl_templates/webapp/tests/test_vo_notes.py b/vasl_templates/webapp/tests/test_vo_notes.py
index 6afef69..b25ba0e 100644
--- a/vasl_templates/webapp/tests/test_vo_notes.py
+++ b/vasl_templates/webapp/tests/test_vo_notes.py
@@ -74,7 +74,7 @@ def test_ma_notes( webapp, webdriver ):
"button.generate[data-id='ob_{}_ma_notes_{}']".format( vo_type, player_no )
)
btn.click()
- wait_for_clipboard( 2, expected, transform=_extract_ma_note_keys )
+ wait_for_clipboard( 2, expected, transform=extract_ma_note_keys )
# test multi-applicable notes for German vehicles
do_test( 1, "german", "vehicles",
@@ -175,13 +175,13 @@ def test_extra_ma_notes( webapp, webdriver ):
wait_for_clipboard( 2, [
( "A", 'Dutch Multi-Applicable Vehicle Note "A".' ),
( "Du", 'Allied Minor Multi-Applicable Vehicle Note "Du".' ),
- ], transform=_extract_ma_notes )
+ ], transform=extract_ma_notes )
btn = find_child( "button.generate[data-id='ob_ordnance_ma_notes_1']" )
btn.click()
wait_for_clipboard( 2, [
( "A", 'Dutch Multi-Applicable Ordnance Note "A".' ),
( "Du", 'Allied Minor Multi-Applicable Ordnance Note "Du".' ),
- ], transform=_extract_ma_notes )
+ ], transform=extract_ma_notes )
# test Axis Minor vehicles/ordnance
select_tab( "ob2" )
@@ -190,13 +190,13 @@ def test_extra_ma_notes( webapp, webdriver ):
wait_for_clipboard( 2, [
( "A", 'Romanian Multi-Applicable Vehicle Note "A".' ),
( "Ro", 'Axis Minor Multi-Applicable Vehicle Note "Ro".' ),
- ], transform=_extract_ma_notes )
+ ], transform=extract_ma_notes )
btn = find_child( "button.generate[data-id='ob_ordnance_ma_notes_2']" )
btn.click()
wait_for_clipboard( 2, [
( "A", 'Romanian Multi-Applicable Ordnance Note "A".' ),
( "Ro", 'Axis Minor Multi-Applicable Ordnance Note "Ro".' ),
- ], transform=_extract_ma_notes )
+ ], transform=extract_ma_notes )
# test Landing Craft
load_scenario( {
@@ -214,7 +214,7 @@ def test_extra_ma_notes( webapp, webdriver ):
( "Y", "Unavailable." ),
"Landing Craft",
( "A", 'Landing Craft Multi-Applicable Note "A".' ),
- ], transform=_extract_ma_notes )
+ ], transform=extract_ma_notes )
select_tab( "ob2" )
btn = find_child( "button.generate[data-id='ob_vehicles_ma_notes_2']" )
btn.click()
@@ -222,7 +222,7 @@ def test_extra_ma_notes( webapp, webdriver ):
( "A", 'Japanese Multi-Applicable Vehicle Note "A".' ),
"Landing Craft",
( "B", 'Landing Craft Multi-Applicable Note "B".' ),
- ], transform=_extract_ma_notes )
+ ], transform=extract_ma_notes )
# ---------------------------------------------------------------------
@@ -343,10 +343,10 @@ def test_special_cases( webapp, webdriver ):
select_tab( "ob1" )
btn = find_child( "button.generate[data-id='ob_ordnance_ma_notes_1']" )
btn.click()
- wait_for_clipboard( 2, ["N","
R"], transform=_extract_ma_note_keys )
+ wait_for_clipboard( 2, ["N","
R"], transform=extract_ma_note_keys )
btn = find_child( "button.generate[data-id='ob_vehicles_ma_notes_1']" )
btn.click()
- wait_for_clipboard( 2, ["N","R"], transform=_extract_ma_note_keys )
+ wait_for_clipboard( 2, ["N","R"], transform=extract_ma_note_keys )
# ---------------------------------------------------------------------
@@ -511,12 +511,12 @@ def _parse_report( buf ):
# ---------------------------------------------------------------------
-def _extract_ma_note_keys( snippet ):
+def extract_ma_note_keys( snippet ):
"""Extract the multi-applicable note keys in a snippet."""
matches = re.finditer( r"
(.+):", snippet )
return [ mo.group(1) for mo in matches ]
-def _extract_ma_notes( snippet ):
+def extract_ma_notes( snippet ):
"""Extract the multi-applicable notes in a snippet."""
mo = re.search( "=== ([^=]+) ===", snippet )
if mo: