Skip to content

Commit

Permalink
Merge pull request #311 from nesrineabdmouleh/AddMethodsForNewUIOfAUt…
Browse files Browse the repository at this point in the history
…oupgradeModule

Add methods for new UI of Autoupgrade module
  • Loading branch information
Progi1984 authored Jan 8, 2025
2 parents 8ef05b6 + 017f44e commit 725db92
Show file tree
Hide file tree
Showing 2 changed files with 208 additions and 14 deletions.
18 changes: 16 additions & 2 deletions src/interfaces/BO/modules/autoupgrade/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ import type {Page} from '@playwright/test';
export interface ModuleAutoupgradeMainPageInterface extends ModuleConfigurationPageInterface {
readonly pageTitle: string;

goToMaintenancePage(page:Page): Promise<Page>;
isRequirementsAlertDangerVisible(page:Page): Promise<boolean>;
readonly checkRequirementSuccessMessage: string;

readonly updateSuccessMessage: string;

cancelBackup(page:Page):Promise<boolean>;
checkRequirements(page: Page): Promise<string>;
checkUpdateSuccess(page:Page):Promise<string>;
chooseNewVersion(page:Page):Promise<boolean>;
clickOnLaunchBackup(page:Page):Promise<boolean>;
clickOnUpdateWithoutBackup(page:Page):Promise<void>;
getCurrentPSAndPHPVersion(page: Page): Promise<string>;
getNewPSVersion(page: Page): Promise<string>;
getStepTitle(page:Page):Promise<string>;
goToMaintenancePage(page: Page): Promise<Page>;
goToNextStep(page:Page):Promise<void>;
updateYourStore(page: Page): Promise<boolean>;
}
204 changes: 192 additions & 12 deletions src/versions/develop/pages/BO/modules/autoupgrade/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,55 @@ import type {Page} from '@playwright/test';
class Autoupgrade extends ModuleConfiguration implements ModuleAutoupgradeMainPageInterface {
public readonly pageTitle: string;

private readonly currentConfigurationTable: string;
public readonly checkRequirementSuccessMessage: string;

private readonly maintenanceModeLink: string;
public readonly updateSuccessMessage: string;

private readonly alertDangerPreUpgrade: string;
private readonly updateYourStoreRadioButton: string;

private readonly getStartedButton: string;

private readonly stepContent: string;

private readonly newVersionRadioButton: string;

private readonly radioCardLoader: string;

private readonly checkRequirementBlock: string;

private readonly checkRequirementsFailedAlerts: string;

private readonly goToMaintenancePageLink: string;

private readonly checkRequirementsButton: string;

private readonly alertSuccessMessage: string;

private readonly currentPSVersion: string;

private readonly newPsVersionCardTitle: string;

private readonly nextStepButton: string;

private readonly stepTitle: string;

private readonly launchBackupButton: string;

private readonly dialogConfirmBuckup: string;

private readonly cancelBackupButton: string;

private readonly updateWithoutBackupButton: string;

private readonly dialogConfirmUpdate: string;

private readonly startUpdateRadioButton: string;

private readonly dialogConfirmUpdateButton: string;

private readonly updateProgressBar: string;

private readonly updateAlertSuccessMessage: string;

/**
* @constructs
Expand All @@ -23,31 +67,167 @@ class Autoupgrade extends ModuleConfiguration implements ModuleAutoupgradeMainPa
super();

this.pageTitle = `Update assistant > Update assistant • ${global.INSTALL.SHOP_NAME}`;
this.checkRequirementSuccessMessage = 'The requirements check is complete, you can update your store to this '
+ 'version of PrestaShop.';
this.updateSuccessMessage = 'Your store is up to date';

// Selectors
this.currentConfigurationTable = '#currentConfiguration table';
this.maintenanceModeLink = `${this.currentConfigurationTable} a[href*='shop/maintenance']`;
this.alertDangerPreUpgrade = `#${this.currentConfigurationTable} p.alert.alert-danger`;
// First page : Welcome to PrestaShop Update Assistant
this.updateYourStoreRadioButton = '#next_page div.radio-card__radio-wrapper input[value="update"]';
this.getStartedButton = '#ua_step_content div.page__buttons button';
// Step content
this.stepContent = '#stepper_content';
this.stepTitle = '.page__title';
// 1 : version choose step
this.newVersionRadioButton = '#online';
this.radioCardLoader = '.radio-card__loader-title';
this.checkRequirementBlock = '.check-requirements';
this.checkRequirementsFailedAlerts = '.check-requirements--failed';
this.goToMaintenancePageLink = '#radio_card_online div.radio-card__check-requirements a[href*="AdminMaintenance"]';
this.checkRequirementsButton = '#radio_card_online div.radio-card__check-requirements button'
+ '[data-action="check-requirements-again"]';
this.alertSuccessMessage = '.alert-success p.alert__message';
this.currentPSVersion = '#ua_step_content p.not-up-to-date__message';
this.newPsVersionCardTitle = '#radio_card_online p.radio-card__title';
this.nextStepButton = '#ua_step_content div.page__buttons button';
// 2 : Update options step
// 3 : Back up your store step
this.launchBackupButton = '#ua_step_content div.page__buttons button.btn-primary';
this.dialogConfirmBuckup = '#dialog-confirm-backup';
this.cancelBackupButton = '#dialog-confirm-backup div.dialog__footer button.btn-link';
this.updateWithoutBackupButton = '#update-backup-page-skip-btn';
this.dialogConfirmUpdate = '#dialog-confirm-update';
this.startUpdateRadioButton = '#dialog-start-update-own-backup';
this.dialogConfirmUpdateButton = '#dialog-confirm-update div.dialog__footer button.btn-primary';
// 4 : Update step
this.updateProgressBar = '#ua_step_content div.log-progress__bar div[title*=\'100\']';
this.updateAlertSuccessMessage = '#ua_step_content div.page__content div.alert-success p.alert__title';
}

// Methods
// Pre-upgrade checklist table
/**
* Update your store
* @param page {Page} Browser tab
* @return {Promise<boolean}
*/
async updateYourStore(page: Page): Promise<boolean> {
await page.locator(this.updateYourStoreRadioButton).setChecked(true);
await page.locator(this.getStartedButton).click();

return this.elementVisible(page, this.stepContent, 5000);
}

/**
* Choose new version
* @param page {Page} Browser tab
* @return {Promise<boolean}
*/
async chooseNewVersion(page: Page): Promise<boolean> {
await page.locator(this.newVersionRadioButton).setChecked(true);
await this.waitForVisibleSelector(page, this.radioCardLoader);
await this.waitForVisibleSelector(page, this.checkRequirementBlock, 100000);

return this.elementVisible(page, this.checkRequirementsFailedAlerts, 2000);
}

/**
* Go to maintenance page
* @param page {Page} Browser tab
* @return {Promise<Page>} Opened tab after the click
*/
async goToMaintenancePage(page: Page): Promise<Page> {
return this.openLinkWithTargetBlank(page, this.maintenanceModeLink);
return this.openLinkWithTargetBlank(page, this.goToMaintenancePageLink);
}

/**
* Check requirements
* @param page {Page} Browser tab
* @return {Promise<string}
*/
async checkRequirements(page: Page): Promise<string> {
await page.locator(this.checkRequirementsButton).click();
await this.waitForVisibleSelector(page, this.radioCardLoader);

return this.getTextContent(page, this.alertSuccessMessage);
}

/**
* Get current PS version
* @param page {Page} Browser tab
* @return {Promise<string}
*/
async getCurrentPSAndPHPVersion(page: Page): Promise<string> {
return this.getTextContent(page, this.currentPSVersion);
}

/**
* Get new PS version
* @param page {Page} Browser tab
* @return {Promise<string}
*/
async getNewPSVersion(page: Page): Promise<string> {
return this.getTextContent(page, this.newPsVersionCardTitle);
}

/**
* Go to new step
* @param page {Page} Browser tab
* @return {Promise<void}
*/
async goToNextStep(page: Page): Promise<void> {
await page.locator(this.nextStepButton).click();
}

/**
* Get step title
* @param page {Page} Browser tab
* @return {Promise<string}
*/
async getStepTitle(page: Page): Promise<string> {
return this.getTextContent(page, this.stepTitle);
}

/**
* Click on launch backup
* @param page {Page} Browser tab
* @return {Promise<boolean}
*/
async clickOnLaunchBackup(page: Page): Promise<boolean> {
await page.locator(this.launchBackupButton).click();
return this.elementVisible(page, this.dialogConfirmBuckup, 5000);
}

/**
* Is requirements alert danger visible
* Cancel backup
* @param page {Page} Browser tab
* @return {Promise<Page>}
* @return {Promise<boolean}
*/
async isRequirementsAlertDangerVisible(page: Page): Promise<boolean> {
return this.elementVisible(page, this.alertDangerPreUpgrade, 2000);
async cancelBackup(page: Page): Promise<boolean> {
await page.locator(this.cancelBackupButton).click();
return this.elementNotVisible(page, this.dialogConfirmBuckup, 5000);
}

/**
* Click on update without backup
* @param page {Page} Browser tab
* @return {Promise<void}
*/
async clickOnUpdateWithoutBackup(page: Page): Promise<void> {
await page.locator(this.updateWithoutBackupButton).click();
await this.waitForVisibleSelector(page, this.dialogConfirmUpdate);
await page.locator(this.startUpdateRadioButton).setChecked(true);
await page.locator(this.dialogConfirmUpdateButton).click();
}

/**
* Check update success
* @param page {Page} Browser tab
* @return {Promise<string}
*/
async checkUpdateSuccess(page: Page): Promise<string> {
await this.waitForVisibleSelector(page, this.updateProgressBar, 500000);

return this.getTextContent(page, this.updateAlertSuccessMessage);
}
}

Expand Down

0 comments on commit 725db92

Please sign in to comment.