Trim generated snippets.

master
Pacman Ghost 6 years ago
parent 773fc3a46f
commit 447716068f
  1. 1
      vasl_templates/webapp/static/generate.js
  2. 14
      vasl_templates/webapp/tests/test_ob_setup.py
  3. 2
      vasl_templates/webapp/tests/test_ssr.py

@ -137,6 +137,7 @@ function generate_snippet( $btn )
// process the template
try {
val = func( params ) ;
val = val.trim() ;
}
catch( ex ) {
showErrorMsg( "Can't process template <em>\"" + template_id + "\"</em>:<pre>" + escapeHTML(ex) + "</pre>" ) ;

@ -32,10 +32,10 @@ def test_ob_setup( webapp, webdriver ):
textarea2.send_keys( "setup there." )
btn2 = find_child( webdriver, "input[type='button'][data-id='ob_setup_2']" )
btn2.click()
assert get_clipboard().strip() == "[setup there.] (col=[OBCOL:russian/OBCOL2:russian])"
assert get_clipboard() == "[setup there.] (col=[OBCOL:russian/OBCOL2:russian])"
select_ob_tab( 1 )
btn1.click()
assert get_clipboard().strip() == "[setup here.] (col=[OBCOL:german/OBCOL2:german])"
assert get_clipboard() == "[setup here.] (col=[OBCOL:german/OBCOL2:german])"
# change the player nationalities and generate the OB SETUP snippets again
elem = find_child( webdriver, "#tabs .ui-tabs-nav a[href='#tabs-scenario']" )
@ -50,10 +50,10 @@ def test_ob_setup( webapp, webdriver ):
sel.select_by_value( "french" )
select_ob_tab( 1 )
btn1.click()
assert get_clipboard().strip() == "[setup here.] (col=[OBCOL:british/OBCOL2:british])"
assert get_clipboard() == "[setup here.] (col=[OBCOL:british/OBCOL2:british])"
select_ob_tab( 2 )
btn2.click()
assert get_clipboard().strip() == "[setup there.] (col=[OBCOL:french/OBCOL2:french])"
assert get_clipboard() == "[setup there.] (col=[OBCOL:french/OBCOL2:french])"
# ---------------------------------------------------------------------
@ -83,7 +83,7 @@ def test_nationality_specific( webapp, webdriver ):
elem.click()
elem = find_child( webdriver, "input[type='button'][data-id='pf']" )
elem.click()
assert get_clipboard().strip() == expected
assert get_clipboard() == expected
# check if a warning was issued
last_warning = get_stored_msg( "_last-warning_" ) or ""
if warning:
@ -109,7 +109,7 @@ def test_nationality_specific( webapp, webdriver ):
elem.click()
elem = find_child( webdriver, "input[type='button'][data-id='baz']" )
elem.click()
assert get_clipboard().strip() == expected
assert get_clipboard() == expected
# check if a warning was issued
last_warning = get_stored_msg( "_last-warning_" ) or ""
if expected == "BAZ: none":
@ -157,7 +157,7 @@ def test_nationality_specific( webapp, webdriver ):
# make sure that the template works
elem.click()
if isinstance( expected[1], str ):
assert get_clipboard().strip() == expected[1]
assert get_clipboard() == expected[1]
elif isinstance( expected[1], types.FunctionType ):
expected[1]() #pylint: disable=not-callable
else:

@ -41,7 +41,7 @@ def test_ssr( webapp, webdriver ):
btn = find_child( webdriver, "input[type='button'][data-id='ssr']" )
btn.click()
val = "\n".join( "(*) [{}]".format(e) for e in expected )
assert html.unescape(get_clipboard().strip()) == val
assert html.unescape(get_clipboard()) == val
# add an SSR and generate the SSR snippet
add_ssr( "This is my first SSR." )

Loading…
Cancel
Save