Skip to content

Commit 2b85891

Browse files
committed
fix: webpack tests
- Add more checks on each single changes - Remove legacy plaform add in some cases
1 parent d232718 commit 2b85891

File tree

3 files changed

+61
-27
lines changed

3 files changed

+61
-27
lines changed

tests/webpack/hello_world_js_tests.py

+21-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from core.device.device import Device
55
from core.device.emulator import Emulator
66
from core.device.simulator import Simulator
7+
from core.osutils.file import File
78
from core.osutils.os_type import OSType
89
from core.settings.settings import ANDROID_KEYSTORE_PATH, \
910
ANDROID_KEYSTORE_PASS, ANDROID_KEYSTORE_ALIAS, ANDROID_KEYSTORE_ALIAS_PASS, EMULATOR_ID, CURRENT_OS, \
@@ -82,11 +83,28 @@ def apply_changes(app_name, log, platform):
8283

8384
@staticmethod
8485
def revert_changes(app_name, log, platform):
86+
# Clean old logs
87+
if CURRENT_OS is not OSType.WINDOWS:
88+
File.write(file_path=log, text="")
89+
8590
# Revert changes
86-
ReplaceHelper.rollback(app_name, WebPackHelloWorldJS.js_change, sleep=10)
8791
ReplaceHelper.rollback(app_name, WebPackHelloWorldJS.xml_change, sleep=10)
92+
Tns.wait_for_log(log_file=log, string_list=['main-page.xml'], clean_log=False)
93+
if platform == Platform.ANDROID:
94+
text_changed = Device.wait_for_text(device_id=EMULATOR_ID, text='TAP')
95+
assert text_changed, 'Changes in XML file not applied (UI is not refreshed).'
96+
97+
ReplaceHelper.rollback(app_name, WebPackHelloWorldJS.js_change, sleep=10)
98+
Tns.wait_for_log(log_file=log, string_list=['main-view-model.js'], clean_log=False)
99+
if platform == Platform.ANDROID:
100+
text_changed = Device.wait_for_text(device_id=EMULATOR_ID, text='42 taps left', timeout=20)
101+
assert text_changed, 'Changes in TS file not applied (UI is not refreshed).'
102+
88103
ReplaceHelper.rollback(app_name, WebPackHelloWorldJS.css_change, sleep=10)
104+
Tns.wait_for_log(log_file=log, string_list=['app.css'], clean_log=False)
89105

106+
ReplaceHelper.rollback(app_name, WebPackHelloWorldJS.css_change, sleep=10)
107+
Tns.wait_for_log(log_file=log, string_list=['app.css'], clean_log=False)
90108
# Verify application looks correct
91109
Tns.wait_for_log(log_file=log, string_list=Helpers.wp_sync, not_existing_string_list=Helpers.wp_errors,
92110
timeout=60)
@@ -131,10 +149,6 @@ def test_100_android_build_release_with_bundle_and_uglify(self):
131149

132150
@unittest.skipIf(CURRENT_OS != OSType.OSX, "Run only on macOS.")
133151
def test_100_ios_build_release_with_bundle_and_uglify(self):
134-
# Hack due to https://github.com/NativeScript/nativescript-cli/issues/3415
135-
Tns.platform_remove(platform=Platform.IOS, attributes={"--path": self.app_name})
136-
Tns.platform_add_ios(attributes={'--path': self.app_name, '--frameworkPath': IOS_PACKAGE})
137-
138152
Tns.build_ios(attributes={"--path": self.app_name, "--release": "", "--for-device": "", "--bundle": "",
139153
"--env.uglify": ""})
140154

@@ -179,7 +193,7 @@ def test_200_run_android_with_bundle_sync_changes(self):
179193
"--bundle": "",
180194
'--device': EMULATOR_ID}, wait=False, assert_success=False)
181195
Tns.wait_for_log(log_file=log, string_list=Helpers.wp_run, not_existing_string_list=Helpers.wp_errors,
182-
timeout=180)
196+
timeout=240)
183197
Helpers.android_screen_match(image=self.image_original, timeout=120)
184198
Helpers.wait_webpack_watcher()
185199

@@ -191,7 +205,7 @@ def test_200_run_ios_with_bundle_sync_changes(self):
191205
log = Tns.run_ios(attributes={'--path': self.app_name, '--emulator': '', '--bundle': ''}, wait=False,
192206
assert_success=False)
193207
Tns.wait_for_log(log_file=log, string_list=Helpers.wp_sync, not_existing_string_list=Helpers.wp_errors,
194-
timeout=240)
208+
timeout=240, check_interval=10)
195209
Helpers.ios_screen_match(sim_id=self.SIMULATOR_ID, image=self.image_original, timeout=120)
196210
Helpers.wait_webpack_watcher()
197211

tests/webpack/hello_world_ng_tests.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from core.device.emulator import Emulator
66
from core.device.simulator import Simulator
77
from core.npm.npm import Npm
8+
from core.osutils.file import File
89
from core.osutils.os_type import OSType
910
from core.settings.settings import ANDROID_KEYSTORE_PATH, \
1011
ANDROID_KEYSTORE_PASS, ANDROID_KEYSTORE_ALIAS, ANDROID_KEYSTORE_ALIAS_PASS, EMULATOR_ID, CURRENT_OS, \
@@ -59,17 +60,16 @@ def apply_changes(app_name, log, platform):
5960

