Skip to content

Commit

Permalink
Merge branch 'develop' into feature/129-ll-not-applied-lcp
Browse files Browse the repository at this point in the history
  • Loading branch information
Miraeld committed Sep 19, 2024
2 parents 73e6d87 + 7b589ba commit 3ed8cef
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 108 deletions.
1 change: 1 addition & 0 deletions .github/workflows/lint_eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
branches:
- trunk
- develop

jobs:
lint:
Expand Down
23 changes: 23 additions & 0 deletions config/scenarioUrls.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
37 changes: 6 additions & 31 deletions config/wp.config.sample.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import ScenarioUrls from "./scenarioUrls.json";

/**
* The default WordPress admin user configuration for both local and live environments.
* @constant
Expand Down Expand Up @@ -67,37 +69,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.
Expand Down
7 changes: 3 additions & 4 deletions src/features/delete-plugin.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@smoke @local @setup
@smoke @local @setup
Feature: C4466 - Should successfully delete the plugin

Background:
Expand All @@ -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

6 changes: 2 additions & 4 deletions src/features/settings-export-import.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@smoke @local @export @setup
@smoke @local @export @setup
Feature: C2148 - Should not change the content of existing fields

Background:
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/support/results/expectedResultsDesktop.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"enabled": true
},
"lcp_single_double": {
"comment": "LCP on this template is from an <input> tag which is not handled by default. Hence, we expect no LCP to be identified.",
"lcp": [],
"viewport": [],
"enabled": true
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/support/results/expectedResultsMobile.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
"enabled": true
},
"lcp_single_double": {
"comment": "LCP on this template is from an <input> tag which is not handled by default. Hence, we expect no LCP to be identified.",
"lcp": [
],
"viewport": [],
Expand Down Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions src/support/steps/delete-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/support/steps/enable-all-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
16 changes: 8 additions & 8 deletions src/support/steps/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/);
});

Expand Down Expand Up @@ -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 });
});

/**
Expand All @@ -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 });
});

/**
Expand All @@ -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();
}

});

/**
Expand Down Expand Up @@ -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();
});
Expand Down
13 changes: 8 additions & 5 deletions src/support/steps/lcp-beacon-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import fs from 'fs/promises';
let data: string,
truthy: boolean = true,
failMsg: string,
jsonData: Record<string, { lcp: string[]; viewport: string[]; enabled: boolean }>,
jsonData: Record<string, { lcp: string[]; viewport: string[]; enabled: boolean, comment: string; }>,
isDbResultAvailable: boolean = true;

const actual: LcpData = {};
Expand Down Expand Up @@ -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;
Expand All @@ -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 ?? ''
}
}
}
Expand Down Expand Up @@ -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`;
}
}

Expand All @@ -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`;
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/support/steps/settings-export-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,19 @@ 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();
});

/**
* Executes the step to export data.
*/

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');
Expand Down
Loading

0 comments on commit 3ed8cef

Please sign in to comment.