Skip to content

Commit 8d27940

Browse files
committed
Update web pack tests
1 parent 3b88e2e commit 8d27940

File tree

5 files changed

+122
-569
lines changed

5 files changed

+122
-569
lines changed

tests/webpack/hello_world_js_tests.py

+13-192
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
import os
21
import unittest
32

43
from core.base_class.BaseClass import BaseClass
54
from core.device.emulator import Emulator
65
from core.device.simulator import Simulator
76
from core.npm.npm import Npm
8-
from core.osutils.file import File
97
from core.osutils.os_type import OSType
108
from core.settings.settings import ANDROID_KEYSTORE_PATH, \
119
ANDROID_KEYSTORE_PASS, ANDROID_KEYSTORE_ALIAS, ANDROID_KEYSTORE_ALIAS_PASS, EMULATOR_ID, CURRENT_OS, \
1210
IOS_RUNTIME_PATH, SIMULATOR_NAME, ANDROID_RUNTIME_PATH
1311
from core.tns.replace_helper import ReplaceHelper
1412
from core.tns.tns import Tns
15-
from core.tns.tns_platform_type import Platform
16-
from core.tns.tns_verifications import TnsAsserts
1713
from tests.webpack.helpers.helpers import Helpers
1814

1915

@@ -53,54 +49,7 @@ def setUp(self):
5349
def tearDownClass(cls):
5450
BaseClass.tearDownClass()
5551

56-
def test_000_build_without_bundle(self):
57-
Tns.build_android(attributes={"--path": self.app_name})
58-
apk_size = File.get_size(Helpers.get_apk_path(app_name=self.app_name, config="debug"))
59-
assert 13000000 < apk_size < 13500000, "Actual apk size is " + str(apk_size)
60-
Helpers.run_android_via_adb(app_name=self.app_name, config="debug", image=self.image_original)
61-
62-
if CURRENT_OS is OSType.OSX:
63-
Tns.build_ios(attributes={"--path": self.app_name})
64-
65-
Tns.build_ios(attributes={"--path": self.app_name, "--release": "", "--for-device": ""})
66-
app_path = Helpers.get_app_path(app_name=self.app_name).replace("emulator", "device")
67-
ipa_path = app_path.replace(".app", ".ipa")
68-
ipa_size = File.get_size(ipa_path)
69-
assert 13000000 < ipa_size < 13500000, "Actual app is " + str(ipa_size)
70-
71-
def test_001_android_build_with_bundle(self):
72-
Tns.build_android(attributes={"--path": self.app_name, "--bundle": ""})
73-
74-
base_path = os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH)
75-
bundle_js_size = File.get_size(os.path.join(base_path, "bundle.js"))
76-
starter_js_size = File.get_size(os.path.join(base_path, "starter.js"))
77-
vendor_js_size = File.get_size(os.path.join(base_path, "vendor.js"))
78-
main_page_xml_size = File.get_size(os.path.join(base_path, "main-page.xml"))
79-
apk_size = File.get_size(Helpers.get_apk_path(app_name=self.app_name, config="debug"))
80-
81-
assert 6500 < bundle_js_size < 7000, "Actual bundle_js_size is " + str(bundle_js_size)
82-
assert 30 < starter_js_size < 50, "Actual starter_js_size is " + str(starter_js_size)
83-
assert 1200000 < vendor_js_size < 1310000, "Actual vendor_js_size is " + str(vendor_js_size)
84-
assert 1600 < main_page_xml_size < 2000, "Actual main_page_xml_size is " + main_page_xml_size
85-
assert 12000000 < apk_size < 13000000, "Actual apk_size is " + str(apk_size)
86-
87-
Helpers.run_android_via_adb(app_name=self.app_name, config="debug", image=self.image_original)
88-
89-
@unittest.skipIf(CURRENT_OS != OSType.OSX, "Run only on macOS.")
90-
def test_001_ios_build_with_bundle(self):
91-
Tns.build_ios(attributes={"--path": self.app_name, "--bundle": ""})
92-
93-
app_path = Helpers.get_app_path(app_name=self.app_name)
94-
bundle_js_size = File.get_size(os.path.join(app_path, "app", "bundle.js"))
95-
starter_js_size = File.get_size(os.path.join(app_path, "app", "starter.js"))
96-
vendor_js_size = File.get_size(os.path.join(app_path, "app", "vendor.js"))
97-
main_page_xml_size = File.get_size(os.path.join(app_path, "app", "main-page.xml"))
98-
assert 6500 < bundle_js_size < 7000, "Actual bundle_js_size is " + str(bundle_js_size)
99-
assert 30 < starter_js_size < 50, "Actual starter_js_size is " + str(starter_js_size)
100-
assert 1400000 < vendor_js_size < 1450000, "Actual vendor_js_size is " + str(vendor_js_size)
101-
assert 1600 < main_page_xml_size < 2000, "Actual main_page_xml_size is " + main_page_xml_size
102-
103-
def test_002_android_build_release_with_bundle(self):
52+
def test_001_android_build_release_with_bundle(self):
10453
Tns.build_android(attributes={"--path": self.app_name,
10554
"--keyStorePath": ANDROID_KEYSTORE_PATH,
10655
"--keyStorePassword": ANDROID_KEYSTORE_PASS,
@@ -109,42 +58,15 @@ def test_002_android_build_release_with_bundle(self):
10958
"--release": "",
11059
"--bundle": ""})
11160