6061
# Change JS, XML and CSS
6162
ReplaceHelper.replace(app_name, WebPackHelloWorldNG.ts_change, sleep=10)
63+
Tns.wait_for_log(log_file=log, string_list=['item.service.'], clean_log=False)
6264
if platform == Platform.ANDROID:
6365
text_changed = Device.wait_for_text(device_id=EMULATOR_ID, text='Stegen Ter', timeout=20)
6466
assert text_changed, 'Changes in JS file not applied (UI is not refreshed).'
6567

6668
ReplaceHelper.replace(app_name, WebPackHelloWorldNG.html_change, sleep=10)
67-
if platform == Platform.ANDROID:
68-
Tns.wait_for_log(log_file=log, string_list=['items.component.html'], clean_log=False)
69+
Tns.wait_for_log(log_file=log, string_list=['items.component.html'], clean_log=False)
6970

7071
ReplaceHelper.replace(app_name, WebPackHelloWorldNG.css_change, sleep=10)
71-
if platform == Platform.ANDROID:
72-
Tns.wait_for_log(log_file=log, string_list=['app.css'], clean_log=False)
72+
Tns.wait_for_log(log_file=log, string_list=['app.css'], clean_log=False)
7373

7474
Tns.wait_for_log(log_file=log, string_list=Helpers.wp_sync, not_existing_string_list=Helpers.wp_errors,
7575
timeout=120)
@@ -83,10 +83,22 @@ def apply_changes(app_name, log, platform):
8383

8484
@staticmethod
8585
def revert_changes(app_name, log, platform):
86+
# Clean old logs
87+
if CURRENT_OS is not OSType.WINDOWS:
88+
File.write(file_path=log, text="")
89+
8690
# Revert changes
91+
ReplaceHelper.rollback(app_name, WebPackHelloWorldNG.html_change, sleep=20)
92+
Tns.wait_for_log(log_file=log, string_list=['items.component.html'], clean_log=False)
93+
8794
ReplaceHelper.rollback(app_name, WebPackHelloWorldNG.ts_change, sleep=10)
88-
ReplaceHelper.rollback(app_name, WebPackHelloWorldNG.html_change, sleep=10)
95+
Tns.wait_for_log(log_file=log, string_list=['item.service.'], clean_log=False)
96+
if platform == Platform.ANDROID:
97+
text_changed = Device.wait_for_text(device_id=EMULATOR_ID, text='Ter Stegen', timeout=20)
98+
assert text_changed, 'Changes in TS file not applied (UI is not refreshed).'
99+
89100
ReplaceHelper.rollback(app_name, WebPackHelloWorldNG.css_change, sleep=10)
101+
Tns.wait_for_log(log_file=log, string_list=['app.css'], clean_log=False)
90102

91103
# Verify application looks correct
92104
Tns.wait_for_log(log_file=log, string_list=Helpers.wp_sync, not_existing_string_list=Helpers.wp_errors,
@@ -132,10 +144,6 @@ def test_100_android_build_release_with_bundle_and_uglify(self):
132144

133145
@unittest.skipIf(CURRENT_OS != OSType.OSX, "Run only on macOS.")
134146
def test_100_ios_build_release_with_bundle_and_uglify(self):
135-
# Hack due to https://github.com/NativeScript/nativescript-cli/issues/3415
136-
Tns.platform_remove(platform=Platform.IOS, attributes={"--path": self.app_name})
137-
Tns.platform_add_ios(attributes={'--path': self.app_name, '--frameworkPath': IOS_PACKAGE})
138-
139147
Tns.build_ios(attributes={"--path": self.app_name, "--release": "", "--for-device": "", "--bundle": "",
140148
"--env.uglify": ""})
141149

@@ -180,7 +188,7 @@ def test_200_run_android_with_bundle_sync_changes(self):
180188
"--bundle": "",
181189
'--device': EMULATOR_ID}, wait=False, assert_success=False)
182190
Tns.wait_for_log(log_file=log, string_list=Helpers.wp_run, not_existing_string_list=Helpers.wp_errors,
183-
timeout=180)
191+
timeout=240, check_interval=10)
184192
Helpers.android_screen_match(image=self.image_original, timeout=120)
185193
Helpers.wait_webpack_watcher()
186194

tests/webpack/hello_world_ts_tests.py

