Skip to content

Commit 2e31bfd

Browse files
authored
chore: merge master in release (#444)
* fix: docker on win (#434) * fix: cases when iOS version is 3 digits (#437) * fix: cases when Xcode version is 3 digits * chore: remove unused noinspection * fix: preview fallback path (#436) * set preview falback path according to os * fix win path * fix lint errors * fix: livesync failures (#438) * update master detail changes * update changes in hello world ng template * fix process name * chore: remove doctor templates (#439) - Remove doctor templates. - Add Tab Navigation Vue template. * chore: change the way we assert changes to improve tests stability * fix: flake8 error * fix: win path in package.json (#443) * fix path on win * fix paths on windows * update variable name * use fail_safe option
1 parent 3f2ebb7 commit 2e31bfd

File tree

11 files changed

+62
-48
lines changed

11 files changed

+62
-48
lines changed

core/settings/Settings.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,18 @@ class Packages(object):
103103
if ENV == EnvironmentType.LIVE:
104104
__default_preview_folder = 'latest-official'
105105
PREVIEW_APP_ID = "org.nativescript.preview"
106-
PREVIEW_PATH = os.environ.get('preview_folder_path', os.path.join("/tns-dist", "Playground",
107-
"ns-play-dev", __default_preview_folder))
108-
PLAYGROUND_PATH = os.environ.get('playground_folder_path', os.path.join("/tns-dist", "Playground",
109-
"ns-play", __default_preview_folder))
106+
if os.name == 'nt':
107+
PREVIEW_PATH = os.environ.get('preview_folder_path',
108+
os.path.join("\\\\telerik.com\\distributions\\DailyBuilds\\NativeScript",
109+
"Playground", "ns-play-dev", __default_preview_folder))
110+
PLAYGROUND_PATH = os.environ.get('playground_folder_path',
111+
os.path.join("\\\\telerik.com\\distributions\\DailyBuilds\\NativeScript",
112+
"Playground", "ns-play", __default_preview_folder))
113+
else:
114+
PREVIEW_PATH = os.environ.get('preview_folder_path', os.path.join("/tns-dist", "Playground",
115+
"ns-play-dev", __default_preview_folder))
116+
PLAYGROUND_PATH = os.environ.get('playground_folder_path', os.path.join("/tns-dist", "Playground",
117+
"ns-play", __default_preview_folder))
110118

111119
PREVIEW_APP_IOS = os.path.join(PREVIEW_PATH, "nsplaydev.tgz")
112120
PREVIEW_APP_ANDROID = os.path.join(PREVIEW_PATH, "app-universal-release.apk")

core/utils/device/simctl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from core.utils.file_utils import File
77
from core.utils.process import Process
88
from core.utils.run import run
9+
from core.utils.version import Version
910

1011

11-
# noinspection PyShadowingBuiltins
1212
class Simctl(object):
1313

1414
@staticmethod
@@ -31,7 +31,6 @@ def __get_simulators():
3131
def get_max_runtime_version(version):
3232
# Parse runtimes
3333
result = Simctl.run_simctl_command(command='list --json runtimes')
34-
runtimes = None
3534
try:
3635
runtimes = json.loads(result.output)
3736
except ValueError:
@@ -42,7 +41,7 @@ def get_max_runtime_version(version):
4241
exact_sdk_version = None
4342
for runtime in runtimes['runtimes']:
4443
if str(version) in runtime['version'] and runtime['name'].startswith('iOS') and runtime['isAvailable']:
45-
exact_sdk_version = runtime['version']
44+
exact_sdk_version = Version.get(runtime['version'])
4645
if exact_sdk_version is None:
4746
raise Exception('Can not find iOS SDK {0}'.format(version))
4847

core/utils/docker.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,24 @@ class Docker(object):
1313
def start():
1414
if Settings.HOST_OS == OSType.WINDOWS:
1515
docker = os.environ.get("DOCKER_HOME")
16-
if docker is not None:
17-
cmd = '"' + os.path.join(docker, 'Docker Desktop.exe') + '"'
18-
run(cmd=cmd, wait=False)
19-
Log.info('Starting docker!')
20-
else:
21-
cmd = r'"C:\Program Files\Docker\Docker\Docker Desktop.exe"'
16+
if not Process.is_running_by_name('Docker Desktop'):
17+
if docker is not None:
18+
cmd = '"' + os.path.join(docker, 'Docker Desktop.exe') + '"'
19+
run(cmd=cmd, wait=False)
20+
Log.info('Starting docker!')
21+
else:
22+
cmd = r'"C:\Program Files\Docker\Docker\Docker Desktop.exe"'
23+
run(cmd=cmd, wait=False)
24+
Log.info('Starting docker!')
25+
elif OSUtils.is_catalina():
26+
if not Process.is_running_by_name('Docker'):
27+
cmd = 'open --background -a Docker'
2228
run(cmd=cmd, wait=False)
2329
Log.info('Starting docker!')
24-
elif OSUtils.is_catalina():
25-
cmd = 'open --background -a Docker'
26-
run(cmd=cmd, wait=False)
27-
Log.info('Starting docker!')
2830
else:
2931
Log.info('No need to start docker!')
3032

3133
@staticmethod
3234
def stop():
33-
if Settings.HOST_OS == OSType.WINDOWS:
34-
Process.kill('Docker Desktop')
35-
Process.kill('Docker.Watchguard')
36-
Process.kill('com.docker.backend')
37-
Process.kill('com.docker.proxy')
3835
if OSUtils.is_catalina():
3936
Process.kill('Docker')

core/utils/version.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ class Version(object):
88
def get(version):
99
"""
1010
Convert version string to float.
11+
Will also trim version like this:
12+
- 13.2.2 will be trimmed to 13.2
1113
:param version: Version string.
1214
:return: Version as float.
1315
"""

data/changes.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class NGHelloWorld(object):
6666
old_value='Ter Stegen', new_value='Unknown',
6767
old_text='Ter Stegen', new_text='Unknown')
6868
CSS = ChangeSet(file_path=os.path.join('src', 'app.css'),
69-
old_value='}', new_value='}\nListView { background-color: pink;}\n',
69+
old_value='}', new_value='}\nLabel{background-color:pink;}\n',
7070
old_color=Colors.WHITE, new_color=Colors.PINK)
7171
HTML = ChangeSet(file_path=os.path.join('src', 'app', 'item', 'items.component.html'), old_value='"item.name"',
7272
new_value='"item.id"', old_text=None, new_text=None)
@@ -105,20 +105,20 @@ class MasterDetailNG(object):
105105

106106
# This change should make background of items on home page purple
107107
SCSS_NESTED_COMMON = ChangeSet(file_path=os.path.join('src', 'app', 'cars', '_car-list.component.scss'),
108-
old_value='$background-color: background',
109-
new_value='$background-color: purple',
110-
old_color=Colors.WHITE, new_color=Colors.PURPLE_CUSTOM)
108+
old_value='background-alt-10);',
109+
new_value='background-alt-10);\nbackground-color: yellow;',
110+
old_color=Colors.WHITE, new_color=Colors.YELLOW)
111111

