diff --git a/src/support/steps/delete-plugin.ts b/src/support/steps/delete-plugin.ts index 9ca3718..d9a7229 100644 --- a/src/support/steps/delete-plugin.ts +++ b/src/support/steps/delete-plugin.ts @@ -30,20 +30,13 @@ When('I delete plugin', async function (this: ICustomWorld) { } // Delete WPR. - await this.page.locator( '#delete-wp-rocket' ).click(); - + await this.utils.removeWprViaUi(); }); /** * Executes the step to assert successful deletion of the WP Rocket plugin. */ Then('plugin should delete successfully', async function (this: ICustomWorld) { - - if (await this.page.getByRole('button', { name: 'Yes, delete these files and data' }).isVisible()) { - await this.page.getByRole('button', { name: 'Yes, delete these files and data' }).click(); - await expect(this.page.locator('#activate-wp-rocket')).toBeHidden(); - return; - } // Assert that WPR is deleted successfully await this.page.waitForSelector('#wp-rocket-deleted'); await expect(this.page.locator('#wp-rocket-deleted')).toBeVisible(); diff --git a/utils/page-utils.ts b/utils/page-utils.ts index 8efd13f..1c97d3f 100644 --- a/utils/page-utils.ts +++ b/utils/page-utils.ts @@ -582,6 +582,10 @@ export class PageUtils { // Remove WP Rocket from UI if on local run is explicitly parsed. if ( process.env.npm_config_env !== undefined && process.env.npm_config_env === 'local' ) { + // Start the process to remove wp-rocket. + await this.visitPage('wp-admin'); + await this.auth(); + await this.removeWprViaUi(); } } @@ -592,10 +596,6 @@ export class PageUtils { * @return {Promise} Promise that resolves after the uninstallation process is complete. */ public removeWprViaUi = async (): Promise => { - // Start the process to remove wp-rocket. - await this.visitPage('wp-admin'); - await this.auth(); - // Confirm Dialog Box. this.page.on('dialog', async(dialog) => { expect(dialog.type()).toContain('confirm');