+22-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from core.device.emulator import Emulator
66
from core.device.simulator import Simulator
77
from core.npm.npm import Npm
8+
from core.osutils.file import File
89
from core.osutils.os_type import OSType
910
from core.settings.settings import ANDROID_KEYSTORE_PATH, \
1011
ANDROID_KEYSTORE_PASS, ANDROID_KEYSTORE_ALIAS, ANDROID_KEYSTORE_ALIAS_PASS, EMULATOR_ID, CURRENT_OS, \
@@ -61,16 +62,15 @@ def apply_changes(app_name, log, platform):
6162
ReplaceHelper.replace(app_name, WebPackHelloWorldTS.ts_change, sleep=10)
6263
if platform == Platform.ANDROID:
6364
text_changed = Device.wait_for_text(device_id=EMULATOR_ID, text='42 clicks left', timeout=20)
64-
assert text_changed, 'Changes in JS file not applied (UI is not refreshed).'
65+
assert text_changed, 'Changes in TS file not applied (UI is not refreshed).'
6566

6667
ReplaceHelper.replace(app_name, WebPackHelloWorldTS.xml_change, sleep=10)
6768
if platform == Platform.ANDROID:
6869
text_changed = Device.wait_for_text(device_id=EMULATOR_ID, text='TEST')
6970
assert text_changed, 'Changes in XML file not applied (UI is not refreshed).'
7071

7172
ReplaceHelper.replace(app_name, WebPackHelloWorldTS.css_change, sleep=10)
72-
if platform == Platform.ANDROID:
73-
Tns.wait_for_log(log_file=log, string_list=['app.css'], clean_log=False)
73+
Tns.wait_for_log(log_file=log, string_list=['app.css'], clean_log=False)
7474

7575
Tns.wait_for_log(log_file=log, string_list=Helpers.wp_sync, not_existing_string_list=Helpers.wp_errors,
7676
timeout=120)
@@ -84,10 +84,26 @@ def apply_changes(app_name, log, platform):
8484

8585
@staticmethod
8686
def revert_changes(app_name, log, platform):
87+
88+
# Clean old logs
89+
if CURRENT_OS is not OSType.WINDOWS:
90+
File.write(file_path=log, text="")
91+
8792
# Revert changes
88-
ReplaceHelper.rollback(app_name, WebPackHelloWorldTS.ts_change, sleep=10)
8993
ReplaceHelper.rollback(app_name, WebPackHelloWorldTS.xml_change, sleep=10)
94+
Tns.wait_for_log(log_file=log, string_list=['main-page.xml'], clean_log=False)
95+
if platform == Platform.ANDROID:
96+
text_changed = Device.wait_for_text(device_id=EMULATOR_ID, text='TAP')
97+
assert text_changed, 'Changes in XML file not applied (UI is not refreshed).'
98+
99+
ReplaceHelper.rollback(app_name, WebPackHelloWorldTS.ts_change, sleep=10)
100+
Tns.wait_for_log(log_file=log, string_list=['main-view-model.ts'], clean_log=False)
101+
if platform == Platform.ANDROID:
102+
text_changed = Device.wait_for_text(device_id=EMULATOR_ID, text='42 taps left', timeout=20)
103+
assert text_changed, 'Changes in TS file not applied (UI is not refreshed).'
104+
90105
ReplaceHelper.rollback(app_name, WebPackHelloWorldTS.css_change, sleep=10)
106+
Tns.wait_for_log(log_file=log, string_list=['app.css'], clean_log=False)
91107

92108
# Verify application looks correct
93109
Tns.wait_for_log(log_file=log, string_list=Helpers.wp_sync, not_existing_string_list=Helpers.wp_errors,
@@ -133,10 +149,6 @@ def test_100_android_build_release_with_bundle_and_uglify(self):
133149

134150
@unittest.skipIf(CURRENT_OS != OSType.OSX, "Run only on macOS.")
135151
def test_100_ios_build_release_with_bundle_and_uglify(self):
136-
# Hack due to https://github.com/NativeScript/nativescript-cli/issues/3415
137-
Tns.platform_remove(platform=Platform.IOS, attributes={"--path": self.app_name})
138-
Tns.platform_add_ios(attributes={'--path': self.app_name, '--frameworkPath': IOS_PACKAGE})
139-
140152
Tns.build_ios(attributes={"--path": self.app_name, "--release": "", "--for-device": "", "--bundle": "",
141153
"--env.uglify": ""})
142154

@@ -181,7 +193,7 @@ def test_200_run_android_with_bundle_sync_changes(self):
181193
"--bundle": "",
182194
'--device': EMULATOR_ID}, wait=False, assert_success=False)
183195
Tns.wait_for_log(log_file=log, string_list=Helpers.wp_run, not_existing_string_list=Helpers.wp_errors,
184-
timeout=180)
196+
timeout=240, check_interval=10)
185197
Helpers.android_screen_match(image=self.image_original, timeout=120)
186198
Helpers.wait_webpack_watcher()
187199

@@ -206,7 +218,7 @@ def test_210_run_android_with_bundle_uglify_sync_changes(self):
206218
"--env.uglify": "",
207219
'--device': EMULATOR_ID}, wait=False, assert_success=False)
208220
Tns.wait_for_log(log_file=log, string_list=Helpers.wp_run, not_existing_string_list=Helpers.wp_errors,
209-
timeout=180)
221+
timeout=240)
210222
Helpers.android_screen_match(image=self.image_original, timeout=120)
211223
Helpers.wait_webpack_watcher()
212224

0 commit comments

Comments
 (0)