Skip to content

chore: merge master in release #444

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 10 commits into from
Nov 20, 2019
16 changes: 12 additions & 4 deletions core/settings/Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,18 @@ class Packages(object):
if ENV == EnvironmentType.LIVE:
__default_preview_folder = 'latest-official'
PREVIEW_APP_ID = "org.nativescript.preview"
PREVIEW_PATH = os.environ.get('preview_folder_path', os.path.join("/tns-dist", "Playground",
"ns-play-dev", __default_preview_folder))
PLAYGROUND_PATH = os.environ.get('playground_folder_path', os.path.join("/tns-dist", "Playground",
"ns-play", __default_preview_folder))
if os.name == 'nt':
PREVIEW_PATH = os.environ.get('preview_folder_path',
os.path.join("\\\\telerik.com\\distributions\\DailyBuilds\\NativeScript",
"Playground", "ns-play-dev", __default_preview_folder))
PLAYGROUND_PATH = os.environ.get('playground_folder_path',
os.path.join("\\\\telerik.com\\distributions\\DailyBuilds\\NativeScript",
"Playground", "ns-play", __default_preview_folder))
else:
PREVIEW_PATH = os.environ.get('preview_folder_path', os.path.join("/tns-dist", "Playground",
"ns-play-dev", __default_preview_folder))
PLAYGROUND_PATH = os.environ.get('playground_folder_path', os.path.join("/tns-dist", "Playground",
"ns-play", __default_preview_folder))

PREVIEW_APP_IOS = os.path.join(PREVIEW_PATH, "nsplaydev.tgz")
PREVIEW_APP_ANDROID = os.path.join(PREVIEW_PATH, "app-universal-release.apk")
Expand Down
5 changes: 2 additions & 3 deletions core/utils/device/simctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from core.utils.file_utils import File
from core.utils.process import Process
from core.utils.run import run
from core.utils.version import Version


# noinspection PyShadowingBuiltins
class Simctl(object):

@staticmethod
Expand All @@ -31,7 +31,6 @@ def __get_simulators():
def get_max_runtime_version(version):
# Parse runtimes
result = Simctl.run_simctl_command(command='list --json runtimes')
runtimes = None
try:
runtimes = json.loads(result.output)
except ValueError:
Expand All @@ -42,7 +41,7 @@ def get_max_runtime_version(version):
exact_sdk_version = None
for runtime in runtimes['runtimes']:
if str(version) in runtime['version'] and runtime['name'].startswith('iOS') and runtime['isAvailable']:
exact_sdk_version = runtime['version']
exact_sdk_version = Version.get(runtime['version'])
if exact_sdk_version is None:
raise Exception('Can not find iOS SDK {0}'.format(version))

Expand Down
27 changes: 12 additions & 15 deletions core/utils/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,24 @@ class Docker(object):
def start():
if Settings.HOST_OS == OSType.WINDOWS:
docker = os.environ.get("DOCKER_HOME")
if docker is not None:
cmd = '"' + os.path.join(docker, 'Docker Desktop.exe') + '"'
run(cmd=cmd, wait=False)
Log.info('Starting docker!')
else:
cmd = r'"C:\Program Files\Docker\Docker\Docker Desktop.exe"'
if not Process.is_running_by_name('Docker Desktop'):
if docker is not None:
cmd = '"' + os.path.join(docker, 'Docker Desktop.exe') + '"'
run(cmd=cmd, wait=False)
Log.info('Starting docker!')
else:
cmd = r'"C:\Program Files\Docker\Docker\Docker Desktop.exe"'
run(cmd=cmd, wait=False)
Log.info('Starting docker!')
elif OSUtils.is_catalina():
if not Process.is_running_by_name('Docker'):
cmd = 'open --background -a Docker'
run(cmd=cmd, wait=False)
Log.info('Starting docker!')
elif OSUtils.is_catalina():
cmd = 'open --background -a Docker'
run(cmd=cmd, wait=False)
Log.info('Starting docker!')
else:
Log.info('No need to start docker!')

