Skip to content

Commit

Permalink
Merge branch 'trunk' into feature/88-add-more-lcp-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Miraeld committed Jun 19, 2024
2 parents 72e52f0 + 2f1a562 commit 860160d
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 69 deletions.
38 changes: 18 additions & 20 deletions src/support/results/expectedResultsDesktop.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
},
"lcp_img_loadedbydynamicjs_template": {
"lcp": [
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/lcp/testavif.avif"
"/wp-content/rocket-test-data/images/lcp/testavif.avif"
],
"viewport": [
"http://www.google.com/intl/en_com/images/logo_plain.png"
"/wp-content/rocket-test-data/images/lcp/logo_plain.png"
],
"enabled": false
"enabled": true
},
"lcp_img_loadedbyjs_template": {
"lcp": [
Expand All @@ -49,10 +49,10 @@
},
"lcp_with_space_after_title": {
"lcp": [
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/lcp/testwebp.webp"
"/wp-content/rocket-test-data/images/lcp/testwebp.webp"
],
"viewport": [
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/test_inline2.jpeg"
"/wp-content/rocket-test-data/images/test_inline2.jpeg"
],
"enabled": true
},
Expand All @@ -68,12 +68,12 @@
"lcp_bg_responsive_webkit_template": {
"lcp": [
"https://fastly.picsum.photos/id/976/200/300.jpg?hmac=s1Uz9fgJv32r8elfaIYn7pLpQXps7X9oYNwC5XirhO8",
"https://rocketlabsqa.ovh/wp-content/rocket-test-data/images/fixtheissue.jpg"
"/wp-content/rocket-test-data/images/fixtheissue.jpg"
],
"viewport": [
"/wp-content/rocket-test-data/image/test3.webp",
"/wp-content/rocket-test-data/images/lcp/testwebp.webp",
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/lcp/testavif.avif"
"/wp-content/rocket-test-data/images/lcp/testavif.avif"
],
"enabled": true
},
Expand Down Expand Up @@ -102,17 +102,17 @@
},
"lcp_rsponsive_imagegrid": {
"lcp": [
"https://www.w3schools.com/w3images/underwater.jpg"
"/wp-content/rocket-test-data/images/lcp/underwater.jpg"
],
"viewport": [
"https://www.w3schools.com/w3images/wedding.jpg",
"https://www.w3schools.com/w3images/rocks.jpg",
"/wp-content/rocket-test-data/images/lcp/wedding.jpg",
"/wp-content/rocket-test-data/images/lcp/rocks.jpg",
"/wp-content/rocket-test-data/images/lcp/testPng.png",
"/wp-content/rocket-test-data/images/lcp/testavif.avif",
"/wp-content/rocket-test-data/images/file_example_JPG_100kB.jpg",
"/wp-content/rocket-test-data/images/maxime-lebrun-6g3Akg708E0-unsplash.jpg"
],
"enabled": false
"enabled": true
},
"lcp_attribute_template": {
"lcp": [
Expand Down Expand Up @@ -141,7 +141,7 @@
],
"viewport": [
"/test.png",
"wp-content/rocket-test-data/images/lcp/testjpg.jpg"
"/wp-content/rocket-test-data/images/test3.gif"
],
"enabled": true
},
Expand All @@ -151,19 +151,19 @@
],
"viewport": [
"/wp-content/rocket-test-data/images/lcp/testPng.png",
"https://cdn.pixabay.com/photo/2023/06/05/02/01/starry-sky-8041247_1280.jpg"
"/wp-content/rocket-test-data/images/lcp/testavif.avif"
],
"enabled": false
"enabled": true
},
"lcp_image_withspecialchar_template": {
"lcp": [
"/wp-content/rocket-test-data/images/lcp/image%20with%20space.jpg"
],
"viewport": [
"/wp-content/rocket-test-data/images/testspace%202.png",
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/paperéquipesTest.jpeg"
"/wp-content/rocket-test-data/images/paper%C3%A9quipesTest.jpeg"
],
"enabled": false
"enabled": true
},
"lcp_img_addedbydynamicstyle_template": {
"lcp": [
Expand All @@ -184,11 +184,9 @@
"enabled": true
},
"lcp_single_double": {
"lcp": [
"/wp-content/rocket-test-data/images/lcp/testwebp.webp"
],
"lcp": [],
"viewport": [],
"enabled": false
"enabled": true
},
"lcp_withfetchprioritylow_template": {
"lcp": [
Expand Down
74 changes: 31 additions & 43 deletions src/support/results/expectedResultsMobile.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,49 @@
},
"lcp_bg_samestyle_template": {
"lcp": [
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/lcp/testavif.avif"
"/wp-content/rocket-test-data/images/lcp/testjpg.jpg"
],
"viewport": [
"/wp-content/rocket-test-data/images/lcp/testjpg.jpg"
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/lcp/testavif.avif"
],
"enabled": false
"enabled": true
},
"lcp_img_loadedbydynamicjs_template": {
"lcp": [
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/lcp/testavif.avif"
"/wp-content/rocket-test-data/images/lcp/testavif.avif"
],
"viewport": [
"http://www.google.com/intl/en_com/images/logo_plain.png"
"/wp-content/rocket-test-data/images/lcp/logo_plain.png"
],
"enabled": false
"enabled": true
},
"lcp_img_loadedbyjs_template": {
"lcp": [
"/wp-content/rocket-test-data/images/istockphoto-1184692500-612x612.webp"
"/wp-content/rocket-test-data/images/lcp/testwebp.webp"
],
"viewport": [
"/test.png",
"/wp-content/rocket-test-data/images/lcp/testwebp.webp"
"/wp-content/rocket-test-data/images/istockphoto-1184692500-612x612.webp"
],
"enabled": false
"enabled": true
},
"lcp_bg_multimage_template": {
"lcp": [
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/image/test3.webp",
"/wp-content/rocket-test-data/image/file_example_JPG_100kB.jpg"
],
"viewport": [
"https://fastly.picsum.photos/id/976/200/300.jpg?hmac=s1Uz9fgJv32r8elfaIYn7pLpQXps7X9oYNwC5XirhO8",
"https://rocketlabsqa.ovh/wp-content/rocket-test-data/images/fixtheissue.jpg"
],
"enabled": false
"viewport": [
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/image/test3.webp",
"/wp-content/rocket-test-data/image/file_example_JPG_100kB.jpg"
],
"enabled": true
},
"lcp_with_space_after_title": {
"lcp": [
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/lcp/testwebp.webp"
"/wp-content/rocket-test-data/images/lcp/testwebp.webp"
],
"viewport": [
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/test_inline2.jpeg"
"/wp-content/rocket-test-data/images/test_inline2.jpeg"
],
"enabled": true
},
Expand All @@ -68,14 +68,12 @@
"lcp_bg_responsive_webkit_template": {
"lcp": [
"https://fastly.picsum.photos/id/976/200/300.jpg?hmac=s1Uz9fgJv32r8elfaIYn7pLpQXps7X9oYNwC5XirhO8",
"https://rocketlabsqa.ovh/wp-content/rocket-test-data/images/fixtheissue.jpg"
"/wp-content/rocket-test-data/images/fixtheissue.jpg"
],
"viewport": [
"/wp-content/rocket-test-data/image/test3.webp",
"/wp-content/rocket-test-data/images/lcp/testwebp.webp",
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/lcp/testavif.avif"
"/wp-content/rocket-test-data/image/test3.webp"
],
"enabled": false
"enabled": true
},
"lcp_regular_image_template": {
"lcp": [
Expand All @@ -102,18 +100,12 @@
},
"lcp_rsponsive_imagegrid": {
"lcp": [
"https://www.w3schools.com/w3images/underwater.jpg"
"/wp-content/rocket-test-data/images/lcp/rocks.jpg"
],
"viewport": [
"https://www.w3schools.com/w3images/wedding.jpg",
"/wp-content/rocket-test-data/images/file_example_JPG_100kB.jpg",
"/wp-content/rocket-test-data/images/lcp/testavif.avif",
"https://www.w3schools.com/w3images/rocks.jpg",
"/wp-content/rocket-test-data/images/lcp/testPng.png",
"/wp-content/rocket-test-data/images/maxime-lebrun-6g3Akg708E0-unsplash.jpg",
"https://www.w3schools.com/w3images/ocean.jpg"
"/wp-content/rocket-test-data/images/lcp/wedding.jpg"
],
"enabled": false
"enabled": true
},
"lcp_attribute_template": {
"lcp": [
Expand All @@ -123,17 +115,13 @@
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/lcp/testPng.png",
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/wp-rocket2.svg",
"/wp-content/rocket-test-data/images/lcp/testsvg.svg",
"https://fastly.picsum.photos/id/976/200/300.jpg?hmac=s1Uz9fgJv32r8elfaIYn7pLpQXps7X9oYNwC5XirhO8",
"https://rocketlabsqa.ovh/wp-content/rocket-test-data/images/fixtheissue.jpg",
"/wp-content/rocket-test-data/images/lcp/testjpeg.jpeg",
"/wp-content/rocket-test-data/images/lcp/testavif.avif",
"/test.png"
"/wp-content/rocket-test-data/images/lcp/testjpeg.jpeg"
],
"enabled": false
"enabled": true
},
"lcp_no_dimension_svg": {
"lcp": [
"/wp-content/rocket-test-data/images/lcp/testsvg.svg"
"https://discuss-assets.s3.amazonaws.com/original/3X/1/9/19823cc1f1f887d70755e0b500dd8ce2c51ba7f9.svg"
],
"viewport": [],
"enabled": false
Expand All @@ -143,30 +131,30 @@
"/wp-content/rocket-test-data/images/lcp/testavif.avif"
],
"viewport": [
"/wp-content/rocket-test-data/images/lcp/testjpg.jpg",
"/wp-content/rocket-test-data/images/lcp/testjpeg.jpeg",
"/test.png"
],
"enabled": true
},
"lcp_no_dimension_absolute_url": {
"lcp": [
"/wp-content/rocket-test-data/images/lcp/testjpg.jpg"
"/wp-content/rocket-test-data/images/lcp/testavif.avif"
],
"viewport": [
"/wp-content/rocket-test-data/images/lcp/testPng.png",
"https://cdn.pixabay.com/photo/2023/06/05/02/01/starry-sky-8041247_1280.jpg"
"/wp-content/rocket-test-data/images/lcp/testjpg.jpg"
],
"enabled": false
"enabled": true
},
"lcp_image_withspecialchar_template": {
"lcp": [
"/wp-content/rocket-test-data/images/lcp/image%20with%20space.jpg"
],
"viewport": [
"/wp-content/rocket-test-data/images/testspace%202.png",
"https://new.rocketlabsqa.ovh/wp-content/rocket-test-data/images/paperéquipesTest.jpeg"
"/wp-content/rocket-test-data/images/paper%C3%A9quipesTest.jpeg"
],
"enabled": false
"enabled": true
},
"lcp_img_addedbydynamicstyle_template": {
"lcp": [
Expand Down
2 changes: 1 addition & 1 deletion src/support/steps/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Given('I have an {word} account', { timeout: 60 * 1000 }, async function (status
* Executes the step to activate a specified WP plugin.
*/
Given('plugin {word} is activated', async function (plugin) {
await activatePlugin(plugin)
await activatePlugin(plugin)
});

/**
Expand Down
20 changes: 15 additions & 5 deletions utils/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ function wrapPrefix(command: string): string {
* @name wp
* @async
* @param {string} args - Arguments to be passed to the WP-CLI command.
* @returns {Promise<void>} - A Promise that resolves when the command is executed.
* @returns {Promise<string>} - A Promise that resolves when the command is executed.
*/
async function wp(args: string): Promise<void> {
async function wp(args: string): Promise<boolean> {
const root = configurations.type === ServerType.docker ? ' --allow-root': '';
const cwd = getWPDir(configurations);

Expand All @@ -53,8 +53,12 @@ async function wp(args: string): Promise<void> {
username: configurations.ssh.username,
privateKeyPath: configurations.ssh.key
})
const res = await client.execCommand(`wp ${args}${root} --path=${cwd}`);
return ;
const result = await client.execCommand(`wp ${args}${root} --path=${cwd}`);
if(result.code === 1) {
console.error('Error :', result.stderr);
return false
}
return true;
}
const command = wrapPrefix(`wp ${args}${root} --path=${cwd}`);

Expand Down Expand Up @@ -220,9 +224,15 @@ export async function rm(destination: string): Promise<void> {
* @returns {Promise<void>} - A Promise that resolves when the activation is completed.
*/
export async function activatePlugin(name: string): Promise<void> {
await wp(`plugin activate ${name}`)
await wp(`plugin activate ${name}`)
const status: boolean = await wp(`plugin is-active ${name}`);
if(!status) {
throw new Error(`Plugin - ${name} is not active`);
}
}



/**
* Install a WordPress plugin from a remote zip file using the WP-CLI command.
*
Expand Down

0 comments on commit 860160d

Please sign in to comment.