112-
base_path = os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH)
113-
bundle_js_size = File.get_size(os.path.join(base_path, "bundle.js"))
114-
starter_js_size = File.get_size(os.path.join(base_path, "starter.js"))
115-
vendor_js_size = File.get_size(os.path.join(base_path, "vendor.js"))
116-
main_page_xml_size = File.get_size(os.path.join(base_path, "main-page.xml"))
117-
apk_size = File.get_size(Helpers.get_apk_path(app_name=self.app_name, config="release"))
118-
119-
assert 6500 < bundle_js_size < 7000
120-
assert 30 < starter_js_size < 50
121-
assert 1200000 < vendor_js_size < 1310000
122-
assert 1600 < main_page_xml_size < 2000
123-
assert 11000000 < apk_size < 11500000
124-
61+
Helpers.verify_size(app_name=self.app_name, config="js-android-bundle")
12562
Helpers.run_android_via_adb(app_name=self.app_name, config="release", image=self.image_original)
12663

12764
@unittest.skipIf(CURRENT_OS != OSType.OSX, "Run only on macOS.")
128-
def test_002_ios_build_release_with_bundle(self):
65+
def test_001_ios_build_release_with_bundle(self):
12966
Tns.build_ios(attributes={"--path": self.app_name, "--release": "", "--for-device": "", "--bundle": ""})
130-
app_path = Helpers.get_app_path(app_name=self.app_name).replace("emulator", "device")
131-
ipa_path = app_path.replace(".app", ".ipa")
132-
bundle_js_size = File.get_size(os.path.join(app_path, "app", "bundle.js"))
133-
starter_js_size = File.get_size(os.path.join(app_path, "app", "starter.js"))
134-
vendor_js_size = File.get_size(os.path.join(app_path, "app", "vendor.js"))
135-
main_page_xml_size = File.get_size(os.path.join(app_path, "app", "main-page.xml"))
136-
ipa_size = File.get_size(ipa_path)
137-
assert 6500 < bundle_js_size < 7000, "Actual bundle_js_size is " + str(bundle_js_size)
138-
assert 30 < starter_js_size < 50, "Actual starter_js_size is " + str(starter_js_size)
139-
assert 1400000 < vendor_js_size < 1450000, "Actual vendor_js_size is " + str(vendor_js_size)
140-
assert 1600 < main_page_xml_size < 2000, "Actual main_page_xml_size is " + main_page_xml_size
141-
assert 12500000 < ipa_size < 13000000, "Actual app is " + str(ipa_size)
142-
143-
def test_100_android_build_release_with_and_bundle_and_uglify(self):
144-
# Workaround for https://github.com/NativeScript/nativescript-dev-webpack/issues/370
145-
Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name})
146-
Tns.platform_add_android(attributes={'--path': self.app_name, '--frameworkPath': ANDROID_RUNTIME_PATH})
67+
Helpers.verify_size(app_name=self.app_name, config="js-ios-bundle")
14768

