@@ -10,11 +10,55 @@ import type {Page} from '@playwright/test';
10
10
class Autoupgrade extends ModuleConfiguration implements ModuleAutoupgradeMainPageInterface {
11
11
public readonly pageTitle : string ;
12
12
13
- private readonly currentConfigurationTable : string ;
13
+ public readonly checkRequirementSuccessMessage : string ;
14
14
15
- private readonly maintenanceModeLink : string ;
15
+ public readonly updateSuccessMessage : string ;
16
16
17
- private readonly alertDangerPreUpgrade : string ;
17
+ private readonly updateYourStoreRadioButton : string ;
18
+
19
+ private readonly getStartedButton : string ;
20
+
21
+ private readonly stepContent : string ;
22
+
23
+ private readonly newVersionRadioButton : string ;
24
+
25
+ private readonly radioCardLoader : string ;
26
+
27
+ private readonly checkRequirementBlock : string ;
28
+
29
+ private readonly checkRequirementsFailedAlerts : string ;
30
+
31
+ private readonly goToMaintenancePageLink : string ;
32
+
33
+ private readonly checkRequirementsButton : string ;
34
+
35
+ private readonly alertSuccessMessage : string ;
36
+
37
+ private readonly currentPSVersion : string ;
38
+
39
+ private readonly newPsVersionCardTitle : string ;
40
+
41
+ private readonly nextStepButton : string ;
42
+
43
+ private readonly stepTitle : string ;
44
+
45
+ private readonly launchBackupButton : string ;
46
+
47
+ private readonly dialogConfirmBuckup : string ;
48
+
49
+ private readonly cancelBackupButton : string ;
50
+
51
+ private readonly updateWithoutBackupButton : string ;
52
+
53
+ private readonly dialogConfirmUpdate : string ;
54
+
55
+ private readonly startUpdateRadioButton : string ;
56
+
57
+ private readonly dialogConfirmUpdateButton : string ;
58
+
59
+ private readonly updateProgressBar : string ;
60
+
61
+ private readonly updateAlertSuccessMessage : string ;
18
62
19
63
/**
20
64
* @constructs
@@ -23,31 +67,167 @@ class Autoupgrade extends ModuleConfiguration implements ModuleAutoupgradeMainPa
23
67
super ( ) ;
24
68
25
69
this . pageTitle = `Update assistant > Update assistant • ${ global . INSTALL . SHOP_NAME } ` ;
70
+ this . checkRequirementSuccessMessage = 'The requirements check is complete, you can update your store to this '
71
+ + 'version of PrestaShop.' ;
72
+ this . updateSuccessMessage = 'Your store is up to date' ;
26
73
27
74
// Selectors
28
- this . currentConfigurationTable = '#currentConfiguration table' ;
29
- this . maintenanceModeLink = `${ this . currentConfigurationTable } a[href*='shop/maintenance']` ;
30
- this . alertDangerPreUpgrade = `#${ this . currentConfigurationTable } p.alert.alert-danger` ;
75
+ // First page : Welcome to PrestaShop Update Assistant
76
+ this . updateYourStoreRadioButton = '#next_page div.radio-card__radio-wrapper input[value="update"]' ;
77
+ this . getStartedButton = '#ua_step_content div.page__buttons button' ;
78
+ // Step content
79
+ this . stepContent = '#stepper_content' ;
80
+ this . stepTitle = '.page__title' ;
81
+ // 1 : version choose step
82
+ this . newVersionRadioButton = '#online' ;
83
+ this . radioCardLoader = '.radio-card__loader-title' ;
84
+ this . checkRequirementBlock = '.check-requirements' ;
85
+ this . checkRequirementsFailedAlerts = '.check-requirements--failed' ;
86
+ this . goToMaintenancePageLink = '#radio_card_online div.radio-card__check-requirements a[href*="AdminMaintenance"]' ;
87
+ this . checkRequirementsButton = '#radio_card_online div.radio-card__check-requirements button'
88
+ + '[data-action="check-requirements-again"]' ;
89
+ this . alertSuccessMessage = '.alert-success p.alert__message' ;
90
+ this . currentPSVersion = '#ua_step_content p.not-up-to-date__message' ;
91
+ this . newPsVersionCardTitle = '#radio_card_online p.radio-card__title' ;
92
+ this . nextStepButton = '#ua_step_content div.page__buttons button' ;
93
+ // 2 : Update options step
94
+ // 3 : Back up your store step
95
+ this . launchBackupButton = '#ua_step_content div.page__buttons button.btn-primary' ;
96
+ this . dialogConfirmBuckup = '#dialog-confirm-backup' ;
97
+ this . cancelBackupButton = '#dialog-confirm-backup div.dialog__footer button.btn-link' ;
98
+ this . updateWithoutBackupButton = '#update-backup-page-skip-btn' ;
99
+ this . dialogConfirmUpdate = '#dialog-confirm-update' ;
100
+ this . startUpdateRadioButton = '#dialog-start-update-own-backup' ;
101
+ this . dialogConfirmUpdateButton = '#dialog-confirm-update div.dialog__footer button.btn-primary' ;
102
+ // 4 : Update step
103
+ this . updateProgressBar = '#ua_step_content div.log-progress__bar div[title*=\'100\']' ;
104
+ this . updateAlertSuccessMessage = '#ua_step_content div.page__content div.alert-success p.alert__title' ;
31
105
}
32
106
33
107
// Methods
34
- // Pre-upgrade checklist table
108
+ /**
109
+ * Update your store
110
+ * @param page {Page} Browser tab
111
+ * @return {Promise<boolean }
112
+ */
113
+ async updateYourStore ( page : Page ) : Promise < boolean > {
114
+ await page . locator ( this . updateYourStoreRadioButton ) . setChecked ( true ) ;
115
+ await page . locator ( this . getStartedButton ) . click ( ) ;
116
+
117
+ return this . elementVisible ( page , this . stepContent , 5000 ) ;
118
+ }
119
+
120
+ /**
121
+ * Choose new version
122
+ * @param page {Page} Browser tab
123
+ * @return {Promise<boolean }
124
+ */
125
+ async chooseNewVersion ( page : Page ) : Promise < boolean > {
126
+ await page . locator ( this . newVersionRadioButton ) . setChecked ( true ) ;
127
+ await this . waitForVisibleSelector ( page , this . radioCardLoader ) ;
128
+ await this . waitForVisibleSelector ( page , this . checkRequirementBlock , 100000 ) ;
129
+
130
+ return this . elementVisible ( page , this . checkRequirementsFailedAlerts , 2000 ) ;
131
+ }
132
+
35
133
/**
36
134
* Go to maintenance page
37
135
* @param page {Page} Browser tab
38
136
* @return {Promise<Page> } Opened tab after the click
39
137
*/
40
138
async goToMaintenancePage ( page : Page ) : Promise < Page > {
41
- return this . openLinkWithTargetBlank ( page , this . maintenanceModeLink ) ;
139
+ return this . openLinkWithTargetBlank ( page , this . goToMaintenancePageLink ) ;
140
+ }
141
+
142
+ /**
143
+ * Check requirements
144
+ * @param page {Page} Browser tab
145
+ * @return {Promise<string }
146
+ */
147
+ async checkRequirements ( page : Page ) : Promise < string > {
148
+ await page . locator ( this . checkRequirementsButton ) . click ( ) ;
149
+ await this . waitForVisibleSelector ( page , this . radioCardLoader ) ;
150
+
151
+ return this . getTextContent ( page , this . alertSuccessMessage ) ;
152
+ }
153
+
154
+ /**
155
+ * Get current PS version
156
+ * @param page {Page} Browser tab
157
+ * @return {Promise<string }
158
+ */
159
+ async getCurrentPSAndPHPVersion ( page : Page ) : Promise < string > {
160
+ return this . getTextContent ( page , this . currentPSVersion ) ;
161
+ }
162
+
163
+ /**
164
+ * Get new PS version
165
+ * @param page {Page} Browser tab
166
+ * @return {Promise<string }
167
+ */
168
+ async getNewPSVersion ( page : Page ) : Promise < string > {
169
+ return this . getTextContent ( page , this . newPsVersionCardTitle ) ;
170
+ }
171
+
172
+ /**
173
+ * Go to new step
174
+ * @param page {Page} Browser tab
175
+ * @return {Promise<void }
176
+ */
177
+ async goToNextStep ( page : Page ) : Promise < void > {
178
+ await page . locator ( this . nextStepButton ) . click ( ) ;
179
+ }
180
+
181
+ /**
182
+ * Get step title
183
+ * @param page {Page} Browser tab
184
+ * @return {Promise<string }
185
+ */
186
+ async getStepTitle ( page : Page ) : Promise < string > {
187
+ return this . getTextContent ( page , this . stepTitle ) ;
188
+ }
189
+
190
+ /**
191
+ * Click on launch backup
192
+ * @param page {Page} Browser tab
193
+ * @return {Promise<boolean }
194
+ */
195
+ async clickOnLaunchBackup ( page : Page ) : Promise < boolean > {
196
+ await page . locator ( this . launchBackupButton ) . click ( ) ;
197
+ return this . elementVisible ( page , this . dialogConfirmBuckup , 5000 ) ;
42
198
}
43
199
44
200
/**
45
- * Is requirements alert danger visible
201
+ * Cancel backup
46
202
* @param page {Page} Browser tab
47
- * @return {Promise<Page> }
203
+ * @return {Promise<boolean }
48
204
*/
49
- async isRequirementsAlertDangerVisible ( page : Page ) : Promise < boolean > {
50
- return this . elementVisible ( page , this . alertDangerPreUpgrade , 2000 ) ;
205
+ async cancelBackup ( page : Page ) : Promise < boolean > {
206
+ await page . locator ( this . cancelBackupButton ) . click ( ) ;
207
+ return this . elementNotVisible ( page , this . dialogConfirmBuckup , 5000 ) ;
208
+ }
209
+
210
+ /**
211
+ * Click on update without backup
212
+ * @param page {Page} Browser tab
213
+ * @return {Promise<void }
214
+ */
215
+ async clickOnUpdateWithoutBackup ( page : Page ) : Promise < void > {
216
+ await page . locator ( this . updateWithoutBackupButton ) . click ( ) ;
217
+ await this . waitForVisibleSelector ( page , this . dialogConfirmUpdate ) ;
218
+ await page . locator ( this . startUpdateRadioButton ) . setChecked ( true ) ;
219
+ await page . locator ( this . dialogConfirmUpdateButton ) . click ( ) ;
220
+ }
221
+
222
+ /**
223
+ * Check update success
224
+ * @param page {Page} Browser tab
225
+ * @return {Promise<string }
226
+ */
227
+ async checkUpdateSuccess ( page : Page ) : Promise < string > {
228
+ await this . waitForVisibleSelector ( page , this . updateProgressBar , 500000 ) ;
229
+
230
+ return this . getTextContent ( page , this . updateAlertSuccessMessage ) ;
51
231
}
52
232
}
53
233
0 commit comments