Skip to content

chore: fix vue tests #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ class MasterDetailVUE(object):
old_value='Car List', new_value='Master Detail',
old_text='Car List', new_text='Master Detail')
VUE_STYLE = ChangeSet(file_path=os.path.join('app', 'components', 'CarList.vue'),
old_value='background-color: $background-light;',
new_value='background-color: rgb(229, 4, 5);',
old_value='background-color: background-alt-10)',
new_value='background-color: accent)',
old_color=Colors.WHITE, new_color=Colors.RED_DARK)
VUE_DETAIL_PAGE_TEMPLATE = ChangeSet(file_path=os.path.join('app', 'components', 'CarDetails.vue'),
old_value='<Span text="/day" />', new_value='<Span text="/24h" />',
Expand Down
52 changes: 25 additions & 27 deletions data/sync/blank_vue.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,28 @@
from products.nativescript.tns_logs import TnsLogs


def __run_vue(app_name, platform, bundle, hmr):
def __run_vue(app_name, platform, hmr):
# Execute `tns run` and wait until logs are OK
return Tns.run(app_name=app_name, platform=platform, emulator=True, wait=False, bundle=bundle, hmr=hmr)
return Tns.run(app_name=app_name, platform=platform, emulator=True, wait=False, hmr=hmr)


def __preview_vue(app_name, platform, device, bundle, hmr):
def __preview_vue(app_name, platform, device, hmr):
# Execute `tns run` and wait until logs are OK
return Preview.run_app(app_name=app_name, bundle=bundle, hmr=hmr, platform=platform, device=device,
click_open_alert=True)
return Preview.run_app(app_name=app_name, hmr=hmr, platform=platform, device=device, click_open_alert=True)


def __workflow(preview, app_name, platform, device, bundle=True, hmr=True):
def __workflow(preview, app_name, platform, device, hmr=True):
# Execute tns command
if preview:
result = __preview_vue(app_name=app_name, platform=platform, device=device, bundle=bundle, hmr=hmr)
result = __preview_vue(app_name=app_name, platform=platform, device=device, hmr=hmr)
else:
result = __run_vue(app_name=app_name, platform=platform, bundle=bundle, hmr=hmr)
result = __run_vue(app_name=app_name, platform=platform, hmr=hmr)

if preview:
Log.info('Skip logs checks.')
else:
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.FULL, bundle=bundle,
hmr=hmr, app_type=AppType.VUE)
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.UNKNOWN, hmr=hmr,
app_type=AppType.VUE)
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=240)