69+
def test_100_android_build_release_with_bundle_and_uglify(self):
14870
Tns.build_android(attributes={"--path": self.app_name,
14971
"--keyStorePath": ANDROID_KEYSTORE_PATH,
15072
"--keyStorePassword": ANDROID_KEYSTORE_PASS,
@@ -154,47 +76,17 @@ def test_100_android_build_release_with_and_bundle_and_uglify(self):
15476
"--bundle": "",
15577
"--env.uglify": ""})
15678

157-
base_path = os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH)
158-
bundle_js_size = File.get_size(os.path.join(base_path, "bundle.js"))
159-
starter_js_size = File.get_size(os.path.join(base_path, "starter.js"))
160-
vendor_js_size = File.get_size(os.path.join(base_path, "vendor.js"))
161-
main_page_xml_size = File.get_size(os.path.join(base_path, "main-page.xml"))
162-
apk_size = File.get_size(Helpers.get_apk_path(app_name=self.app_name, config="release"))
163-
164-
assert 3500 < bundle_js_size < 3750, "Actual bundle_js_size is " + str(bundle_js_size)
165-
assert 30 < starter_js_size < 50, "Actual starter_js_size is " + str(starter_js_size)
166-
assert 670000 < vendor_js_size < 680000, "Actual vendor_js_size is " + str(vendor_js_size)
167-
assert 1600 < main_page_xml_size < 2000, "Actual main_page_xml_size is " + main_page_xml_size
168-
assert 11000000 < apk_size < 11500000, "Actual app is " + str(apk_size)
169-
79+
Helpers.verify_size(app_name=self.app_name, config="js-android-bundle-uglify")
17080
Helpers.run_android_via_adb(app_name=self.app_name, config="release", image=self.image_original)
17181

17282
@unittest.skipIf(CURRENT_OS != OSType.OSX, "Run only on macOS.")
173-
def test_100_ios_build_release_with_and_bundle_and_uglify(self):
174-
# Workaround for https://github.com/NativeScript/nativescript-dev-webpack/issues/370
175-
Tns.platform_remove(platform=Platform.IOS, attributes={"--path": self.app_name})
176-
Tns.platform_add_ios(attributes={'--path': self.app_name, '--frameworkPath': IOS_RUNTIME_PATH})
177-
83+
def test_100_ios_build_release_with_bundle_and_uglify(self):
17884
Tns.build_ios(attributes={"--path": self.app_name, "--release": "", "--for-device": "", "--bundle": "",
17985
"--env.uglify": ""})
180-
app_path = Helpers.get_app_path(app_name=self.app_name).replace("emulator", "device")
181-
ipa_path = app_path.replace(".app", ".ipa")
182-
bundle_js_size = File.get_size(os.path.join(app_path, "app", "bundle.js"))
183-
starter_js_size = File.get_size(os.path.join(app_path, "app", "starter.js"))
184-
vendor_js_size = File.get_size(os.path.join(app_path, "app", "vendor.js"))
185-
main_page_xml_size = File.get_size(os.path.join(app_path, "app", "main-page.xml"))
186-
ipa_size = File.get_size(ipa_path)
187-
assert 3500 < bundle_js_size < 3750, "Actual bundle_js_size is " + str(bundle_js_size)
188-
assert 30 < starter_js_size < 50, "Actual starter_js_size is " + str(starter_js_size)
189-
assert 685000 < vendor_js_size < 695000, "Actual vendor_js_size is " + str(vendor_js_size)
190-
assert 1600 < main_page_xml_size < 2000, "Actual main_page_xml_size is " + main_page_xml_size
191-
assert 12500000 < ipa_size < 13000000, "Actual app is " + str(ipa_size)
192-
193-
def test_110_android_build_release_with_and_bundle_and_snapshot(self):
194-
# Workaround for https://github.com/NativeScript/nativescript-dev-webpack/issues/370
195-
Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name})
196-
Tns.platform_add_android(attributes={'--path': self.app_name, '--frameworkPath': ANDROID_RUNTIME_PATH})
19786

87+
Helpers.verify_size(app_name=self.app_name, config="js-ios-bundle-uglify")
88+
89+
def test_110_android_build_release_with_bundle_and_snapshot(self):
19890
Tns.build_android(attributes={"--path": self.app_name,
19991
"--keyStorePath": ANDROID_KEYSTORE_PATH,
20092
"--keyStorePassword": ANDROID_KEYSTORE_PASS,
@@ -204,47 +96,10 @@ def test_110_android_build_release_with_and_bundle_and_snapshot(self):
20496
"--bundle": "",
20597
"--env.snapshot": ""})
20698

207-
base_path = os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH)
208-
bundle_js_size = File.get_size(os.path.join(base_path, "bundle.js"))
209-
starter_js_size = File.get_size(os.path.join(base_path, "starter.js"))
210-
vendor_js_size = File.get_size(os.path.join(base_path, "vendor.js"))
211-
main_page_xml_size = File.get_size(os.path.join(base_path, "main-page.xml"))
212-
apk_size = File.get_size(Helpers.get_apk_path(app_name=self.app_name, config="release"))
213-
214-
assert 6500 < bundle_js_size < 7000, "Actual bundle_js_size is " + str(bundle_js_size)
215-
assert 30 < starter_js_size < 50, "Actual starter_js_size is " + str(starter_js_size)
216-
assert vendor_js_size == 0, "Actual vendor_js_size is " + str(vendor_js_size)
217-
assert 1600 < main_page_xml_size < 2000, "Actual main_page_xml_size is " + main_page_xml_size
218-
assert 13000000 < apk_size < 14000000, "Actual app is " + str(apk_size)
219-
99+
Helpers.verify_size(app_name=self.app_name, config="js-android-bundle-snapshot")
220100
Helpers.run_android_via_adb(app_name=self.app_name, config="release", image=self.image_original)
221101

222-
@unittest.skipIf(CURRENT_OS != OSType.OSX, "Run only on macOS.")
223-
def test_110_ios_build_release_with_and_bundle_and_snapshot(self):
224-
# Workaround for https://github.com/NativeScript/nativescript-dev-webpack/issues/370
225-
Tns.platform_remove(platform=Platform.IOS, attributes={"--path": self.app_name})
226-
Tns.platform_add_ios(attributes={'--path': self.app_name, '--frameworkPath': IOS_RUNTIME_PATH})
227-
228-
Tns.build_ios(attributes={"--path": self.app_name, "--release": "", "--for-device": "", "--bundle": "",
229-
"--env.snapshot": ""})
230-
app_path = Helpers.get_app_path(app_name=self.app_name).replace("emulator", "device")
231-
ipa_path = app_path.replace(".app", ".ipa")
232-
bundle_js_size = File.get_size(os.path.join(app_path, "app", "bundle.js"))
233-
starter_js_size = File.get_size(os.path.join(app_path, "app", "starter.js"))
234-
vendor_js_size = File.get_size(os.path.join(app_path, "app", "vendor.js"))
235-
main_page_xml_size = File.get_size(os.path.join(app_path, "app", "main-page.xml"))
236-
ipa_size = File.get_size(ipa_path)
237-
assert 6500 < bundle_js_size < 7000, "Actual bundle_js_size is " + str(bundle_js_size)
238-
assert 30 < starter_js_size < 50, "Actual starter_js_size is " + str(starter_js_size)
239-
assert 1400000 < vendor_js_size < 1450000, "Actual vendor_js_size is " + str(vendor_js_size)
240-
assert 1600 < main_page_xml_size < 2000
241-
assert 12500000 < ipa_size < 13000000, "Actual app is " + str(ipa_size)
242-
243-
def test_120_android_build_release_with_and_bundle_and_snapshot_and_uglify(self):
244-
# Workaround for https://github.com/NativeScript/nativescript-dev-webpack/issues/370
245-
Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": self.app_name})
246-
Tns.platform_add_android(attributes={'--path': self.app_name, '--frameworkPath': ANDROID_RUNTIME_PATH})
247-
102+
def test_120_android_build_release_with_bundle_and_snapshot_and_uglify(self):
248103
Tns.build_android(attributes={"--path": self.app_name,
249104
"--keyStorePath": ANDROID_KEYSTORE_PATH,
250105
"--keyStorePassword": ANDROID_KEYSTORE_PASS,
@@ -255,43 +110,9 @@ def test_120_android_build_release_with_and_bundle_and_snapshot_and_uglify(self)
255110
"--env.uglify": "",
256111
"--env.snapshot": ""})
257112