112112
# This change should make icons on home page yellow
113113
SCSS_NESTED_ANDROID = ChangeSet(file_path=os.path.join('src', 'app', 'cars', 'car-list.component.android.scss'),
114114
old_value='Android here',
115-
new_value='Android here\n.cars-list__item{ color: yellow; }\n',
116-
old_color=None, new_color=Colors.YELLOW)
115+
new_value='Android here\n.cars-list__item-name{background-color: orange;}\n',
116+
old_color=None, new_color=Colors.ORANGE)
117117

118118
SCSS_NESTED_IOS = ChangeSet(file_path=os.path.join('src', 'app', 'cars', 'car-list.component.ios.scss'),
119119
old_value='iOS here',
120-
new_value='iOS here\n.cars-list__item{ color: yellow; }\n',
121-
old_color=None, new_color=Colors.YELLOW)
120+
new_value='iOS here\n.cars-list__item-name{background-color: orange;}\n',
121+
old_color=None, new_color=Colors.ORANGE)
122122

123123
class JSTabNavigation(object):
124124
JS = ChangeSet(file_path=os.path.join('app', 'home', 'home-items-view-model.js'),
@@ -203,12 +203,12 @@ class DateTimePicker(object):
203203
COMMON_TS = ChangeSet(file_path=os.path.join(DATETIME_PICKER_PATH, 'ui', 'date-picker-field.common.ts'),
204204
old_value='name: "date",',
205205
new_value='name: "date", defaultValue: new Date(),')
206-
ANDROID_TS = ChangeSet(file_path=os.path.join(DATETIME_PICKER_PATH, 'datetimepicker.android.ts'),
207-
old_value='datePicker.init(date.getFullYear(), date.getMonth(), date.getDate(), null);',
208-
new_value='datePicker.init(2010, date.getMonth(), date.getDate(), null);')
209-
IOS_TS = ChangeSet(file_path=os.path.join(DATETIME_PICKER_PATH, 'datetimepicker.ios.ts'),
210-
old_value='pickerView.date = date;',
211-
new_value='date.setFullYear(2010); pickerView.date = date;')
206+
ANDROID_TS = ChangeSet(file_path=os.path.join(DATETIME_PICKER_PATH, 'ui', 'date-picker-field.android.ts'),
207+
old_value='this.nativeView.setFocusable(false);',
208+
new_value='this.nativeView.setFocusable(false); this.hint = "testMessage";')
209+
IOS_TS = ChangeSet(file_path=os.path.join(DATETIME_PICKER_PATH, 'ui', 'date-picker-field.ios.ts'),
210+
old_value='export class DatePickerField extends DatePickerFieldBase {',
211+
new_value='export class DatePickerField extends DatePickerFieldBase {initNativeView() {this.hint = "testMessage";}') # noqa: E501 pylint: disable=line-too-long
212212

213213
class AppFileChanges(object):
214214
CHANGE_XML_INVALID_SYNTAX = ChangeSet(file_path=os.path.join('app', 'main-page.xml'),

data/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ class Colors(object):
1919
PURPLE_CUSTOM = numpy.array([255, 48, 129]) # A bit custom purple (when apply purple on master-detail).
2020
YELLOW = numpy.array([0, 255, 255]) # Yellow (standard CSS color).
2121
YELLOW_ICON = numpy.array([0, 242, 255]) # Yellow of star.png
22+
ORANGE = numpy.array([0, 165, 255]) # Orange (standard CSS color).
2223
GREEN_ICON = numpy.array([0, 128, 0]) # Green of background colour of resources generate images

data/sync/hello_world_ng.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
from core.enums.device_type import DeviceType
99
from core.enums.platform_type import Platform
1010
from core.enums.os_type import OSType
11+
from core.log.log import Log
1112
from core.settings import Settings
13+
from core.utils.wait import Wait
1214
from data.changes import Changes, Sync
1315
from data.const import Colors
1416
from products.nativescript.preview_helpers import Preview
@@ -90,7 +92,9 @@ def sync_hello_world_ng(app_name, platform, device, bundle=True, uglify=False, a
9092
device=device)
9193
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180,
9294
not_existing_string_list=not_existing_string_list)
93-
device.wait_for_main_color(color=Changes.NGHelloWorld.CSS.new_color)
95+
assert Wait.until(lambda: device.get_pixels_by_color(color=Changes.NGHelloWorld.CSS.new_color) > 100), \
96+
'CSS on root level not applied!'
97+
Log.info('CSS on root level applied successfully!')
9498

9599
# Revert changes
96100
Sync.revert(app_name=app_name, change_set=Changes.NGHelloWorld.HTML)
@@ -116,7 +120,9 @@ def sync_hello_world_ng(app_name, platform, device, bundle=True, uglify=False, a
116120
device=device)
117121
TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180,
118122
not_existing_string_list=not_existing_string_list)
119-
device.wait_for_main_color(color=Colors.WHITE)
123+
assert Wait.until(lambda: device.get_pixels_by_color(color=Changes.NGHelloWorld.CSS.new_color) < 100), \
124+
'CSS on root level not applied!'
125+
Log.info('CSS on root level applied successfully!')
120126

