From 25ce0b89f6271e988b66b1e4ff392c8256304d9f Mon Sep 17 00:00:00 2001 From: Maria Endarova Date: Tue, 5 Nov 2019 16:50:07 +0200 Subject: [PATCH] chore: update to new templates (#417) * update theme path * update theme to next by default * update css changes * use master branch for templates * fix wait for color * update master detail changes * update master detail changes * update tabstrip changes * lint fixes * fix: lint * fix: lint * chore: fix lint * fix: lint * fix: lint --- core/settings/Settings.py | 2 +- data/changes.py | 66 +++++++++++++++-------------- data/const.py | 1 + data/sync/hello_world_js.py | 2 +- data/sync/hello_world_ng.py | 5 +-- products/nativescript/app.py | 5 ++- products/nativescript/tns_assert.py | 2 +- 7 files changed, 45 insertions(+), 38 deletions(-) diff --git a/core/settings/Settings.py b/core/settings/Settings.py index 3544c710..bc66d63e 100644 --- a/core/settings/Settings.py +++ b/core/settings/Settings.py @@ -125,7 +125,7 @@ class Packages(object): SASS = resolve_package(name='nativescript-dev-sass', variable='nativescript_dev_sass') # Templates branch - TEMPLATES_BRANCH = os.environ.get('templates_branch', 'release') + TEMPLATES_BRANCH = os.environ.get('templates_branch', 'master') # noinspection SpellCheckingInspection diff --git a/data/changes.py b/data/changes.py index e8b58abf..373b1e58 100644 --- a/data/changes.py +++ b/data/changes.py @@ -5,7 +5,6 @@ from data.const import Colors -# noinspection PyShadowingBuiltins class ChangeSet(object): def __init__(self, file_path, old_value, new_value, old_text=None, new_text=None, old_color=None, new_color=None): self.file_path = file_path @@ -35,7 +34,8 @@ class JSHelloWord(object): old_value='taps left', new_value='clicks left', old_text='taps left', new_text='clicks left') CSS = ChangeSet(file_path=os.path.join('app', 'app.css'), - old_value='font-size: 18', new_value='font-size: 50', + old_value='font-size: 18', + new_value='font-size: 18;\nbackground-color: red;', old_color=None, new_color=None) XML = ChangeSet(file_path=os.path.join('app', 'main-page.xml'), old_value='TAP', new_value='HIT', @@ -54,7 +54,8 @@ class TSHelloWord(object): old_value='taps left', new_value='clicks left', old_text='taps left', new_text='clicks left') CSS = ChangeSet(file_path=os.path.join('app', 'app.css'), - old_value='font-size: 18', new_value='font-size: 50', + old_value='font-size: 18', + new_value='font-size: 18;\nbackground-color: red;', old_color=None, new_color=None) XML = ChangeSet(file_path=os.path.join('app', 'main-page.xml'), old_value='TAP', new_value='HIT', @@ -65,11 +66,10 @@ class NGHelloWorld(object): old_value='Ter Stegen', new_value='Unknown', old_text='Ter Stegen', new_text='Unknown') CSS = ChangeSet(file_path=os.path.join('src', 'app.css'), - old_value='light', new_value='dark', - old_color=Colors.WHITE, new_color=Colors.DARK) - HTML = ChangeSet(file_path=os.path.join('src', 'app', 'item', 'items.component.html'), - old_value='"item.name"', new_value='"item.id"', - old_text=None, new_text=None) + old_value='}', new_value='}\nListView { background-color: pink;}\n', + old_color=Colors.WHITE, new_color=Colors.PINK) + HTML = ChangeSet(file_path=os.path.join('src', 'app', 'item', 'items.component.html'), old_value='"item.name"', + new_value='"item.id"', old_text=None, new_text=None) XML_ACTION_BAR = ChangeSet(file_path=os.path.join('src', 'app', 'item', 'items.component.html'), old_value='My App', new_value='TestApp', old_text='My App', new_text='TestApp') @@ -89,33 +89,35 @@ class MasterDetailNG(object): # This change should make title of cars pink SCSS_ROOT_COMMON = ChangeSet(file_path=os.path.join('src', '_app-common.scss'), - old_value='$accent-dark;', new_value='pink;', + old_value='font-weight: 900;', + new_value='font-weight: 900;\nbackground-color: pink;\n', old_color=Colors.ACCENT_DARK, new_color=Colors.PINK) # This change should add some red between list view items on home page SCSS_ROOT_ANDROID = ChangeSet(file_path=os.path.join('src', 'app.android.scss'), old_value='Android here', - new_value='Android here\n.page { background-color: red;}\n', - old_color=Colors.WHITE, new_color=Colors.RED_DARK) + new_value='Android here\n.m-r-20{ background-color: red; }\n', + old_color=Colors.WHITE, new_color=Colors.RED) SCSS_ROOT_IOS = ChangeSet(file_path=os.path.join('src', 'app.ios.scss'), old_value='iOS here', - new_value='iOS here\n.page { padding: 30; background-color: red; }\n', + new_value='iOS here\n.m-r-20{ background-color: red; }\n', old_color=Colors.WHITE, new_color=Colors.RED) # This change should make background of items on home page purple SCSS_NESTED_COMMON = ChangeSet(file_path=os.path.join('src', 'app', 'cars', '_car-list.component.scss'), - old_value='$background-light;', new_value='purple;', - old_color=Colors.WHITE, new_color=Colors.PURPLE) + old_value='$background-color: background', + new_value='$background-color: purple', + old_color=Colors.WHITE, new_color=Colors.PURPLE_CUSTOM) # This change should make icons on home page yellow SCSS_NESTED_ANDROID = ChangeSet(file_path=os.path.join('src', 'app', 'cars', 'car-list.component.android.scss'), old_value='Android here', - new_value='Android here\n.list-group{.list-group-item{.fa{color:yellow;}}}\n', + new_value='Android here\n.cars-list__item{ color: yellow; }\n', old_color=None, new_color=Colors.YELLOW) SCSS_NESTED_IOS = ChangeSet(file_path=os.path.join('src', 'app', 'cars', 'car-list.component.ios.scss'), old_value='iOS here', - new_value='iOS here\n.list-group{.list-group-item{.fa{color:yellow;}}}\n', + new_value='iOS here\n.cars-list__item{ color: yellow; }\n', old_color=None, new_color=Colors.YELLOW) class JSTabNavigation(object): @@ -126,16 +128,19 @@ class JSTabNavigation(object): old_value='Home', new_value='Test', old_text='Home', new_text='Test') - # This change should make title of home red - SCSS_VARIABLES = ChangeSet(file_path=os.path.join('app', '_app-variables.scss'), - old_value='#D7D7D7', new_value='red', - old_color='#D7D7D7', new_color=Colors.RED) + # This change should make background of home red + SCSS_VARIABLES = ChangeSet(file_path=os.path.join('app', '_app-common.scss'), + old_value='Font icon class', + new_value='Font icon class\n.page__content{ background-color: red; }\n', + old_color=None, new_color=Colors.RED) SCSS_ROOT_ANDROID = ChangeSet(file_path=os.path.join('app', 'app.android.scss'), - old_value='$blue-dark;', new_value='pink;', - old_color=Colors.ACCENT_DARK, new_color=Colors.PINK) + old_value='Android here', + new_value='Android here\n.navigation__item{ background-color: yellow; }\n', + old_color=None, new_color=Colors.YELLOW) SCSS_ROOT_IOS = ChangeSet(file_path=os.path.join('app', 'app.ios.scss'), - old_value='$item-active-color;', new_value='pink;', - old_color=Colors.ACCENT_DARK, new_color=Colors.PINK) + old_value='iOS here', + new_value='iOS here\n.navigation__item{ background-color: yellow; }\n', + old_color=None, new_color=Colors.YELLOW) class TSTabNavigation(object): TS = ChangeSet(file_path=os.path.join('src', 'app', 'home', 'home-items-view-model.ts'), @@ -194,15 +199,14 @@ class MasterDetailVUE(object): old_text='/day', new_text='/24h') class DateTimePicker(object): - COMMON_TS = ChangeSet(file_path=os.path.join( - Settings.TEST_SUT_HOME, 'nativescript-datetimepicker', 'src', 'ui', 'date-picker-field.common.ts'), - old_value='name: "date",', new_value='name: "date", defaultValue: new Date(),') - ANDROID_TS = ChangeSet(file_path=os.path.join( - Settings.TEST_SUT_HOME, 'nativescript-datetimepicker', 'src', 'datetimepicker.android.ts'), + DATETIME_PICKER_PATH = os.path.join(Settings.TEST_SUT_HOME, 'nativescript-datetimepicker', 'src') + COMMON_TS = ChangeSet(file_path=os.path.join(DATETIME_PICKER_PATH, 'ui', 'date-picker-field.common.ts'), + old_value='name: "date",', + new_value='name: "date", defaultValue: new Date(),') + ANDROID_TS = ChangeSet(file_path=os.path.join(DATETIME_PICKER_PATH, 'datetimepicker.android.ts'), old_value='datePicker.init(date.getFullYear(), date.getMonth(), date.getDate(), null);', new_value='datePicker.init(2010, date.getMonth(), date.getDate(), null);') - IOS_TS = ChangeSet(file_path=os.path.join( - Settings.TEST_SUT_HOME, 'nativescript-datetimepicker', 'src', 'datetimepicker.ios.ts'), + IOS_TS = ChangeSet(file_path=os.path.join(DATETIME_PICKER_PATH, 'datetimepicker.ios.ts'), old_value='pickerView.date = date;', new_value='date.setFullYear(2010); pickerView.date = date;') diff --git a/data/const.py b/data/const.py index b80fe964..fcd7330b 100644 --- a/data/const.py +++ b/data/const.py @@ -16,6 +16,7 @@ class Colors(object): RED = numpy.array([0, 0, 255]) # Red (standard CSS color). RED_DARK = numpy.array([5, 4, 229]) # A bit custom red (happens when apply red on master-detail template). PURPLE = numpy.array([128, 0, 128]) # Purple (standard CSS color). + PURPLE_CUSTOM = numpy.array([255, 48, 129]) # A bit custom purple (when apply purple on master-detail). YELLOW = numpy.array([0, 255, 255]) # Yellow (standard CSS color). YELLOW_ICON = numpy.array([0, 242, 255]) # Yellow of star.png GREEN_ICON = numpy.array([0, 128, 0]) # Green of background colour of resources generate images diff --git a/data/sync/hello_world_js.py b/data/sync/hello_world_js.py index 6f0372ff..791cebe7 100644 --- a/data/sync/hello_world_js.py +++ b/data/sync/hello_world_js.py @@ -95,7 +95,7 @@ def __sync_hello_world_js_ts(app_type, app_name, platform, device, bundle=True, # Edit CSS file and verify changes are applied blue_count = device.get_pixels_by_color(color=Colors.LIGHT_BLUE) Sync.replace(app_name=app_name, change_set=css_change) - device.wait_for_color(color=Colors.LIGHT_BLUE, pixel_count=blue_count * 2, delta=25) + device.wait_for_color(color=Colors.RED, pixel_count=blue_count) device.wait_for_text(text=xml_change.old_text) device.wait_for_text(text=js_change.old_text) strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, bundle=bundle, diff --git a/data/sync/hello_world_ng.py b/data/sync/hello_world_ng.py index 97c0b4bd..27a9eb25 100644 --- a/data/sync/hello_world_ng.py +++ b/data/sync/hello_world_ng.py @@ -78,7 +78,6 @@ def sync_hello_world_ng(app_name, platform, device, bundle=True, uglify=False, a not_existing_string_list=not_existing_string_list) Sync.replace(app_name=app_name, change_set=Changes.NGHelloWorld.CSS) - device.wait_for_main_color(color=Colors.DARK) if platform == Platform.IOS: for number in ["10", "1"]: device.wait_for_text(text=number) @@ -91,6 +90,7 @@ def sync_hello_world_ng(app_name, platform, device, bundle=True, uglify=False, a device=device) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180, not_existing_string_list=not_existing_string_list) + device.wait_for_main_color(color=Colors.PINK) # Revert changes Sync.revert(app_name=app_name, change_set=Changes.NGHelloWorld.HTML) @@ -103,7 +103,6 @@ def sync_hello_world_ng(app_name, platform, device, bundle=True, uglify=False, a Sync.revert(app_name=app_name, change_set=Changes.NGHelloWorld.TS) device.wait_for_text(text=Changes.NGHelloWorld.TS.old_text) - device.wait_for_main_color(color=Colors.DARK) strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, bundle=bundle, file_name='item.service.ts', hmr=hmr, instrumented=instrumented, app_type=AppType.NG, device=device) @@ -111,13 +110,13 @@ def sync_hello_world_ng(app_name, platform, device, bundle=True, uglify=False, a not_existing_string_list=not_existing_string_list) Sync.revert(app_name=app_name, change_set=Changes.NGHelloWorld.CSS) - device.wait_for_main_color(color=Colors.WHITE) device.wait_for_text(text=Changes.NGHelloWorld.TS.old_text) strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, bundle=bundle, file_name='app.css', hmr=hmr, instrumented=instrumented, app_type=AppType.NG, device=device) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180, not_existing_string_list=not_existing_string_list) + device.wait_for_main_color(color=Colors.WHITE) # Assert final and initial states are same initial_state = os.path.join(Settings.TEST_OUT_IMAGES, device.name, 'initial_state.png') diff --git a/products/nativescript/app.py b/products/nativescript/app.py index feccee6c..2c7a3bbc 100644 --- a/products/nativescript/app.py +++ b/products/nativescript/app.py @@ -45,12 +45,15 @@ def install_dev_dependency(app_name, dependency, version='latest'): Npm.install(package='{0}@{1}'.format(dependency, version), option='--save-dev --save-exact', folder=app_path) @staticmethod - def update(app_name, modules=True, angular=True, typescript=False, web_pack=True, vue=True): + def update(app_name, modules=True, angular=True, typescript=False, web_pack=True, vue=True, theme=True): app_path = os.path.join(Settings.TEST_RUN_HOME, app_name) modules_path = os.path.join(app_path, 'node_modules') if modules and App.is_dependency(app_name=app_name, dependency='tns-core-modules'): Npm.uninstall(package='tns-core-modules', option='--save', folder=app_path) Npm.install(package=Settings.Packages.MODULES, option='--save --save-exact', folder=app_path) + if theme and App.is_dependency(app_name=app_name, dependency='@nativescript/theme'): + Npm.uninstall(package='@nativescript/theme', option='--save', folder=app_path) + Npm.install(package='@nativescript/theme@next', option='--save --save-exact', folder=app_path) if angular and App.is_dependency(app_name=app_name, dependency='nativescript-angular'): Npm.uninstall(package='nativescript-angular', option='--save', folder=app_path) Npm.install(package=Settings.Packages.ANGULAR, option='--save --save-exact', folder=app_path) diff --git a/products/nativescript/tns_assert.py b/products/nativescript/tns_assert.py index 9d1dbb57..f013ee5f 100644 --- a/products/nativescript/tns_assert.py +++ b/products/nativescript/tns_assert.py @@ -48,7 +48,7 @@ def created(app_name, output=None, app_data=None, path=Settings.TEST_RUN_HOME, w # Verify {N} core theme is installed if theme: - assert Folder.exists(os.path.join(node_path, 'nativescript-theme-core')), '{N} theme do not exists.' + assert Folder.exists(os.path.join(node_path, '@nativescript', 'theme')), '{N} theme do not exists.' # Verify webpack is installed before_watch_hooks = os.path.join(app_path, 'hooks', 'before-watch')