diff --git a/src/interfaces/BO/modules/autoupgrade/index.ts b/src/interfaces/BO/modules/autoupgrade/index.ts index b9a81264..adf4ff17 100644 --- a/src/interfaces/BO/modules/autoupgrade/index.ts +++ b/src/interfaces/BO/modules/autoupgrade/index.ts @@ -4,6 +4,20 @@ import type {Page} from '@playwright/test'; export interface ModuleAutoupgradeMainPageInterface extends ModuleConfigurationPageInterface { readonly pageTitle: string; - goToMaintenancePage(page:Page): Promise; - isRequirementsAlertDangerVisible(page:Page): Promise; + readonly checkRequirementSuccessMessage: string; + + readonly updateSuccessMessage: string; + + cancelBackup(page:Page):Promise; + checkRequirements(page: Page): Promise; + checkUpdateSuccess(page:Page):Promise; + chooseNewVersion(page:Page):Promise; + clickOnLaunchBackup(page:Page):Promise; + clickOnUpdateWithoutBackup(page:Page):Promise; + getCurrentPSAndPHPVersion(page: Page): Promise; + getNewPSVersion(page: Page): Promise; + getStepTitle(page:Page):Promise; + goToMaintenancePage(page: Page): Promise; + goToNextStep(page:Page):Promise; + updateYourStore(page: Page): Promise; } diff --git a/src/versions/develop/pages/BO/modules/autoupgrade/index.ts b/src/versions/develop/pages/BO/modules/autoupgrade/index.ts index 91cb3b38..889fa90e 100644 --- a/src/versions/develop/pages/BO/modules/autoupgrade/index.ts +++ b/src/versions/develop/pages/BO/modules/autoupgrade/index.ts @@ -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 @@ -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 { + 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 { + 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} Opened tab after the click */ async goToMaintenancePage(page: Page): Promise { - return this.openLinkWithTargetBlank(page, this.maintenanceModeLink); + return this.openLinkWithTargetBlank(page, this.goToMaintenancePageLink); + } + + /** + * Check requirements + * @param page {Page} Browser tab + * @return {Promise { + 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 { + return this.getTextContent(page, this.currentPSVersion); + } + + /** + * Get new PS version + * @param page {Page} Browser tab + * @return {Promise { + return this.getTextContent(page, this.newPsVersionCardTitle); + } + + /** + * Go to new step + * @param page {Page} Browser tab + * @return {Promise { + await page.locator(this.nextStepButton).click(); + } + + /** + * Get step title + * @param page {Page} Browser tab + * @return {Promise { + return this.getTextContent(page, this.stepTitle); + } + + /** + * Click on launch backup + * @param page {Page} Browser tab + * @return {Promise { + 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} + * @return {Promise { - return this.elementVisible(page, this.alertDangerPreUpgrade, 2000); + async cancelBackup(page: Page): Promise { + 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 { + 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 { + await this.waitForVisibleSelector(page, this.updateProgressBar, 500000); + + return this.getTextContent(page, this.updateAlertSuccessMessage); } }