Skip to content

Commit 725db92

Browse files
authored
Merge pull request #311 from nesrineabdmouleh/AddMethodsForNewUIOfAUtoupgradeModule
Add methods for new UI of Autoupgrade module
2 parents 8ef05b6 + 017f44e commit 725db92

File tree

2 files changed

+208
-14
lines changed
  • src
    • interfaces/BO/modules/autoupgrade
    • versions/develop/pages/BO/modules/autoupgrade

2 files changed

+208
-14
lines changed

src/interfaces/BO/modules/autoupgrade/index.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ import type {Page} from '@playwright/test';
44
export interface ModuleAutoupgradeMainPageInterface extends ModuleConfigurationPageInterface {
55
readonly pageTitle: string;
66

7-
goToMaintenancePage(page:Page): Promise<Page>;
8-
isRequirementsAlertDangerVisible(page:Page): Promise<boolean>;
7+
readonly checkRequirementSuccessMessage: string;
8+
9+
readonly updateSuccessMessage: string;
10+
11+
cancelBackup(page:Page):Promise<boolean>;
12+
checkRequirements(page: Page): Promise<string>;
13+
checkUpdateSuccess(page:Page):Promise<string>;
14+
chooseNewVersion(page:Page):Promise<boolean>;
15+
clickOnLaunchBackup(page:Page):Promise<boolean>;
16+
clickOnUpdateWithoutBackup(page:Page):Promise<void>;
17+
getCurrentPSAndPHPVersion(page: Page): Promise<string>;
18+
getNewPSVersion(page: Page): Promise<string>;
19+
getStepTitle(page:Page):Promise<string>;
20+
goToMaintenancePage(page: Page): Promise<Page>;
21+
goToNextStep(page:Page):Promise<void>;
22+
updateYourStore(page: Page): Promise<boolean>;
923
}

src/versions/develop/pages/BO/modules/autoupgrade/index.ts

Lines changed: 192 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,55 @@ import type {Page} from '@playwright/test';
1010
class Autoupgrade extends ModuleConfiguration implements ModuleAutoupgradeMainPageInterface {
1111
public readonly pageTitle: string;
1212

13-
private readonly currentConfigurationTable: string;
13+
public readonly checkRequirementSuccessMessage: string;
1414

15-
private readonly maintenanceModeLink: string;
15+
public readonly updateSuccessMessage: string;
1616

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;
1862

1963
/**
2064
* @constructs
@@ -23,31 +67,167 @@ class Autoupgrade extends ModuleConfiguration implements ModuleAutoupgradeMainPa
2367
super();
2468

2569
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';
2673

2774
// 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';
31105
}
32106

33107
// 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+
35133
/**
36134
* Go to maintenance page
37135
* @param page {Page} Browser tab
38136
* @return {Promise<Page>} Opened tab after the click
39137
*/
40138
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);
42198
}
43199

44200
/**
45-
* Is requirements alert danger visible
201+
* Cancel backup
46202
* @param page {Page} Browser tab
47-
* @return {Promise<Page>}
203+
* @return {Promise<boolean}
48204
*/
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);
51231
}
52232
}
53233

0 commit comments

Comments
 (0)