@staticmethod
def stop():
if Settings.HOST_OS == OSType.WINDOWS:
Process.kill('Docker Desktop')
Process.kill('Docker.Watchguard')
Process.kill('com.docker.backend')
Process.kill('com.docker.proxy')
if OSUtils.is_catalina():
Process.kill('Docker')
2 changes: 2 additions & 0 deletions core/utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class Version(object):
def get(version):
"""
Convert version string to float.
Will also trim version like this:
- 13.2.2 will be trimmed to 13.2
:param version: Version string.
:return: Version as float.
"""
Expand Down
28 changes: 14 additions & 14 deletions data/changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ 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='}', new_value='}\nListView { background-color: pink;}\n',
old_value='}', new_value='}\nLabel{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)
Expand Down Expand Up @@ -105,20 +105,20 @@ class MasterDetailNG(object):

# 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-color: background',
new_value='$background-color: purple',
old_color=Colors.WHITE, new_color=Colors.PURPLE_CUSTOM)
old_value='background-alt-10);',
new_value='background-alt-10);\nbackground-color: yellow;',
old_color=Colors.WHITE, new_color=Colors.YELLOW)

# 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.cars-list__item{ color: yellow; }\n',
old_color=None, new_color=Colors.YELLOW)
new_value='Android here\n.cars-list__item-name{background-color: orange;}\n',
old_color=None, new_color=Colors.ORANGE)

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.cars-list__item{ color: yellow; }\n',
old_color=None, new_color=Colors.YELLOW)
new_value='iOS here\n.cars-list__item-name{background-color: orange;}\n',
old_color=None, new_color=Colors.ORANGE)

class JSTabNavigation(object):
JS = ChangeSet(file_path=os.path.join('app', 'home', 'home-items-view-model.js'),
Expand Down Expand Up @@ -203,12 +203,12 @@ class DateTimePicker(object):
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(DATETIME_PICKER_PATH, 'datetimepicker.ios.ts'),
old_value='pickerView.date = date;',
new_value='date.setFullYear(2010); pickerView.date = date;')
ANDROID_TS = ChangeSet(file_path=os.path.join(DATETIME_PICKER_PATH, 'ui', 'date-picker-field.android.ts'),
old_value='this.nativeView.setFocusable(false);',
new_value='this.nativeView.setFocusable(false); this.hint = "testMessage";')
IOS_TS = ChangeSet(file_path=os.path.join(DATETIME_PICKER_PATH, 'ui', 'date-picker-field.ios.ts'),
old_value='export class DatePickerField extends DatePickerFieldBase {',
new_value='export class DatePickerField extends DatePickerFieldBase {initNativeView() {this.hint = "testMessage";}') # noqa: E501 pylint: disable=line-too-long

class AppFileChanges(object):
CHANGE_XML_INVALID_SYNTAX = ChangeSet(file_path=os.path.join('app', 'main-page.xml'),
Expand Down
1 change: 1 addition & 0 deletions data/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ class Colors(object):
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
ORANGE = numpy.array([0, 165, 255]) # Orange (standard CSS color).
GREEN_ICON = numpy.array([0, 128, 0]) # Green of background colour of resources generate images
10 changes: 8 additions & 2 deletions data/sync/hello_world_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from core.enums.device_type import DeviceType
from core.enums.platform_type import Platform
from core.enums.os_type import OSType
from core.log.log import Log
from core.settings import Settings
from core.utils.wait import Wait
from data.changes import Changes, Sync
from data.const import Colors
from products.nativescript.preview_helpers import Preview
Expand Down Expand Up @@ -90,7 +92,9 @@ 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=Changes.NGHelloWorld.CSS.new_color)
assert Wait.until(lambda: device.get_pixels_by_color(color=Changes.NGHelloWorld.CSS.new_color) > 100), \
'CSS on root level not applied!'
Log.info('CSS on root level applied successfully!')

# Revert changes
Sync.revert(app_name=app_name, change_set=Changes.NGHelloWorld.HTML)
Expand All @@ -116,7 +120,9 @@ 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.WHITE)
assert Wait.until(lambda: device.get_pixels_by_color(color=Changes.NGHelloWorld.CSS.new_color) < 100), \
'CSS on root level not applied!'
Log.info('CSS on root level applied successfully!')

