4
4
import os
5
5
6
6
from core .enums .app_type import AppType
7
+ from core .log .log import Log
7
8
from core .settings import Settings
8
9
from core .utils .wait import Wait
9
10
from data .changes import Changes , Sync
13
14
from products .nativescript .tns_logs import TnsLogs
14
15
15
16
16
- def sync_blank_vue (app_name , platform , device , bundle = False , hmr = False , instrumented = False ):
17
+ def __run_vue (app_name , platform , bundle , hmr ):
17
18
# Execute `tns run` and wait until logs are OK
18
- result = Tns .run (app_name = app_name , platform = platform , emulator = True , wait = False , bundle = bundle , hmr = hmr )
19
+ return Tns .run (app_name = app_name , platform = platform , emulator = True , wait = False , bundle = bundle , hmr = hmr )
19
20
20
- strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .FULL , bundle = bundle ,
21
- hmr = hmr , app_type = AppType .VUE , instrumented = instrumented )
22
- TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings , timeout = 240 )
21
+
22
+ def __preview_vue (app_name , bundle , hmr ):
23
+ # Execute `tns run` and wait until logs are OK
24
+ return Tns .preview (app_name = app_name , bundle = bundle , hmr = hmr )
25
+
26
+
27
+ def __workflow (preview , app_name , platform , device , bundle = False , hmr = False ):
28
+ # Execute tns command
29
+ if preview :
30
+ result = __preview_vue (app_name = app_name , bundle = bundle , hmr = hmr )
31
+ else :
32
+ result = __run_vue (app_name = app_name , platform = platform , bundle = bundle , hmr = hmr )
33
+
34
+ if preview :
35
+ Log .info ('Skip logs checks.' )
36
+ else :
37
+ strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .FULL , bundle = bundle ,
38
+ hmr = hmr , app_type = AppType .VUE )
39
+ TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings , timeout = 240 )
23
40
24
41
# Verify it looks properly
25
42
device .wait_for_text (text = Changes .BlankVue .VUE_SCRIPT .old_text )
@@ -29,49 +46,78 @@ def sync_blank_vue(app_name, platform, device, bundle=False, hmr=False, instrume
29
46
30
47
# Edit script in .vue file
31
48
Sync .replace (app_name = app_name , change_set = Changes .BlankVue .VUE_SCRIPT )
32
- strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .INCREMENTAL , bundle = bundle ,
33
- hmr = hmr , app_type = AppType .VUE , file_name = 'Home.vue' , instrumented = instrumented )
34
- TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings )
49
+ if preview :
50
+ Log .info ('Skip logs checks.' )
51
+ else :
52
+ strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .INCREMENTAL ,
53
+ bundle = bundle , hmr = hmr , app_type = AppType .VUE , file_name = 'Home.vue' )
54
+ TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings )
35
55
device .wait_for_text (text = Changes .BlankVue .VUE_SCRIPT .new_text )
36
56
37
57
# Edit template in .vue file
38
58
Sync .replace (app_name = app_name , change_set = Changes .BlankVue .VUE_TEMPLATE )
39
- strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .INCREMENTAL , bundle = bundle ,
40
- hmr = hmr , app_type = AppType .VUE , file_name = 'Home.vue' , instrumented = instrumented )
41
- TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings )
59
+ if preview :
60
+ Log .info ('Skip logs checks.' )
61
+ else :
62
+ strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .INCREMENTAL ,
63
+ bundle = bundle , hmr = hmr , app_type = AppType .VUE , file_name = 'Home.vue' )
64
+ TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings )
42
65
device .wait_for_text (text = Changes .BlankVue .VUE_TEMPLATE .new_text )
43
66
44
67
# Edit styling in .vue file
45
68
Sync .replace (app_name = app_name , change_set = Changes .BlankVue .VUE_STYLE )
46
- strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .INCREMENTAL , bundle = bundle ,
47
- hmr = hmr , app_type = AppType .VUE , file_name = 'Home.vue' , instrumented = instrumented )
48
- TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings )
69
+ if preview :
70
+ Log .info ('Skip logs checks.' )
71
+ else :
72
+ strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .INCREMENTAL ,
73
+ bundle = bundle , hmr = hmr , app_type = AppType .VUE , file_name = 'Home.vue' )
74
+ TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings )
49
75
style_applied = Wait .until (lambda : device .get_pixels_by_color (Colors .RED ) > 100 )
50
76
assert style_applied , 'Failed to sync changes in style.'
51
77
52
78
# Revert script in .vue file
53
79
Sync .revert (app_name = app_name , change_set = Changes .BlankVue .VUE_SCRIPT )
54
- strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .INCREMENTAL , bundle = bundle ,
55
- hmr = hmr , app_type = AppType .VUE , file_name = 'Home.vue' , instrumented = instrumented )
56
- TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings )
80
+ if preview :
81
+ Log .info ('Skip logs checks.' )
82
+ else :
83
+ strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .INCREMENTAL ,
84
+ bundle = bundle , hmr = hmr , app_type = AppType .VUE , file_name = 'Home.vue' )
85
+ TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings )
57
86
device .wait_for_text (text = Changes .BlankVue .VUE_SCRIPT .old_text )
58
87
59
88
# Revert template in .vue file
60
89
Sync .revert (app_name = app_name , change_set = Changes .BlankVue .VUE_TEMPLATE )
61
- strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .INCREMENTAL , bundle = bundle ,
62
- hmr = hmr , app_type = AppType .VUE , file_name = 'Home.vue' , instrumented = instrumented )
63
- TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings )
90
+ if preview :
91
+ Log .info ('Skip logs checks.' )
92
+ else :
93
+ strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .INCREMENTAL ,
94
+ bundle = bundle , hmr = hmr , app_type = AppType .VUE , file_name = 'Home.vue' )
95
+ TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings )
64
96
device .wait_for_text (text = Changes .BlankVue .VUE_TEMPLATE .old_text )
65
97
66
98
# Revert styling in .vue file
67
99
Sync .revert (app_name = app_name , change_set = Changes .BlankVue .VUE_STYLE )
68
- strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .INCREMENTAL , bundle = bundle ,
69
- hmr = hmr , app_type = AppType .VUE , file_name = 'Home.vue' , instrumented = instrumented )
70
- TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings )
100
+ if preview :
101
+ Log .info ('Skip logs checks.' )
102
+ else :
103
+ strings = TnsLogs .run_messages (app_name = app_name , platform = platform , run_type = RunType .INCREMENTAL ,
104
+ bundle = bundle ,
105
+ hmr = hmr , app_type = AppType .VUE , file_name = 'Home.vue' )
106
+ TnsLogs .wait_for_log (log_file = result .log_file , string_list = strings )
71
107
72
- # Skip next steps because of https://github.com/nativescript-vue/nativescript-vue/issues/425
73
- # style_applied = Wait.until(lambda: device.get_pixels_by_color(Colors.RED) == 0)
74
- # assert style_applied, 'Failed to sync changes in style.'
108
+ if hmr :
109
+ Log .info ('Skip next steps because of https://github.com/nativescript-vue/nativescript-vue/issues/425' )
110
+ else :
111
+ style_applied = Wait .until (lambda : device .get_pixels_by_color (Colors .RED ) == 0 )
112
+ assert style_applied , 'Failed to sync changes in style.'
75
113
76
114
# Assert final and initial states are same
77
115
device .screen_match (expected_image = initial_state , tolerance = 1.0 , timeout = 30 )
116
+
117
+
118
+ def sync_blank_vue (app_name , platform , device , bundle = False , hmr = False ):
119
+ __workflow (preview = False , app_name = app_name , platform = platform , device = device , bundle = bundle , hmr = hmr )
120
+
121
+
122
+ def preview_blank_vue (app_name , platform , device , bundle = False , hmr = False ):
123
+ __workflow (preview = True , app_name = app_name , platform = platform , device = device , bundle = bundle , hmr = hmr )
0 commit comments