diff --git a/src/features/delete-plugin.feature b/src/features/delete-plugin.feature index 3166343..4b1f3ac 100644 --- a/src/features/delete-plugin.feature +++ b/src/features/delete-plugin.feature @@ -1,4 +1,4 @@ -@smoke @local @setup +@smoke @local @setup Feature: C4466 - Should successfully delete the plugin Background: @@ -13,9 +13,8 @@ Feature: C4466 - Should successfully delete the plugin Scenario: WP Rocket is installed and activated Given plugin is installed 'new_release' And plugin is activated - When I go to 'wp-admin/options-general.php?page=wprocket#dashboard' And I enable all settings - And I delete plugin + When I delete plugin Then plugin should delete successfully - Then I must not see any error in debug.log + And I must not see any error in debug.log \ No newline at end of file diff --git a/src/features/settings-export-import.feature b/src/features/settings-export-import.feature index cb53156..b431e34 100644 --- a/src/features/settings-export-import.feature +++ b/src/features/settings-export-import.feature @@ -1,4 +1,4 @@ -@smoke @local @export @setup +@smoke @local @export @setup Feature: C2148 - Should not change the content of existing fields Background: @@ -8,7 +8,6 @@ Feature: C2148 - Should not change the content of existing fields Given plugin is installed 'previous_stable' And plugin is activated And I disabled all settings - And I save settings 'cache' 'cacheLoggedUser' And I export data '1' And I enable all settings When I import data @@ -18,15 +17,14 @@ Feature: C2148 - Should not change the content of existing fields Given plugin is installed 'previous_stable' And plugin is activated Given I disabled all settings - And I save settings 'media' 'lazyload' When I export data '2' Then data '2' is exported correctly Scenario: Data exported correctly on latest version Given plugin is installed 'previous_stable' And plugin is activated - And I updated plugin to 'new_release' And I disabled all settings + And I updated plugin to 'new_release' And I save settings 'media' 'lazyload' When I export data '3' Then data '3' is exported correctly diff --git a/src/support/steps/delete-plugin.ts b/src/support/steps/delete-plugin.ts index e7bd55f..9ca3718 100644 --- a/src/support/steps/delete-plugin.ts +++ b/src/support/steps/delete-plugin.ts @@ -29,22 +29,21 @@ When('I delete plugin', async function (this: ICustomWorld) { await this.page.locator('text=Confirm').click(); } - await this.page.waitForLoadState('load', { timeout: 30000 }); - // Delete WPR. await this.page.locator( '#delete-wp-rocket' ).click(); - 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; - } }); /** * 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/src/support/steps/enable-all-features.ts b/src/support/steps/enable-all-features.ts index 992e1be..f076b76 100644 --- a/src/support/steps/enable-all-features.ts +++ b/src/support/steps/enable-all-features.ts @@ -24,5 +24,5 @@ Then('page loads successfully', async function (this: ICustomWorld) { expect(response.status()).not.toEqual(404); }); await this.page.goto(WP_BASE_URL); - await this.page.waitForLoadState('load', { timeout: 30000 }); + //Todo: future enahancement, we can do VR compared to nowprocket but if no CNAME is set or correct CNAME is set }); \ No newline at end of file diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index 30cfe75..bde5458 100644 --- a/src/support/steps/general.ts +++ b/src/support/steps/general.ts @@ -33,7 +33,6 @@ Given('I am logged in', async function (this: ICustomWorld) { */ Given('plugin is installed {string}', async function (this: ICustomWorld, pluginVersion: string) { await this.utils.uploadNewPlugin(`./plugin/${pluginVersion}.zip`); - await this.page.waitForLoadState('load', { timeout: 30000 }); await expect(this.page).toHaveURL(/action=upload-plugin/); }); @@ -84,7 +83,6 @@ Given('I save settings {string} {string}', async function (this: ICustomWorld, s await this.sections.state(true).toggle(element); await this.utils.saveSettings(); - await this.page.waitForLoadState('load', { timeout: 30000 }); }); /** @@ -107,7 +105,6 @@ When('I log in', async function (this: ICustomWorld) { */ When('I go to {string}', async function (this: ICustomWorld, page) { await this.utils.visitPage(page); - await this.page.waitForLoadState('load', { timeout: 100000 }); }); /** @@ -132,12 +129,15 @@ When('I click on {string}', async function (this: ICustomWorld, selector) { await this.page.locator('#tools_tab').click(); await this.page.waitForSelector('#save_last_major_version'); await this.page.locator('#save_last_major_version').click(); - await this.page.waitForLoadState('load', { timeout: 30000 }); await this.utils.gotoWpr(); await this.page.locator('#wpr-nav-tools').click(); + await this.page.locator(selector).click(); + await this.page.waitForLoadState('load', { timeout: 70000 }); } - await this.page.locator(selector).click(); - await this.page.waitForLoadState('load', { timeout: 100000 }); + else{ + await this.page.locator(selector).click(); + } + }); /** @@ -280,8 +280,8 @@ Then('I should see {string}', async function (this: ICustomWorld, text) { */ Then('I must not see any error in debug.log', async function (this: ICustomWorld){ // Goto WP Rocket dashboard - await this.utils.gotoWpr(); - await this.page.waitForLoadState('load', { timeout: 30000 }); + await this.utils.gotoPlugin(); + // Assert that there is no related error in debug.log await expect(this.page.locator('#wpr_debug_log_notice')).toBeHidden(); }); diff --git a/src/support/steps/settings-export-import.ts b/src/support/steps/settings-export-import.ts index 009e79b..d5033b1 100644 --- a/src/support/steps/settings-export-import.ts +++ b/src/support/steps/settings-export-import.ts @@ -48,7 +48,7 @@ Given('I updated to latest version', async function (this: ICustomWorld) { */ When('I import data', async function (this: ICustomWorld) { await this.utils.importSettings('./plugin/exported_settings/wp-rocket-settings-test-2023-00-01-64e7ada0d3b70.json'); - await this.page.waitForLoadState('load', { timeout: 100000 }); + await expect(this.page.getByText('Settings imported and saved.')).toBeVisible(); }); /** @@ -56,6 +56,11 @@ When('I import data', async function (this: ICustomWorld) { */ When('I export data {string}', async function (this: ICustomWorld, fileNo: string) { + if(! await this.page.url().includes('page=wprocket#tools')) + { + await this.utils.visitPage('wp-admin/options-general.php?page=wprocket#tools'); + + } await this.page.locator('#wpr-nav-tools').click(); // Export settings. const downloadPromise = this.page.waitForEvent('download'); diff --git a/utils/page-utils.ts b/utils/page-utils.ts index 3ac1b56..822169a 100644 --- a/utils/page-utils.ts +++ b/utils/page-utils.ts @@ -260,15 +260,15 @@ export class PageUtils { * Performs upload new plugin action. * * @param file File to be uploaded. - * * @return {Promise} */ public uploadNewPlugin = async (file: string): Promise => { await this.page.goto(WP_BASE_URL + '/wp-admin/plugin-install.php'); + await this.page.waitForSelector('.upload-view-toggle'); await this.page.locator('.upload-view-toggle').click(); await this.page.locator('#pluginzip').setInputFiles(file); await this.page.waitForSelector('#install-plugin-submit'); - await this.page.locator('#install-plugin-submit').click({ timeout: 120000 }); + await this.page.locator('#install-plugin-submit').click(); } /** @@ -297,9 +297,9 @@ export class PageUtils { if(! await this.page.locator('#user_login').isVisible()) { return ; } - await this.page.waitForTimeout(200); + await this.wpAdminLogin(); - await this.page.waitForLoadState('load', { timeout: 30000 }); + } /** @@ -317,8 +317,9 @@ export class PageUtils { await this.sections.set("cache").visit(); await this.sections.massToggle(); await this.saveSettings(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); + await this.page.locator('#setting-error-settings_updated > button').click(); + } if(await this.sections.doesSectionExist('fileOptimization')) { @@ -326,8 +327,9 @@ export class PageUtils { await this.sections.set("fileOptimization").visit(); await this.sections.massToggle(); await this.saveSettings(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); + await this.page.locator('#setting-error-settings_updated > button').click(); + } if(await this.sections.doesSectionExist('media')) { @@ -335,8 +337,9 @@ export class PageUtils { await this.sections.set("media").visit(); await this.sections.massToggle(); await this.saveSettings(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); + await this.page.locator('#setting-error-settings_updated > button').click(); + } if(await this.sections.doesSectionExist('preload')) { @@ -344,8 +347,8 @@ export class PageUtils { await this.sections.set("preload").visit(); await this.sections.massToggle(); await this.saveSettings(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); + await this.page.locator('#setting-error-settings_updated > button').click(); } if(await this.sections.doesSectionExist('advancedRules')) { @@ -353,8 +356,8 @@ export class PageUtils { await this.sections.set("advancedRules").visit(); await this.sections.massFill(""); await this.saveSettings(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); + await this.page.locator('#setting-error-settings_updated > button').click(); } if(await this.sections.doesSectionExist('database')) { @@ -362,8 +365,8 @@ export class PageUtils { await this.sections.set("database").visit(); await this.sections.massToggle(); await this.page.getByRole('button', { name: 'Save Changes and Optimize' }).click(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); + await this.page.locator('#setting-error-settings_updated > button').click(); } if(await this.sections.doesSectionExist('cdn')) { @@ -372,8 +375,15 @@ export class PageUtils { await this.sections.massToggle(); await this.sections.fill("cnames", ""); await this.saveSettings(); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); + await this.page.locator('#setting-error-settings_updated > button').click(); + + } - await this.page.waitForLoadState('load', { timeout: 30000 }); + if(await this.sections.doesSectionExist('addons')) { + // Disable all settings for Addons. + await this.sections.set("addons").visit(); + await this.sections.massToggle(); } if(await this.sections.doesSectionExist('heartbeat')) { @@ -381,15 +391,11 @@ export class PageUtils { await this.sections.set("heartbeat").visit(); await this.sections.massToggle(); await this.saveSettings(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); + } - if(await this.sections.doesSectionExist('addons')) { - // Disable all settings for Addons. - await this.sections.set("addons").visit(); - await this.sections.massToggle(); - } + } /** @@ -415,8 +421,6 @@ export class PageUtils { public enableAllOptions = async (): Promise => { await this.gotoWpr(); - await this.page.waitForLoadState('load', { timeout: 30000 }); - this.sections.optionState = true; if (await this.sections.doesSectionExist('cache')) { @@ -424,8 +428,7 @@ export class PageUtils { await this.sections.set("cache").visit(); await this.sections.massToggle(); await this.saveSettings(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); } if(await this.sections.doesSectionExist('fileOptimization')) { @@ -433,8 +436,7 @@ export class PageUtils { await this.sections.set("fileOptimization").visit(); await this.sections.massToggle(); await this.saveSettings(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); } if (await this.sections.doesSectionExist('media')) { @@ -442,8 +444,7 @@ export class PageUtils { await this.sections.set("media").visit(); await this.sections.massToggle(); await this.saveSettings(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); } if (await this.sections.doesSectionExist('preload')) { @@ -451,8 +452,7 @@ export class PageUtils { await this.sections.set("preload").visit(); await this.sections.massToggle(); await this.saveSettings(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); } if(await this.sections.doesSectionExist('advancedRules')) { @@ -461,8 +461,7 @@ export class PageUtils { const values: Array = ['/test\n/.*\n/test2', 'woocommerce_items_in_cart', 'Mobile(.*)Safari(.*)', '/hello-world/', 'country']; await this.sections.massFill(values); await this.saveSettings(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); } if(await this.sections.doesSectionExist('database')) { @@ -470,8 +469,7 @@ export class PageUtils { await this.sections.set("database").visit(); await this.sections.massToggle(); await this.page.getByRole('button', { name: 'Save Changes and Optimize' }).click(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Database optimization process is complete')).toBeVisible(); } if(await this.sections.doesSectionExist('cdn')) { @@ -480,8 +478,14 @@ export class PageUtils { await this.sections.toggle("cdn"); await this.sections.fill("cnames", "test.example.com"); await this.saveSettings(); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); + await this.page.locator('#setting-error-settings_updated > button').click(); + } - await this.page.waitForLoadState('load', { timeout: 30000 }); + if(await this.sections.doesSectionExist('addons')) { + // Enable all settings for Addons. + await this.sections.set("addons").visit(); + await this.sections.massToggle(); } if(await this.sections.doesSectionExist('heartbeat')) { @@ -489,15 +493,10 @@ export class PageUtils { await this.sections.set("heartbeat").visit(); await this.sections.toggle("controlHeartbeat"); await this.saveSettings(); - - await this.page.waitForLoadState('load', { timeout: 30000 }); + await expect(this.page.getByText('Settings saved.')).toBeVisible(); } - if(await this.sections.doesSectionExist('addons')) { - // Enable all settings for Addons. - await this.sections.set("addons").visit(); - await this.sections.massToggle(); - } + } /**