From eecef07cd1f309aff810df1090fc8d210b960a29 Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Fri, 13 Sep 2024 08:35:26 +0100 Subject: [PATCH 01/22] Add comments to lcp json :closes: #121 --- src/support/results/expectedResultsDesktop.json | 2 ++ src/support/results/expectedResultsMobile.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/support/results/expectedResultsDesktop.json b/src/support/results/expectedResultsDesktop.json index da3c37a..4c815f9 100644 --- a/src/support/results/expectedResultsDesktop.json +++ b/src/support/results/expectedResultsDesktop.json @@ -184,6 +184,7 @@ "enabled": true }, "lcp_single_double": { + "comment": "LCP on this template is from an tag which is not handled by default. Hence, we expect no LCP to be identified.", "lcp": [], "viewport": [], "enabled": true @@ -311,6 +312,7 @@ "enabled": true }, "lcp_6647_svgbg_template": { + "comment": "Contains only SVG and background-image styles starting with data:image. Those are not captured by our OCI feature.", "lcp": [], "viewport": [], "enabled": true diff --git a/src/support/results/expectedResultsMobile.json b/src/support/results/expectedResultsMobile.json index 978242f..d2b5d71 100644 --- a/src/support/results/expectedResultsMobile.json +++ b/src/support/results/expectedResultsMobile.json @@ -175,6 +175,7 @@ "enabled": true }, "lcp_single_double": { + "comment": "LCP on this template is from an tag which is not handled by default. Hence, we expect no LCP to be identified.", "lcp": [ ], "viewport": [], @@ -306,6 +307,7 @@ "enabled": true }, "lcp_6647_svgbg_template": { + "comment": "Contains only SVG and background-image styles starting with data:image. Those are not captured by our OCI feature.", "lcp": [], "viewport": [], "enabled": true From e067b99c2fc48435f957e2ffbfed359fe5cf6031 Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Fri, 13 Sep 2024 13:25:58 +0100 Subject: [PATCH 02/22] Add comment to script function --- src/support/steps/lcp-beacon-script.ts | 13 ++++++++----- utils/types.ts | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/support/steps/lcp-beacon-script.ts b/src/support/steps/lcp-beacon-script.ts index fc6c124..cd7508b 100644 --- a/src/support/steps/lcp-beacon-script.ts +++ b/src/support/steps/lcp-beacon-script.ts @@ -21,7 +21,7 @@ import fs from 'fs/promises'; let data: string, truthy: boolean = true, failMsg: string, - jsonData: Record, + jsonData: Record, isDbResultAvailable: boolean = true; const actual: LcpData = {}; @@ -71,7 +71,7 @@ When('I visit the urls for {string}', async function (this: ICustomWorld, formFa await this.page.waitForFunction(() => { const beacon = document.querySelector('[data-name="wpr-wpr-beacon"]'); return beacon && beacon.getAttribute('beacon-completed') === 'true'; - }); + }, { timeout: 900000 }); if (formFactor !== 'desktop') { isMobile = 1; @@ -95,7 +95,8 @@ When('I visit the urls for {string}', async function (this: ICustomWorld, formFa actual[key] = { url: url, lcp: resultFromStdout[0].lcp, - viewport: resultFromStdout[0].viewport + viewport: resultFromStdout[0].viewport, + comment: jsonData[key].comment ?? '' } } } @@ -125,7 +126,8 @@ Then('lcp and atf should be as expected for {string}', async function (this: ICu // Check if expected lcp is present in actual lcp. if (!actual[key].lcp.includes(lcp)) { truthy = false; - failMsg += `Expected LCP for ${formFactor} - ${lcp} for ${actual[key].url} is not present in actual - ${actual[key].lcp}\n\n\n`; + failMsg += `Expected LCP for ${formFactor} - ${lcp} for ${actual[key].url} is not present in actual - ${actual[key].lcp} + more info -- ( ${actual[key].comment} )\n\n\n`; } } @@ -134,7 +136,8 @@ Then('lcp and atf should be as expected for {string}', async function (this: ICu for (const viewport of expected.viewport) { if (!actual[key].viewport.includes(viewport)) { truthy = false; - failMsg += `Expected Viewport for ${formFactor} - ${viewport} for ${actual[key].url} is not present in actual - ${actual[key].viewport}\n\n\n`; + failMsg += `Expected Viewport for ${formFactor} - ${viewport} for ${actual[key].url} is not present in actual - ${actual[key].viewport} + more info -- ( ${actual[key].comment} )\n\n\n`; } } } diff --git a/utils/types.ts b/utils/types.ts index 64dddf3..d03be64 100644 --- a/utils/types.ts +++ b/utils/types.ts @@ -104,7 +104,8 @@ export interface LcpData { [key: string]: { url: string, lcp: string, - viewport: string + viewport: string, + comment: string } } From da2b9738ad4a55b7d5b30597b4256662c772c06f Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 10:18:49 +0300 Subject: [PATCH 03/22] refactor rollback related steps --- src/support/steps/general.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index 30cfe75..70cd769 100644 --- a/src/support/steps/general.ts +++ b/src/support/steps/general.ts @@ -107,7 +107,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 +131,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(); + } + }); /** From 16385e3bfcf7e26578b706ce9f7f797ae179d52e Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 10:32:45 +0300 Subject: [PATCH 04/22] refactor enable all options --- utils/page-utils.ts | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/utils/page-utils.ts b/utils/page-utils.ts index 3ac1b56..a113dcd 100644 --- a/utils/page-utils.ts +++ b/utils/page-utils.ts @@ -415,7 +415,7 @@ export class PageUtils { public enableAllOptions = async (): Promise => { await this.gotoWpr(); - await this.page.waitForLoadState('load', { timeout: 30000 }); + // await this.page.waitForLoadState('load', { timeout: 30000 }); this.sections.optionState = true; @@ -424,8 +424,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 +432,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 +440,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 +448,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 +457,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 +465,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 +474,13 @@ 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.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 +488,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(); - } + } /** From 3ed302083452244892afbe6488d6743a08c9bdb0 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 10:45:18 +0300 Subject: [PATCH 05/22] refactor page load successfully step and login --- src/support/steps/enable-all-features.ts | 2 +- utils/page-utils.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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/utils/page-utils.ts b/utils/page-utils.ts index a113dcd..c22bbef 100644 --- a/utils/page-utils.ts +++ b/utils/page-utils.ts @@ -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 }); + } /** From 270669fd0a5b47550d84d91378f275ece045775e Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 10:56:58 +0300 Subject: [PATCH 06/22] refactor plugin install --- src/support/steps/general.ts | 1 - utils/page-utils.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index 70cd769..9e38e5d 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/); }); diff --git a/utils/page-utils.ts b/utils/page-utils.ts index c22bbef..6a2a88a 100644 --- a/utils/page-utils.ts +++ b/utils/page-utils.ts @@ -268,7 +268,7 @@ export class PageUtils { 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(); } /** From e7e1f10a3bab9e3bee427da09f35d4ccb55ce683 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 11:03:16 +0300 Subject: [PATCH 07/22] remove wait when check that no error in debug.log --- src/support/steps/general.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index 9e38e5d..59eacc2 100644 --- a/src/support/steps/general.ts +++ b/src/support/steps/general.ts @@ -282,7 +282,7 @@ 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 }); + // Assert that there is no related error in debug.log await expect(this.page.locator('#wpr_debug_log_notice')).toBeHidden(); }); From f6abd21fb9ecdcb22a65d721251ef2147e3091e9 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 11:38:33 +0300 Subject: [PATCH 08/22] remove wait from delete plugin --- src/support/steps/delete-plugin.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/support/steps/delete-plugin.ts b/src/support/steps/delete-plugin.ts index e7bd55f..a4b1a5d 100644 --- a/src/support/steps/delete-plugin.ts +++ b/src/support/steps/delete-plugin.ts @@ -29,8 +29,6 @@ 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(); From 7573ebd41e73665e0f83022477cb321dd974d677 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 12:47:20 +0300 Subject: [PATCH 09/22] remove load from import settings, save settings user cache and disable all options --- src/support/steps/general.ts | 1 - src/support/steps/settings-export-import.ts | 2 +- utils/page-utils.ts | 41 +++++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index 59eacc2..9d9fe59 100644 --- a/src/support/steps/general.ts +++ b/src/support/steps/general.ts @@ -83,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 }); }); /** diff --git a/src/support/steps/settings-export-import.ts b/src/support/steps/settings-export-import.ts index 009e79b..311233f 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(); }); /** diff --git a/utils/page-utils.ts b/utils/page-utils.ts index 6a2a88a..3ec801e 100644 --- a/utils/page-utils.ts +++ b/utils/page-utils.ts @@ -317,8 +317,8 @@ 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')) { @@ -326,8 +326,8 @@ 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')) { @@ -335,8 +335,8 @@ 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')) { @@ -344,8 +344,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')) { @@ -353,8 +352,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(); + } if(await this.sections.doesSectionExist('database')) { @@ -362,8 +361,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(); + } if(await this.sections.doesSectionExist('cdn')) { @@ -372,8 +371,14 @@ 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.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 +386,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(); - } + } /** From 877af862cdb4bee852f7b98730ea2e5444dd98a6 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 14:23:22 +0300 Subject: [PATCH 10/22] using plugins page to confirm no debug error instead of WPR as wpr may be already deleted --- src/support/steps/general.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index 9d9fe59..bde5458 100644 --- a/src/support/steps/general.ts +++ b/src/support/steps/general.ts @@ -280,7 +280,7 @@ 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.utils.gotoPlugin(); // Assert that there is no related error in debug.log await expect(this.page.locator('#wpr_debug_log_notice')).toBeHidden(); From da0d4475b85a121f1646640fc46035dc313ebe19 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 14:24:41 +0300 Subject: [PATCH 11/22] adjust data imported test as it's validated across all disabled options and reorder steps for export after update but still need some work there --- src/features/settings-export-import.feature | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/features/settings-export-import.feature b/src/features/settings-export-import.feature index cb53156..207aad2 100644 --- a/src/features/settings-export-import.feature +++ b/src/features/settings-export-import.feature @@ -8,9 +8,9 @@ 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 + And I save settings 'cache' 'cacheLoggedUser' When I import data Then data is imported correctly @@ -25,9 +25,10 @@ Feature: C2148 - Should not change the content of existing fields 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 save settings 'media' 'lazyload' + And I updated plugin to 'new_release' + And I save settings 'media' 'lazyload' When I export data '3' Then data '3' is exported correctly Then I must not see changes in exported files From da3a717f831066ae6c7a2bff388fc81ea60139a4 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 20:04:39 +0300 Subject: [PATCH 12/22] removed unneeded save step as save is already in disable/enable all settings --- src/features/settings-export-import.feature | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/features/settings-export-import.feature b/src/features/settings-export-import.feature index 207aad2..2887b25 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 @only Feature: C2148 - Should not change the content of existing fields Background: @@ -10,7 +10,6 @@ Feature: C2148 - Should not change the content of existing fields And I disabled all settings And I export data '1' And I enable all settings - And I save settings 'cache' 'cacheLoggedUser' When I import data Then data is imported correctly @@ -18,7 +17,6 @@ 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 @@ -26,7 +24,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 'media' 'lazyload' And I updated plugin to 'new_release' And I save settings 'media' 'lazyload' When I export data '3' From 1fbb049fa7df33fd41bce03033a1ee69bc2cea06 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 20:06:09 +0300 Subject: [PATCH 13/22] moved if condition to successfully deleted step --- src/support/steps/delete-plugin.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/support/steps/delete-plugin.ts b/src/support/steps/delete-plugin.ts index a4b1a5d..9ca3718 100644 --- a/src/support/steps/delete-plugin.ts +++ b/src/support/steps/delete-plugin.ts @@ -32,17 +32,18 @@ When('I delete plugin', async function (this: ICustomWorld) { // 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(); From 50e48e7b69285c538a42f9272428ea32dbe7976f Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 20:07:36 +0300 Subject: [PATCH 14/22] added condition to switch to tools page if it wasnot open --- src/support/steps/settings-export-import.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/support/steps/settings-export-import.ts b/src/support/steps/settings-export-import.ts index 311233f..d5033b1 100644 --- a/src/support/steps/settings-export-import.ts +++ b/src/support/steps/settings-export-import.ts @@ -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'); From 7e755682c3d07a3809ffca1adff11f1871a86f10 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 17 Sep 2024 20:09:40 +0300 Subject: [PATCH 15/22] modified page utils to avoid possible error --- utils/page-utils.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/utils/page-utils.ts b/utils/page-utils.ts index 3ec801e..04fc270 100644 --- a/utils/page-utils.ts +++ b/utils/page-utils.ts @@ -260,11 +260,11 @@ 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'); @@ -318,6 +318,7 @@ export class PageUtils { await this.sections.massToggle(); await this.saveSettings(); await expect(this.page.getByText('Settings saved.')).toBeVisible(); + await this.page.locator('#setting-error-settings_updated > button').click(); } @@ -327,6 +328,7 @@ export class PageUtils { await this.sections.massToggle(); await this.saveSettings(); await expect(this.page.getByText('Settings saved.')).toBeVisible(); + await this.page.locator('#setting-error-settings_updated > button').click(); } @@ -336,6 +338,7 @@ export class PageUtils { await this.sections.massToggle(); await this.saveSettings(); await expect(this.page.getByText('Settings saved.')).toBeVisible(); + await this.page.locator('#setting-error-settings_updated > button').click(); } @@ -345,6 +348,7 @@ export class PageUtils { await this.sections.massToggle(); await this.saveSettings(); 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,7 +357,7 @@ export class PageUtils { await this.sections.massFill(""); await this.saveSettings(); 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,7 +366,7 @@ export class PageUtils { await this.sections.massToggle(); await this.page.getByRole('button', { name: 'Save Changes and Optimize' }).click(); 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,6 +376,7 @@ export class PageUtils { 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(); } @@ -476,6 +481,7 @@ export class PageUtils { 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(); } if(await this.sections.doesSectionExist('addons')) { From 3a60d40cd9d5def27770a7387287a583e41742b0 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Wed, 18 Sep 2024 11:25:47 +0300 Subject: [PATCH 16/22] remove unnecessary save step --- src/features/delete-plugin.feature | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/features/delete-plugin.feature b/src/features/delete-plugin.feature index 3166343..89637c7 100644 --- a/src/features/delete-plugin.feature +++ b/src/features/delete-plugin.feature @@ -1,4 +1,4 @@ -@smoke @local @setup +@smoke @local @setup @only 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 From 9ee414fd542bd637d909722937d016481b3b2b5a Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Wed, 18 Sep 2024 11:26:16 +0300 Subject: [PATCH 17/22] adjust space --- utils/page-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/page-utils.ts b/utils/page-utils.ts index 04fc270..765bc6c 100644 --- a/utils/page-utils.ts +++ b/utils/page-utils.ts @@ -264,7 +264,7 @@ export class PageUtils { */ 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.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'); From 5c16df96830a8cc55b60957ad81cf2387662cc70 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Wed, 18 Sep 2024 11:34:49 +0300 Subject: [PATCH 18/22] removed only tag --- src/features/settings-export-import.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/settings-export-import.feature b/src/features/settings-export-import.feature index 2887b25..b431e34 100644 --- a/src/features/settings-export-import.feature +++ b/src/features/settings-export-import.feature @@ -1,4 +1,4 @@ -@smoke @local @export @setup @only +@smoke @local @export @setup Feature: C2148 - Should not change the content of existing fields Background: From 93bfa1c02ed87ffc1bda7dcfc54ea40ec4d590fb Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Thu, 19 Sep 2024 05:15:13 +0300 Subject: [PATCH 19/22] delete only local tag --- src/features/delete-plugin.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/delete-plugin.feature b/src/features/delete-plugin.feature index 89637c7..4b1f3ac 100644 --- a/src/features/delete-plugin.feature +++ b/src/features/delete-plugin.feature @@ -1,4 +1,4 @@ -@smoke @local @setup @only +@smoke @local @setup Feature: C4466 - Should successfully delete the plugin Background: From 3193b1e994e8e793c2fea54a6a38ebfdaff2a84b Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Thu, 19 Sep 2024 05:15:46 +0300 Subject: [PATCH 20/22] delete commented wait for load --- utils/page-utils.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/utils/page-utils.ts b/utils/page-utils.ts index 765bc6c..822169a 100644 --- a/utils/page-utils.ts +++ b/utils/page-utils.ts @@ -421,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')) { From a7e0390651123b541c52c980d64c525409d99892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Robin?= Date: Thu, 19 Sep 2024 15:40:02 +0200 Subject: [PATCH 21/22] Closes #138: Make `SCENARIO_URLS` dynamic and depending on the running test (#141) * Closes #138: Make `SCENARIO_URLS` dynamic and depending on the running test * Remove function from config --- config/scenarioUrls.json | 23 +++++++++++++++++++++++ config/wp.config.sample.ts | 37 ++++++------------------------------- 2 files changed, 29 insertions(+), 31 deletions(-) create mode 100644 config/scenarioUrls.json diff --git a/config/scenarioUrls.json b/config/scenarioUrls.json new file mode 100644 index 0000000..4bb7f15 --- /dev/null +++ b/config/scenarioUrls.json @@ -0,0 +1,23 @@ +{ + "test:llcssbg": { + "home": { + "path": "" + }, + "llcss": { + "path": "lazyload_css_background_images" + }, + "noJsLlcss": { + "path": "lazyload_css_background_images", + "disableJs": true + }, + "elementorLlcss": { + "path": "elementor-overlay" + }, + "doubleColon": { + "path": "ll_bg_css_double_colon" + }, + "singleColon": { + "path": "ll_bg_css_single_colon" + } + } +} \ No newline at end of file diff --git a/config/wp.config.sample.ts b/config/wp.config.sample.ts index 0c72d60..7681712 100755 --- a/config/wp.config.sample.ts +++ b/config/wp.config.sample.ts @@ -1,3 +1,5 @@ +import ScenarioUrls from "./scenarioUrls.json"; + /** * The default WordPress admin user configuration for both local and live environments. * @constant @@ -57,37 +59,10 @@ const { * } * }} */ -const SCENARIO_URLS = { - /** - * The value will hold the url paths - */ - home: { - path: '' - }, - llcss: { - path: 'lazyload_css_background_images' - }, - noJsLlcss: { - path: 'lazyload_css_background_images', - disableJs: true - }, - elementorLlcss: { - path: 'elementor-overlay' - }, - delayJs: { - path: '' - }, - delayJsMobile: { - path: '', - mobile: true, - }, - doubleColon: { - path: 'll_bg_css_double_colon' - }, - singleColon: { - path: 'll_bg_css_single_colon' - } -} + + +const scriptName = process.env.npm_lifecycle_event; +const SCENARIO_URLS = ScenarioUrls[scriptName]; /** * Exported WordPress environment configuration. From 7b589ba20f78d9f25d0d3edaec1278cf60f92b33 Mon Sep 17 00:00:00 2001 From: Michael Lee <38788055+jeawhanlee@users.noreply.github.com> Date: Thu, 19 Sep 2024 15:12:46 +0100 Subject: [PATCH 22/22] Added develop to workflow trigger (#148) --- .github/workflows/lint_eslint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint_eslint.yml b/.github/workflows/lint_eslint.yml index 3c1a0f8..393714a 100644 --- a/.github/workflows/lint_eslint.yml +++ b/.github/workflows/lint_eslint.yml @@ -3,6 +3,7 @@ on: pull_request: branches: - trunk + - develop jobs: lint: