Skip to content

Commit d05ce8e

Browse files
authored
Merge pull request #277 from wp-media/develop
Merge dev to trunk and release 1.2.0
2 parents 6a883f5 + a7949ea commit d05ce8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2587
-173
lines changed

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/config/wp.config.ts
22
/node_modules
33
/artifacts
4-
/plugin/new_release.zip
5-
/plugin/previous_stable.zip
6-
/plugin/wp-rocket_3.10.9.zip
4+
/plugin/*.zip
75
/plugin/exported_settings/wp-rocket-settings-test-2023-00-01-64e7ada0d3b70.json
86
/plugin/exported_settings/wp-rocket-settings-test-2023-00-02-64e7ada0d3b70.json
97
/plugin/exported_settings/wp-rocket-settings-test-2023-00-03-64e7ada0d3b70.json
@@ -14,4 +12,5 @@
1412
/backstop_data/html_report
1513
.DS_Store
1614
.idea
17-
backstop.json
15+
backstop.json
16+
/temp

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,24 @@ E2E tests here are written with Playwright. Without further ado, let's meet belo
2727
You can find this [here](https://github.com/wp-media/wp-rocket-e2e/blob/trunk/config/wp.config.sample.ts)
2828

2929
## Running Tests
30-
- Please delete the debug.log from your test site before running tests, We will automate this step in the future.
3130
- Don't forget to install the [helper plugin](https://github.com/wp-media/wp-rocket-e2e-test-helper)
3231
- To run tests on playwright, simply run `npx playwright test` or `npm run test:e2e` which ever you prefer.
33-
34-
**NB:** By default, test will run in headless mode.
32+
- To run Visual regression with certain feature run
33+
`npm run test:vr --wproption=lazyloadCssBgImg` This means to run visual regression for the pages defined for this feature LLCSSBG after enabling it
3534

3635
## Debugging Tests
3736
Use `npx playwright test --debug` to control and get a view of each test step.
3837

3938
You can also run `npx playwright test --headed` to view the tests being executed on the browser.
4039

4140
## Reporting
42-
At the end of a failed test cycle, playwright will launch a temporary server and open reports with videos and screenshot of failed tests.
41+
- In order to have report at the shared folder /var/shared/rocket-e2e-reports on remote e2e server, we can run this "WPRversion_e2e_testType_branch"
42+
`npm run test:e2e --tag=wpr3.19.4_e2e_all_dev` This means the test ran using WPR version 3.19.4 and e2e develop branch to run all tests
43+
44+
- At the end of a failed test cycle, playwright will launch a temporary server and open reports with videos and screenshot of failed tests.
4345

4446
If you ever get failed tests like the one below, it indicates that WP Rocket has some related errors in debug.log
4547
![Screenshot 2023-04-27 at 09 55 37](https://user-images.githubusercontent.com/38788055/234812244-c1cd0c87-702a-49a9-baf6-0fab7afd2cd0.png)
4648

49+
### BackWpUp Doc
50+
- [BackWpUp Documentation](src/backwpup/README.md)

backstop.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
],
2121
"engine": "puppeteer",
2222
"engineOptions": {
23+
"readyTimeout": 30000,
24+
"gotoTimeout": 30000,
2325
"args": [
2426
"--no-sandbox"
2527
],
26-
"headless": false,
27-
"timeout": 0
28+
"headless": false
2829
},
2930
"asyncCaptureLimit": 5,
3031
"asyncCompareLimit": 50,

config/wp.config.sample.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import ScenarioUrls from "./scenarioUrls.json";
21
/**
32
* The default WordPress admin user configuration for both local and live environments.
43
* @constant
@@ -26,6 +25,29 @@ const IMAGIFY_INFOS = {
2625
apiKey: ''
2726
} as const;
2827

28+
/**
29+
* Backwpup settings information
30+
*/
31+
const BACKWPUP_INFOS = {
32+
msazure: {
33+
accountName: '',
34+
accessKey: '',
35+
container: ''
36+
},
37+
sugarsync: {
38+
email: '',
39+
password: ''
40+
},
41+
ftp: {
42+
host: '',
43+
username: '',
44+
password: '',
45+
port: '21',
46+
ssl: false,
47+
passiveMode: true
48+
}
49+
} as const;
50+
2951
/**
3052
* Extracted environment variables related to WordPress configuration.
3153
* Uses default values if environment variables are not set.
@@ -62,21 +84,6 @@ const {
6284
WP_SSH_ROOT_DIR = ''
6385
} = process.env;
6486

65-
/**
66-
* Exported Scenario urls to be used for visual regression testing with backstopjs
67-
* @exports
68-
* @type {{
69-
* [key: string]: {
70-
* path?: string,
71-
* disableJs?: boolean,
72-
* theme?: string,
73-
* mobile?: boolean
74-
* }
75-
* }}
76-
*/
77-
const scriptName = process.env.npm_lifecycle_event;
78-
const SCENARIO_URLS = ScenarioUrls[scriptName];
79-
8087
/**
8188
* Exported WordPress environment configuration.
8289
* @exports
@@ -94,12 +101,6 @@ const SCENARIO_URLS = ScenarioUrls[scriptName];
94101
* WP_SSH_ADDRESS: string;
95102
* WP_SSH_KEY: string;
96103
* WP_SSH_ROOT_DIR: string;
97-
* SCENARIO_URLS: {
98-
* home: string;
99-
* llcss: string;
100-
* noJsLlcss: string;
101-
* elementorLlcss: string;
102-
* },
103104
* }}
104105
*/
105106
export {
@@ -116,6 +117,6 @@ export {
116117
WP_SSH_ADDRESS,
117118
WP_SSH_KEY,
118119
WP_SSH_ROOT_DIR,
119-
SCENARIO_URLS,
120-
IMAGIFY_INFOS
120+
IMAGIFY_INFOS,
121+
BACKWPUP_INFOS
121122
};

cucumber.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
"snippetInterface": "async-await"
55
},
66
"paths": [
7-
"src/features/"
7+
"src/features/",
8+
"src/backwpup/"
89
],
910
"publishQuiet": true,
1011
"dryRun": false,
1112
"require": [
1213
"src/support/steps/**/*.ts",
13-
"src/support/hooks.ts"
14+
"src/support/hooks.ts",
15+
"src/backwpup/support/hooks.ts",
16+
"src/backwpup/steps/**/*.ts"
1417
],
1518
"requireModule": [
1619
"ts-node/register"
@@ -21,7 +24,8 @@
2124
"json:test-results/cucumber-report.json",
2225
"rerun:@rerun.txt"
2326
],
24-
"parallel": 1
27+
"parallel": 1,
28+
"retry": 3
2529
},
2630
"rerun": {
2731
"formatOptions": {
@@ -31,7 +35,9 @@
3135
"dryRun": false,
3236
"require": [
3337
"src/support/steps/**/*.ts",
34-
"src/support/hooks.ts"
38+
"src/support/hooks.ts",
39+
"src/backwpup/support/hooks.ts",
40+
"src/backwpup/steps/**/*.ts"
3541
],
3642
"requireModule": [
3743
"ts-node/register"

open-report.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { exec } from 'child_process';
2+
import * as path from 'path';
3+
import { promisify } from 'util';
4+
5+
const execAsync = promisify(exec);
6+
7+
interface PlatformCommands {
8+
[key: string]: string;
9+
}
10+
11+
async function openCucumberReport(): Promise<void> {
12+
const reportPath: string = path.join(process.cwd(), 'test-results', 'cucumber-report.html');
13+
14+
const platformCommands: PlatformCommands = {
15+
'win32': `start "" "${reportPath}"`,
16+
'darwin': `open "${reportPath}"`,
17+
'linux': `xdg-open "${reportPath}"`
18+
};
19+
20+
const command: string = platformCommands[process.platform] || `xdg-open "${reportPath}"`;
21+
22+
try {
23+
await execAsync(command);
24+
console.log('✅ Cucumber report opened in browser');
25+
} catch (error) {
26+
console.error('❌ Error opening report:', error);
27+
}
28+
}
29+
30+
if (require.main === module) {
31+
openCucumberReport();
32+
}
33+
34+
export { openCucumberReport };

package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,30 @@
1010
"scripts": {
1111
"lint": "eslint . --ext .ts",
1212
"lint:fix": "eslint . --ext .ts --fix",
13-
"test:e2e": "$npm_package_config_testCommand --tags \"not @vr\" ; npm run push-report --tag=$npm_config_tag",
13+
"test:e2e": "$npm_package_config_testCommand --tags \"not @vr and not @delayjs and not @bwpupsmoke\" ; npm run push-report --tag=$npm_config_tag",
1414
"test:smoke": "$npm_package_config_testCommand --tags @smoke ; npm run push-report --tag=$npm_config_tag",
1515
"test:local": "$npm_package_config_testCommand --tags @local",
16+
"test:export": "$npm_package_config_testCommand --tags @export",
1617
"test:online": "$npm_package_config_testCommand --tags @online",
1718
"test:vr": "$npm_package_config_testCommand --tags @vr $npm_config_wproption",
1819
"test:llcssbg": "$npm_package_config_testCommand --tags @llcssbg",
1920
"test:delayjs": "$npm_package_config_testCommand --tags @delayjs",
2021
"test:lcp": "$npm_package_config_testCommand --tags @lcp",
22+
"test:long-test": "$npm_package_config_testCommand --tags @long-test",
23+
"test:priorityelements": "$npm_package_config_testCommand --tags @priorityelements",
24+
"test:preloadfonts": "$npm_package_config_testCommand --tags @preloadfonts",
25+
"test:selfhostgooglefonts": "$npm_package_config_testCommand --tags @selfhostgooglefonts",
2126
"test:test": "$npm_package_config_testCommand --tags @test",
2227
"test:lrc": "$npm_package_config_testCommand --tags @lrc",
2328
"test:cpcss": "$npm_package_config_testCommand --tags @cpcss",
2429
"test:performancehints": "$npm_package_config_testCommand --tags @performancehints",
2530
"healthcheck": "ts-node healthcheck.ts",
2631
"push-report": "ts-node report.ts",
27-
"wp-env": "wp-env"
32+
"wp-env": "wp-env",
33+
"test:bwpupstorage": "$npm_package_config_testCommand --tags @bwpupstorage",
34+
"test:bwpuponboarding": "$npm_package_config_testCommand --tags @bwpuponboarding",
35+
"test:bwpupsmoke": "$npm_package_config_testCommand --tags @bwpupsmoke",
36+
"test:bwpup": "$npm_package_config_testCommand --tags @bwpup"
2837
},
2938
"repository": {
3039
"type": "git",

src/backwpup/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Welcome to BackWpUp E2E Tests Repo
2+
E2E tests here are written with Playwright. Without further ado, let's meet below below ⤵️
3+
4+
5+
## Requirements
6+
- Do you still not have node installed? You'll be needing it.
7+
- You also need zip files of Backwpup pro, I'll explain:
8+
- zip the latest release - **rename the zip file name to `backwpup-pro.zip`. e.g `backwpup-5.3.1.zip` becomes `backwpup-pro.zip`**
9+
- Make sure to put the file in the `./plugin` folder in the root - Playwright will pick these files when needed and use them during tests.
10+
- To generate the zip, you can follow the steps [here](https://www.notion.so/wpmedia/Generate-a-Branch-Zip-File-29d931ad50e945dab8df5a4302ea948a#1c3ed22a22f0801f9d84f22b0bd1bd93)
11+
12+
13+
## Installation
14+
- Clone this repo
15+
- run a `npm install` to install dependencies, well for this case it's just playwright.
16+
- Additionally, in some cases on a fresh install you might also need to run `npx playwright install` to download the various browser engines as well.
17+
18+
19+
## Configuration
20+
You'll need to update the site you want to run tests on as well as the credentials.
21+
22+
Update the `wp.config.sample.ts` to `wp.config.ts` in https://github.com/wp-media/wp-rocket-e2e/blob/trunk/config/
23+
24+
Change the `live_username` & `live_password` & `WP_BASE_URL` to that of your test site.
25+
26+
You can find this [here](https://github.com/wp-media/wp-rocket-e2e/blob/trunk/config/wp.config.sample.ts)
27+
28+
## Running Tests
29+
- Please delete forget to delete the backup after running your tests, We will automate this step in the future.
30+
- To run tests on playwright, simply run `npm run test:bwpupsmoke` which ever you prefer.
31+
32+
**NB:** By default, test will run in headless mode.
33+
34+
## Debugging Tests
35+
Use `npx playwright test --debug` to control and get a view of each test step.
36+
37+
You can also run `npx playwright test --headed` to view the tests being executed on the browser.
38+
39+
40+
## TODO
41+
- Add option for backwpup free plugin
42+
- Create helper function to read debug.log content
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {IWorldOptions, setWorldConstructor, World} from "@cucumber/cucumber";
2+
import {BrowserContext, Page} from "@playwright/test";
3+
import {Sections} from "../../common/sections";
4+
import {PageUtils} from "../../../utils/page-utils";
5+
import {Pickle} from "@cucumber/messages/dist/esm/src";
6+
import {Section} from "../../../utils/types";
7+
import {BackupRowData} from "../utils/types";
8+
import {StorageUtils} from "../utils/storage";
9+
10+
export interface ICustomWorld extends World {
11+
context?: BrowserContext;
12+
page?: Page;
13+
sections?: Sections;
14+
utils?: PageUtils;
15+
pickle?: Pickle;
16+
wprSection?: Section;
17+
wprOption?: string;
18+
initialBackups?: BackupRowData[];
19+
storage?: StorageUtils;
20+
}
21+
22+
export class CustomWorld extends World implements ICustomWorld {
23+
constructor(options: IWorldOptions) {
24+
super(options)
25+
}
26+
}
27+
28+
setWorldConstructor(CustomWorld)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@bwpup @bwpupsetup @bwpupsmoke
2+
Feature: Should be able to backup
3+
4+
Background:
5+
Given I am logged in
6+
And I delete backwpup plugin
7+
And plugin is installed 'backwpup-pro'
8+
And plugin is activated
9+
10+
Scenario: Should common backup now generate files&DB locally
11+
And I go '/wp-admin/admin.php?page=backwpup'
12+
When I click '.js-backwpup-onboarding-step-2' button to continue
13+
And I click '.js-backwpup-onboarding-step-3' button to continue
14+
When I Configure web server storage
15+
And I go '/wp-admin/admin.php?page=backwpup'
16+
And I should see 'mixed' job cards
17+
Then the backup should be added to the table
18+
When I click on common backup now button
19+
Then '1' backup is generated and added to history

0 commit comments

Comments
 (0)