diff --git a/vasl_templates/webapp/static/generate.js b/vasl_templates/webapp/static/generate.js index 7cf0eaa..3496f4d 100644 --- a/vasl_templates/webapp/static/generate.js +++ b/vasl_templates/webapp/static/generate.js @@ -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 \"" + template_id + "\":
" + escapeHTML(ex) + "
" ) ; diff --git a/vasl_templates/webapp/tests/test_ob_setup.py b/vasl_templates/webapp/tests/test_ob_setup.py index adf9db6..58e1f33 100644 --- a/vasl_templates/webapp/tests/test_ob_setup.py +++ b/vasl_templates/webapp/tests/test_ob_setup.py @@ -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: diff --git a/vasl_templates/webapp/tests/test_ssr.py b/vasl_templates/webapp/tests/test_ssr.py index a9bd3b8..a6db49c 100644 --- a/vasl_templates/webapp/tests/test_ssr.py +++ b/vasl_templates/webapp/tests/test_ssr.py @@ -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." )