Skip to content

Commit 31f07c7

Browse files
committed
fix: template tests
1 parent 7d0772b commit 31f07c7

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

core/utils/device/device.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ def get_main_color(self):
198198
# noinspection PyUnresolvedReferences
199199
def wait_for_main_color(self, color, timeout=30):
200200
result = Wait.until(lambda: (self.get_main_color() == color).all(), timeout=timeout)
201+
if result:
202+
Log.info('Main color is: ' + str(color))
201203
assert result, "Expected main color: " + str(color) + os.linesep + \
202204
"Actual main color: " + str(self.get_main_color())
203205

data/templates.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Template(object):
1919
dr_str = ['Page content goes here']
2020
tn_str = ['Item 1']
2121
login = ['Login']
22+
auth = ['Your Company Name']
2223

2324
# Blank templates
2425
BLANK_JS = gen_template_info(name='template-blank', app_type=AppType.JS)
@@ -54,9 +55,9 @@ class Template(object):
5455
TAB_NAVIGATION_NG = gen_template_info(name='template-tab-navigation-ng', app_type=AppType.NG, texts=tn_str)
5556

5657
# Enterprise auth templates
57-
ENTERPRISE_AUTH_JS = gen_template_info(name='template-enterprise-auth', app_type=AppType.JS, texts=login)
58-
ENTERPRISE_AUTH_TS = gen_template_info(name='template-enterprise-auth-ts', app_type=AppType.TS, texts=login)
59-
ENTERPRISE_AUTH_NG = gen_template_info(name='template-enterprise-auth-ng', app_type=AppType.NG, texts=login)
58+
ENTERPRISE_AUTH_JS = gen_template_info(name='template-enterprise-auth', app_type=AppType.JS, texts=auth)
59+
ENTERPRISE_AUTH_TS = gen_template_info(name='template-enterprise-auth-ts', app_type=AppType.TS, texts=auth)
60+
ENTERPRISE_AUTH_NG = gen_template_info(name='template-enterprise-auth-ng', app_type=AppType.NG, texts=auth)
6061

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

tests/live/template_tests.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from nose_parameterized import parameterized
44

5+
from const import Colors
56
from core.base_test.tns_test import TnsTest
67
from core.enums.env import EnvironmentType
78
from core.enums.os_type import OSType
@@ -11,6 +12,7 @@
1112
from data.templates import Template
1213
from products.nativescript.app import App
1314
from products.nativescript.tns import Tns
15+
from utils.device.adb import Adb
1416

1517

1618
# noinspection PyUnusedLocal
@@ -75,19 +77,26 @@ def test(self, template_name, template_info):
7577
if Settings.ENV != EnvironmentType.LIVE:
7678
App.update(app_name=app_name)
7779

80+
# Run Android with bundle
81+
Adb.open_home(id=self.emu.id)
82+
Tns.run_android(app_name=app_name, device=self.emu.id, bundle=True)
83+
self.emu.wait_for_main_color(color=Colors.WHITE)
84+
if template_info.texts is not None:
85+
for text in template_info.texts:
86+
self.emu.wait_for_text(text=text, timeout=30)
87+
88+
# Run iOS with bundle
89+
if Settings.HOST_OS is OSType.OSX:
90+
Tns.run_ios(app_name=app_name, device=self.sim.id, bundle=True)
91+
self.sim.wait_for_main_color(color=Colors.WHITE)
92+
if template_info.texts is not None:
93+
for text in template_info.texts:
94+
self.sim.wait_for_text(text=text, timeout=30)
95+
7896
# Build in release
7997
Tns.build_android(app_name=app_name, release=True, bundle=True, aot=True, uglify=True, snapshot=True)
8098
if Settings.HOST_OS is OSType.OSX:
8199
Tns.build_ios(app_name=app_name, release=True, for_device=True, bundle=True, aot=True, uglify=True)
82100

83-
# Run with bundle
84-
Tns.run_android(app_name=app_name, device=self.emu.id, bundle=True, justlaunch=True, wait=True)
85-
for text in template_info.texts:
86-
self.emu.wait_for_text(text=text, timeout=30)
87-
if Settings.HOST_OS is OSType.OSX:
88-
Tns.run_ios(app_name=app_name, device=self.sim.id, bundle=True, justlaunch=True, wait=True)
89-
for text in template_info.texts:
90-
self.sim.wait_for_text(text=text, timeout=30)
91-
92101
# Cleanup
93102
Folder.clean(local_path)

0 commit comments

Comments
 (0)