# Assert final and initial states are same
initial_state = os.path.join(Settings.TEST_OUT_IMAGES, device.name, 'initial_state.png')
Expand Down
7 changes: 1 addition & 6 deletions data/sync/plugin_src.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,4 @@ def sync_plugin_platform_spec(app_name, app_type, log_result, platform, device,
app_type=app_type)
TnsLogs.wait_for_log(log_file=log_result.log_file, string_list=strings, timeout=60)
device.click(text="DatePickerField")
device.wait_for_text("select date")
device.click(text="select date")
device.click(text="OK")
date = datetime.date.today().replace(year=2010)
date = date.strftime("%b %-d, %Y")
device.wait_for_text(str(date))
device.wait_for_text("testMessage")
1 change: 1 addition & 0 deletions data/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Template(object):
TAB_NAVIGATION_JS = gen_template_info(name='template-tab-navigation', app_type=AppType.JS, texts=tn_str)
TAB_NAVIGATION_TS = gen_template_info(name='template-tab-navigation-ts', app_type=AppType.TS, texts=tn_str)
TAB_NAVIGATION_NG = gen_template_info(name='template-tab-navigation-ng', app_type=AppType.NG, texts=tn_str)
TAB_NAVIGATION_VUE = gen_template_info(name='template-tab-navigation-vue', app_type=AppType.VUE, texts=tn_str)

# Health templates
HEALTH_SURVEY_NG = gen_template_info(name='template-health-survey-ng', app_type=AppType.NG, texts=login)
Expand Down
8 changes: 7 additions & 1 deletion products/nativescript/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import os

from core.settings import Settings
from core.utils.file_utils import Folder
from core.utils.file_utils import Folder, File
from core.utils.json_utils import JsonUtils
from core.utils.npm import Npm
from core.utils.run import run
from core.enums.os_type import OSType


class App(object):
Expand Down Expand Up @@ -84,3 +85,8 @@ def update(app_name, modules=True, angular=True, typescript=False, web_pack=True
if vue and App.is_dependency(app_name=app_name, dependency='nativescript-vue'):
Npm.uninstall(package='nativescript-vue', option='--save', folder=app_path)
Npm.install(package='nativescript-vue@next', option='--save --save-exact', folder=app_path)
# on win when `npm i` is executed with path to .tgz it saves in package.json unix style path
# which cannot be resolved on win
if Settings.HOST_OS == OSType.WINDOWS:
package_json = os.path.join(Settings.TEST_RUN_HOME, app_name, 'package.json')
File.replace(package_json, 'file://', '\\\\\\\\', fail_safe=True)
5 changes: 2 additions & 3 deletions tests/templates/template_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class TemplateTests(TnsRunTest):
[Template.DRAWER_NAVIGATION_TS.name, Template.DRAWER_NAVIGATION_TS],
[Template.DRAWER_NAVIGATION_NG.name, Template.DRAWER_NAVIGATION_NG],
[Template.DRAWER_NAVIGATION_VUE.name, Template.DRAWER_NAVIGATION_VUE],
[Template.HEALTH_SURVEY_NG.name, Template.HEALTH_SURVEY_NG],
[Template.HELLO_WORLD_JS.name, Template.HELLO_WORLD_JS],
[Template.HELLO_WORLD_TS.name, Template.HELLO_WORLD_TS],
[Template.HELLO_WORLD_NG.name, Template.HELLO_WORLD_NG],
Expand All @@ -44,10 +43,10 @@ class TemplateTests(TnsRunTest):
[Template.MASTER_DETAIL_TS.name, Template.MASTER_DETAIL_TS],
[Template.MASTER_DETAIL_NG.name, Template.MASTER_DETAIL_NG],
[Template.MASTER_DETAIL_VUE.name, Template.MASTER_DETAIL_VUE],
[Template.PATIENT_CARE_NG.name, Template.PATIENT_CARE_NG],
[Template.TAB_NAVIGATION_JS.name, Template.TAB_NAVIGATION_JS],
[Template.TAB_NAVIGATION_TS.name, Template.TAB_NAVIGATION_TS],
[Template.TAB_NAVIGATION_NG.name, Template.TAB_NAVIGATION_NG]
[Template.TAB_NAVIGATION_NG.name, Template.TAB_NAVIGATION_NG],
[Template.TAB_NAVIGATION_VUE.name, Template.TAB_NAVIGATION_VUE]
]

@parameterized.expand(test_data)
Expand Down