Create attractive VASL scenarios, with loads of useful information embedded to assist with game play. https://vasl-templates.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vasl-templates/vasl_templates/webapp/tests/test_ssr.py

63 lines
1.9 KiB

6 years ago
""" Test generating SSR snippets. """
import html
from vasl_templates.webapp.tests.utils import \
init_webapp, select_tab, find_child, wait_for_clipboard, \
add_simple_note, edit_simple_note, drag_sortable_entry_to_trash, get_sortable_entry_count
6 years ago
# ---------------------------------------------------------------------
def test_ssr( webapp, webdriver ):
"""Test generating SSR snippets."""
# initialize
init_webapp( webapp, webdriver )
select_tab( "scenario" )
sortable = find_child( "#ssr-sortable" )
6 years ago
# initialize
expected = []
generate_snippet_btn = find_child( "button[data-id='ssr']" )
def add_ssr( val ):
"""Add a new SSR."""
6 years ago
expected.append( val )
add_simple_note( sortable, val, None )
check_snippet()
def edit_ssr( ssr_no, val ):
"""Edit an existing SSR."""
expected[ssr_no] = val
edit_simple_note( sortable, ssr_no, val, None )
6 years ago
check_snippet()
def check_snippet( width=None ):
6 years ago
"""Check the generated SSR snippet."""
generate_snippet_btn.click()
6 years ago
val = "\n".join( "(*) [{}]".format(e) for e in expected )
if width:
val += "\nwidth = [{}]".format( width )
wait_for_clipboard( 2, val, transform=html.unescape )
6 years ago
# add an SSR and generate the SSR snippet
add_ssr( "This is my first SSR." )
6 years ago
# add an SSR that contains HTML
add_ssr( "This snippet contains <b>bold</b> and <i>italic</i> text." )
6 years ago
# add a multi-line SSR
add_ssr( "line 1\nline 2\nline 3" )
6 years ago
# edit one of the SSR's
edit_ssr( 1, "This SSR was <i>modified</i>." )
6 years ago
# delete one of the SSR's
assert get_sortable_entry_count(sortable) == 3
drag_sortable_entry_to_trash( sortable, 1 )
assert get_sortable_entry_count(sortable) == 2
6 years ago
del expected[1]
check_snippet()
# set the snippet width
elem = find_child( "input[name='SSR_WIDTH']" )
elem.send_keys( "300px" )
check_snippet( "300px" )