258-
base_path = os.path.join(self.app_name, TnsAsserts.PLATFORM_ANDROID_APP_PATH)
259-
bundle_js_size = File.get_size(os.path.join(base_path, "bundle.js"))
260-
starter_js_size = File.get_size(os.path.join(base_path, "starter.js"))
261-
vendor_js_size = File.get_size(os.path.join(base_path, "vendor.js"))
262-
main_page_xml_size = File.get_size(os.path.join(base_path, "main-page.xml"))
263-
apk_size = File.get_size(Helpers.get_apk_path(app_name=self.app_name, config="release"))
264-
265-
assert 3500 < bundle_js_size < 3750
266-
assert 30 < starter_js_size < 50
267-
assert vendor_js_size == 0
268-
assert 1600 < main_page_xml_size < 2000
269-
270-
assert 12500000 < apk_size < 13500000, "Actual app is " + str(apk_size)
271-
113+
Helpers.verify_size(app_name=self.app_name, config="js-android-bundle-uglify-snapshot")
272114
Helpers.run_android_via_adb(app_name=self.app_name, config="release", image=self.image_original)
273115

274-
@unittest.skipIf(CURRENT_OS != OSType.OSX, "Run only on macOS.")
275-
def test_120_ios_build_release_with_and_bundle_and_snapshot_and_uglify(self):
276-
# Workaround for https://github.com/NativeScript/nativescript-dev-webpack/issues/370
277-
Tns.platform_remove(platform=Platform.IOS, attributes={"--path": self.app_name})
278-
Tns.platform_add_ios(attributes={'--path': self.app_name, '--frameworkPath': IOS_RUNTIME_PATH})
279-
280-
Tns.build_ios(attributes={"--path": self.app_name, "--release": "", "--for-device": "", "--bundle": "",
281-
"--env.snapshot": "", "--env.uglify": ""})
282-
app_path = Helpers.get_app_path(app_name=self.app_name).replace("emulator", "device")
283-
ipa_path = app_path.replace(".app", ".ipa")
284-
bundle_js_size = File.get_size(os.path.join(app_path, "app", "bundle.js"))
285-
starter_js_size = File.get_size(os.path.join(app_path, "app", "starter.js"))
286-
vendor_js_size = File.get_size(os.path.join(app_path, "app", "vendor.js"))
287-
main_page_xml_size = File.get_size(os.path.join(app_path, "app", "main-page.xml"))
288-
ipa_size = File.get_size(ipa_path)
289-
assert 3500 < bundle_js_size < 3750
290-
assert 30 < starter_js_size < 50
291-
assert 680000 < vendor_js_size < 700000, "Actual vendor_js_size is " + str(vendor_js_size)
292-
assert 1600 < main_page_xml_size < 2000
293-
assert 12500000 < ipa_size < 13000000, "Actual app is " + str(ipa_size)
294-
295116
def test_200_run_android_with_bundle_sync_changes(self):
296117
log = Tns.run_android(attributes={'--path': self.app_name,
297118
"--bundle": "",

0 commit comments

Comments
 (0)