121127
# Assert final and initial states are same
122128
initial_state = os.path.join(Settings.TEST_OUT_IMAGES, device.name, 'initial_state.png')

data/sync/plugin_src.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,4 @@ def sync_plugin_platform_spec(app_name, app_type, log_result, platform, device,
9696
app_type=app_type)
9797
TnsLogs.wait_for_log(log_file=log_result.log_file, string_list=strings, timeout=60)
9898
device.click(text="DatePickerField")
99-
device.wait_for_text("select date")
100-
device.click(text="select date")
101-
device.click(text="OK")
102-
date = datetime.date.today().replace(year=2010)
103-
date = date.strftime("%b %-d, %Y")
104-
device.wait_for_text(str(date))
99+
device.wait_for_text("testMessage")

data/templates.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class Template(object):
5656
TAB_NAVIGATION_JS = gen_template_info(name='template-tab-navigation', app_type=AppType.JS, texts=tn_str)
5757
TAB_NAVIGATION_TS = gen_template_info(name='template-tab-navigation-ts', app_type=AppType.TS, texts=tn_str)
5858
TAB_NAVIGATION_NG = gen_template_info(name='template-tab-navigation-ng', app_type=AppType.NG, texts=tn_str)
59+
TAB_NAVIGATION_VUE = gen_template_info(name='template-tab-navigation-vue', app_type=AppType.VUE, texts=tn_str)
5960

