From 910640036ecfdae680dce40cf156491dd3cfdda3 Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Tue, 17 Sep 2024 11:16:09 +0100 Subject: [PATCH 01/15] :closes: #137 add new urls to config --- config/wp.config.sample.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/config/wp.config.sample.ts b/config/wp.config.sample.ts index 0c72d607..96a966d8 100755 --- a/config/wp.config.sample.ts +++ b/config/wp.config.sample.ts @@ -86,6 +86,30 @@ const SCENARIO_URLS = { }, singleColon: { path: 'll_bg_css_single_colon' + }, + delayJs13Live: { + path: 'delayjs_1_3_live_template', + }, + delayJs68Live: { + path: 'delayjs_68_live_template', + }, + lcp6647Live: { + path: 'lcp_6647_live', + }, + lcpLive4Template: { + path: 'lcp_live_4_template', + }, + lcpLiveTestSpan: { + path: 'lcp_live_test_span', + }, + rucss5213Template: { + path: 'rucss_5213_template', + }, + template4787: { + path: '4787_template', + }, + lrcWillSite: { + path: 'lrc_will_site', } } From ec253deb20ebaa4fd2137d811d680cf6d2e4608d Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Wed, 18 Sep 2024 13:10:48 +0100 Subject: [PATCH 02/15] Add new step for LRC templates -- #137 --- src/features/lrc-visual-regression.feature | 14 ++++++++++++++ src/support/steps/general.ts | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/features/lrc-visual-regression.feature diff --git a/src/features/lrc-visual-regression.feature b/src/features/lrc-visual-regression.feature new file mode 100644 index 00000000..6cab9725 --- /dev/null +++ b/src/features/lrc-visual-regression.feature @@ -0,0 +1,14 @@ +@setup @lrc +Feature: LRC Visual Regression Test on Live Template + + Background: + Given I am logged in + And plugin is installed 'new_release' + And plugin is activated + And I go to 'wp-admin/options-general.php?page=wprocket#dashboard' + + Scenario: Shouldn't have any visual regression when visiting + When I log out + And I visit lrc live templates + And I am logged in + And I clear cache diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index 55ffa16c..353e78ff 100644 --- a/src/support/steps/general.ts +++ b/src/support/steps/general.ts @@ -14,7 +14,7 @@ import { expect } from "@playwright/test"; import { ICustomWorld } from "../../common/custom-world"; import { Given, When, Then } from '@cucumber/cucumber'; -import { WP_BASE_URL } from '../../../config/wp.config'; +import {SCENARIO_URLS, WP_BASE_URL} from '../../../config/wp.config'; import { createReference, compareReference } from "../../../utils/helpers"; import type { Section } from "../../../utils/types"; import { Page } from '@playwright/test'; @@ -262,6 +262,23 @@ When('I visit page {string} with browser dimension {int} x {int}', async functio await this.utils.visitPage(page); }); +/** + * Executes the step to visit page in a specific browser dimension. + */ +When('I visit lrc live templates', async function (this:ICustomWorld) { + await this.page.setViewportSize({ + width: 1600, + height: 700, + }); + const liveUrl = SCENARIO_URLS; + + for (const key in liveUrl) { + if(liveUrl[key].type === 'lrc') { + await this.utils.visitPage(liveUrl[key].path); + } + } +}); + /** * Executes the step to scroll to the bottom of the page. */ From fa4e9928cf7ae8aa70d8e5c8846e594bb5ac7f60 Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Wed, 18 Sep 2024 15:27:26 +0100 Subject: [PATCH 03/15] Add new command for lrc test --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 01666ae0..4c2ad48c 100755 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "test:llimages": "$npm_package_config_testCommand --tags @llimages", "test:lcp": "$npm_package_config_testCommand --tags @lcp", "test:test": "$npm_package_config_testCommand --tags @test", + "test:lrc": "$npm_package_config_testCommand --tags @lrc", "healthcheck": "ts-node healthcheck.ts", "wp-env": "wp-env" }, From 1269d45f61e7dae6f716c3b9b97406e0447e9f7d Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Thu, 19 Sep 2024 13:22:58 +0100 Subject: [PATCH 04/15] Add vr step --- src/features/lrc-visual-regression.feature | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/features/lrc-visual-regression.feature b/src/features/lrc-visual-regression.feature index 6cab9725..a3effe0f 100644 --- a/src/features/lrc-visual-regression.feature +++ b/src/features/lrc-visual-regression.feature @@ -12,3 +12,6 @@ Feature: LRC Visual Regression Test on Live Template And I visit lrc live templates And I am logged in And I clear cache + When I create reference + Then I must not see any visual regression 'general' + From 874ac9547acdfb91ef14d2515101d9139eeb4425 Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Thu, 19 Sep 2024 13:31:29 +0100 Subject: [PATCH 05/15] Update config --- config/wp.config.sample.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/config/wp.config.sample.ts b/config/wp.config.sample.ts index 96a966d8..5a3d1c1b 100755 --- a/config/wp.config.sample.ts +++ b/config/wp.config.sample.ts @@ -89,28 +89,36 @@ const SCENARIO_URLS = { }, delayJs13Live: { path: 'delayjs_1_3_live_template', + type: 'lrc' }, delayJs68Live: { path: 'delayjs_68_live_template', + type: 'lrc' }, lcp6647Live: { path: 'lcp_6647_live', + type: 'lrc' }, lcpLive4Template: { path: 'lcp_live_4_template', + type: 'lrc' }, lcpLiveTestSpan: { path: 'lcp_live_test_span', + type: 'lrc' }, rucss5213Template: { path: 'rucss_5213_template', + type: 'lrc' }, template4787: { path: '4787_template', + type: 'lrc' }, lrcWillSite: { path: 'lrc_will_site', - } + type: 'lrc' + }, } /** From 28498e19b253c8e59e8506c72a73cc8faa251a2e Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Mon, 23 Sep 2024 17:54:27 +0100 Subject: [PATCH 06/15] Modify vr process --- src/features/lrc-visual-regression.feature | 3 +-- src/support/steps/general.ts | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/features/lrc-visual-regression.feature b/src/features/lrc-visual-regression.feature index 8dcc7985..9d50190c 100644 --- a/src/features/lrc-visual-regression.feature +++ b/src/features/lrc-visual-regression.feature @@ -12,6 +12,5 @@ Feature: LRC Visual Regression Test on Live Template And I visit lrc live templates And I am logged in And I clear cache - When I create reference - Then I must not see any visual regression in LRC + Then I must not see any visual regression in scenario urls diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index 3f503945..056d8832 100644 --- a/src/support/steps/general.ts +++ b/src/support/steps/general.ts @@ -245,7 +245,8 @@ When('I clear cache', async function (this:ICustomWorld) { await this.utils.gotoWpr(); this.sections.set('dashboard'); - await this.sections.toggle('clearCacheBtn'); + await this.page.locator("text=Clear and preload").last().click(); + //await this.sections.toggle('clearCacheBtn'); await expect(this.page.getByText('WP Rocket: Cache cleared.')).toBeVisible(); }); @@ -319,11 +320,11 @@ Then('I must not see any visual regression {string}', async function (this: ICus /** * Executes the step to check for LRC visual regression. */ -Then('I must not see any visual regression in LRC', async function (this: ICustomWorld) { +Then('I must not see any visual regression in scenario urls', async function (this: ICustomWorld) { const liveUrl = SCENARIO_URLS; for (const key in liveUrl) { - await compareReference(liveUrl[key].path); + await compareReference(liveUrl[key]); } }); From 73859c3b0b0fb6504ddd87eaba218e849682c200 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Tue, 24 Sep 2024 09:31:02 +0100 Subject: [PATCH 07/15] Updated general tests --- src/support/steps/general.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index 056d8832..58a09bee 100644 --- a/src/support/steps/general.ts +++ b/src/support/steps/general.ts @@ -263,9 +263,9 @@ When('I visit page {string} with browser dimension {int} x {int}', async functio }); /** - * Executes the step to visit page in a specific browser dimension. + * Executes the step to visit scenario urls for visual regression testing in a specific browser dimension. */ -When('I visit lrc live templates', async function (this:ICustomWorld) { +When('I visit scenario urls', async function (this:ICustomWorld) { await this.page.setViewportSize({ width: 1600, height: 700, @@ -324,7 +324,7 @@ Then('I must not see any visual regression in scenario urls', async function (th const liveUrl = SCENARIO_URLS; for (const key in liveUrl) { - await compareReference(liveUrl[key]); + await compareReference(key); } }); From 4b17af7b793e37891c8ee1aec9b29e544505b814 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Tue, 24 Sep 2024 09:43:22 +0100 Subject: [PATCH 08/15] Allow backstop room to take reference snapshot before browser closes --- backstop_data/engine_scripts/wait.js | 2 +- utils/helpers.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backstop_data/engine_scripts/wait.js b/backstop_data/engine_scripts/wait.js index 3ab143c4..a0bfb433 100644 --- a/backstop_data/engine_scripts/wait.js +++ b/backstop_data/engine_scripts/wait.js @@ -1,3 +1,3 @@ module.exports = async (page) => { - await page.waitForTimeout(15000); + await page.waitForTimeout(3000); }; \ No newline at end of file diff --git a/utils/helpers.ts b/utils/helpers.ts index ca67e68f..f0faf61c 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -271,7 +271,7 @@ export const batchUpdateVRTestUrl = async(config: VRurlConfig): Promise => } else{ beforeScript = ''; - readyScript = config.optimize ? 'scrollToBottom.js' : ''; + readyScript = config.optimize ? 'scrollToBottom.js' : 'wait.js'; } viewports = 'mobile' in urls[key] && urls[key].mobile ? mobileViewport : []; From 25eb03bcbdd5ef4101f5b997156b714f0eec520d Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Tue, 24 Sep 2024 11:15:57 +0100 Subject: [PATCH 09/15] Updated step --- src/features/lrc-visual-regression.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/lrc-visual-regression.feature b/src/features/lrc-visual-regression.feature index 9d50190c..1ea206a7 100644 --- a/src/features/lrc-visual-regression.feature +++ b/src/features/lrc-visual-regression.feature @@ -9,7 +9,7 @@ Feature: LRC Visual Regression Test on Live Template Scenario: Shouldn't have any visual regression when visiting When I log out - And I visit lrc live templates + And I visit scenario urls And I am logged in And I clear cache Then I must not see any visual regression in scenario urls From f929e775ccff0eeb9244faacc5894085890b173f Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Tue, 24 Sep 2024 11:25:35 +0100 Subject: [PATCH 10/15] PR modifications --- src/support/steps/general.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index 58a09bee..89123c69 100644 --- a/src/support/steps/general.ts +++ b/src/support/steps/general.ts @@ -245,8 +245,8 @@ When('I clear cache', async function (this:ICustomWorld) { await this.utils.gotoWpr(); this.sections.set('dashboard'); - await this.page.locator("text=Clear and preload").last().click(); - //await this.sections.toggle('clearCacheBtn'); + const cacheButton = this.page.locator('p:has-text("This action will clear") + a').first(); + await cacheButton.click(); await expect(this.page.getByText('WP Rocket: Cache cleared.')).toBeVisible(); }); From 7be05e1685f79d20a1ff47f7378f5f951e3061b7 Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Mon, 30 Sep 2024 17:14:49 +0200 Subject: [PATCH 11/15] Add scrolltobottom.js to vr reference process --- utils/helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/helpers.ts b/utils/helpers.ts index afc134ae..b23b75b6 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -273,7 +273,7 @@ export const batchUpdateVRTestUrl = async(config: VRurlConfig): Promise => } else{ beforeScript = ''; - readyScript = config.optimize ? 'scrollToBottom.js' : 'wait.js'; + readyScript = config.optimize ? 'scrollToBottom.js' : 'scrollToBottom.js'; } viewports = 'mobile' in urls[key] && urls[key].mobile ? mobileViewport : []; From d73cb9dd910812c9df99b12b35e5d0be1b6e6a9a Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Mon, 30 Sep 2024 17:01:12 +0100 Subject: [PATCH 12/15] Scroll to bottom for reference --- utils/helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/helpers.ts b/utils/helpers.ts index b23b75b6..3b02a750 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -273,7 +273,7 @@ export const batchUpdateVRTestUrl = async(config: VRurlConfig): Promise => } else{ beforeScript = ''; - readyScript = config.optimize ? 'scrollToBottom.js' : 'scrollToBottom.js'; + readyScript = 'scrollToBottom.js'; } viewports = 'mobile' in urls[key] && urls[key].mobile ? mobileViewport : []; From a2fe30d56348e937bf811765d0d9c0dc243cbeed Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 1 Oct 2024 15:15:26 +0300 Subject: [PATCH 13/15] removed template that has VR after applying lrc due to problem in style --- config/scenarioUrls.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/scenarioUrls.json b/config/scenarioUrls.json index b13593d0..9b9d4b4c 100644 --- a/config/scenarioUrls.json +++ b/config/scenarioUrls.json @@ -33,9 +33,6 @@ "lcpLive4Template": { "path": "lcp_live_4_template" }, - "lcpLiveTestSpan": { - "path": "lcp_live_test_span" - }, "rucss5213Template": { "path": "rucss_5213_template" }, From a97f76e8f7e17ee80a467716f23d42b9328107a0 Mon Sep 17 00:00:00 2001 From: Mai Saad Date: Tue, 1 Oct 2024 15:54:00 +0300 Subject: [PATCH 14/15] removed template with dynamic images to avoid false + --- config/scenarioUrls.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config/scenarioUrls.json b/config/scenarioUrls.json index 9b9d4b4c..7f2b5ea9 100644 --- a/config/scenarioUrls.json +++ b/config/scenarioUrls.json @@ -20,10 +20,6 @@ "path": "ll_bg_css_single_colon" } }, - "test:lrc": { - "delayJs13Live": { - "path": "delayjs_1-3_live_template" - }, "delayJs68Live": { "path": "delayjs_68_live_template" }, From 6f31dd59e132cde9a636daff617ff51805f34546 Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Tue, 1 Oct 2024 16:32:33 +0200 Subject: [PATCH 15/15] Revert remove template --- config/scenarioUrls.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/scenarioUrls.json b/config/scenarioUrls.json index 7f2b5ea9..b13593d0 100644 --- a/config/scenarioUrls.json +++ b/config/scenarioUrls.json @@ -20,6 +20,10 @@ "path": "ll_bg_css_single_colon" } }, + "test:lrc": { + "delayJs13Live": { + "path": "delayjs_1-3_live_template" + }, "delayJs68Live": { "path": "delayjs_68_live_template" }, @@ -29,6 +33,9 @@ "lcpLive4Template": { "path": "lcp_live_4_template" }, + "lcpLiveTestSpan": { + "path": "lcp_live_test_span" + }, "rucss5213Template": { "path": "rucss_5213_template" },