# Verify it looks properly
Expand All @@ -58,8 +57,8 @@ def __workflow(preview, app_name, platform, device, bundle=True, hmr=True):
if preview:
Log.info('Skip logs checks.')
else:
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL,
bundle=bundle, hmr=hmr, app_type=AppType.VUE, file_name='Home.vue')
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, hmr=hmr,
app_type=AppType.VUE, file_name='Home.vue')
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
not_existing_string_list=not_existing_string_list)
device.wait_for_text(text=Changes.BlankVue.VUE_SCRIPT.new_text)
Expand All @@ -69,8 +68,8 @@ def __workflow(preview, app_name, platform, device, bundle=True, hmr=True):
if preview:
Log.info('Skip logs checks.')
else:
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL,
bundle=bundle, hmr=hmr, app_type=AppType.VUE, file_name='Home.vue')
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, hmr=hmr,
app_type=AppType.VUE, file_name='Home.vue')
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
not_existing_string_list=not_existing_string_list)
device.wait_for_text(text=Changes.BlankVue.VUE_TEMPLATE.new_text)
Expand All @@ -80,8 +79,8 @@ def __workflow(preview, app_name, platform, device, bundle=True, hmr=True):
if preview:
Log.info('Skip logs checks.')
else:
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL,
bundle=bundle, hmr=hmr, app_type=AppType.VUE, file_name='Home.vue')
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, hmr=hmr,
app_type=AppType.VUE, file_name='Home.vue')
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
not_existing_string_list=not_existing_string_list)
style_applied = Wait.until(lambda: device.get_pixels_by_color(Colors.RED) > 100)
Expand All @@ -92,8 +91,8 @@ def __workflow(preview, app_name, platform, device, bundle=True, hmr=True):
if preview:
Log.info('Skip logs checks.')
else:
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL,
bundle=bundle, hmr=hmr, app_type=AppType.VUE, file_name='Home.vue')
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, hmr=hmr,
app_type=AppType.VUE, file_name='Home.vue')
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
not_existing_string_list=not_existing_string_list)
device.wait_for_text(text=Changes.BlankVue.VUE_SCRIPT.old_text)
Expand All @@ -103,8 +102,8 @@ def __workflow(preview, app_name, platform, device, bundle=True, hmr=True):
if preview:
Log.info('Skip logs checks.')
else:
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL,
bundle=bundle, hmr=hmr, app_type=AppType.VUE, file_name='Home.vue')
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, hmr=hmr,
app_type=AppType.VUE, file_name='Home.vue')
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
not_existing_string_list=not_existing_string_list)
device.wait_for_text(text=Changes.BlankVue.VUE_TEMPLATE.old_text)
Expand All @@ -114,9 +113,8 @@ def __workflow(preview, app_name, platform, device, bundle=True, hmr=True):
if preview:
Log.info('Skip logs checks.')
else:
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL,
bundle=bundle,
hmr=hmr, app_type=AppType.VUE, file_name='Home.vue')
strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, hmr=hmr,
app_type=AppType.VUE, file_name='Home.vue')
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
not_existing_string_list=not_existing_string_list)

Expand All @@ -130,9 +128,9 @@ def __workflow(preview, app_name, platform, device, bundle=True, hmr=True):
device.screen_match(expected_image=initial_state, tolerance=1.0, timeout=30)


def sync_blank_vue(app_name, platform, device, bundle=True, hmr=True):
__workflow(preview=False, app_name=app_name, platform=platform, device=device, bundle=bundle, hmr=hmr)
def sync_blank_vue(app_name, platform, device, hmr=True):
__workflow(preview=False, app_name=app_name, platform=platform, device=device, hmr=hmr)


def preview_blank_vue(app_name, platform, device, bundle=True, hmr=True):
__workflow(preview=True, app_name=app_name, platform=platform, device=device, bundle=bundle, hmr=hmr)
def preview_blank_vue(app_name, platform, device, hmr=True):
__workflow(preview=True, app_name=app_name, platform=platform, device=device, hmr=hmr)
4 changes: 2 additions & 2 deletions data/sync/master_detail_vue.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def sync_master_detail_vue(app_name, platform, device, bundle=True, hmr=True):
bundle=bundle, hmr=hmr, app_type=AppType.VUE, file_name='CarList.vue')
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
not_existing_string_list=not_existing_string_list)
style_applied = Wait.until(lambda: device.get_pixels_by_color(Colors.RED_DARK) > 200)
style_applied = Wait.until(lambda: device.get_pixels_by_color(Colors.LIGHT_BLUE) > 200)
assert style_applied, 'Failed to sync changes in style.'

# Revert styling in .vue file
Expand All @@ -66,7 +66,7 @@ def sync_master_detail_vue(app_name, platform, device, bundle=True, hmr=True):
bundle=bundle, hmr=hmr, app_type=AppType.VUE, file_name='CarList.vue')
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings,
not_existing_string_list=not_existing_string_list)
style_applied = Wait.until(lambda: device.get_pixels_by_color(Colors.WHITE) > 200)
style_applied = Wait.until(lambda: device.get_pixels_by_color(Colors.LIGHT_BLUE) < 200)
assert style_applied, 'Failed to sync changes in style.'

device.wait_for_text(text="Ford KA")
Expand Down