6061
# Health templates
6162
HEALTH_SURVEY_NG = gen_template_info(name='template-health-survey-ng', app_type=AppType.NG, texts=login)

products/nativescript/app.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
import os
33

44
from core.settings import Settings
5-
from core.utils.file_utils import Folder
5+
from core.utils.file_utils import Folder, File
66
from core.utils.json_utils import JsonUtils
77
from core.utils.npm import Npm
88
from core.utils.run import run
9+
from core.enums.os_type import OSType
910

1011

1112
class App(object):
@@ -84,3 +85,8 @@ def update(app_name, modules=True, angular=True, typescript=False, web_pack=True
8485
if vue and App.is_dependency(app_name=app_name, dependency='nativescript-vue'):
8586
Npm.uninstall(package='nativescript-vue', option='--save', folder=app_path)
8687
Npm.install(package='nativescript-vue@next', option='--save --save-exact', folder=app_path)
88+
# on win when `npm i` is executed with path to .tgz it saves in package.json unix style path
89+
# which cannot be resolved on win
90+
if Settings.HOST_OS == OSType.WINDOWS:
91+
package_json = os.path.join(Settings.TEST_RUN_HOME, app_name, 'package.json')
92+
File.replace(package_json, 'file://', '\\\\\\\\', fail_safe=True)

tests/templates/template_tests.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class TemplateTests(TnsRunTest):
3333
[Template.DRAWER_NAVIGATION_TS.name, Template.DRAWER_NAVIGATION_TS],
3434
[Template.DRAWER_NAVIGATION_NG.name, Template.DRAWER_NAVIGATION_NG],
3535
[Template.DRAWER_NAVIGATION_VUE.name, Template.DRAWER_NAVIGATION_VUE],
36-
[Template.HEALTH_SURVEY_NG.name, Template.HEALTH_SURVEY_NG],
3736
[Template.HELLO_WORLD_JS.name, Template.HELLO_WORLD_JS],
3837
[Template.HELLO_WORLD_TS.name, Template.HELLO_WORLD_TS],
3938
[Template.HELLO_WORLD_NG.name, Template.HELLO_WORLD_NG],
@@ -44,10 +43,10 @@ class TemplateTests(TnsRunTest):
4443
[Template.MASTER_DETAIL_TS.name, Template.MASTER_DETAIL_TS],
4544
[Template.MASTER_DETAIL_NG.name, Template.MASTER_DETAIL_NG],
4645
[Template.MASTER_DETAIL_VUE.name, Template.MASTER_DETAIL_VUE],
47-
[Template.PATIENT_CARE_NG.name, Template.PATIENT_CARE_NG],
4846
[Template.TAB_NAVIGATION_JS.name, Template.TAB_NAVIGATION_JS],
4947
[Template.TAB_NAVIGATION_TS.name, Template.TAB_NAVIGATION_TS],
50-
[Template.TAB_NAVIGATION_NG.name, Template.TAB_NAVIGATION_NG]
48+
[Template.TAB_NAVIGATION_NG.name, Template.TAB_NAVIGATION_NG],
49+
[Template.TAB_NAVIGATION_VUE.name, Template.TAB_NAVIGATION_VUE]
5150
]
5251

5352
@parameterized.expand(test_data)

0 commit comments

Comments
 (0)