-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Boost: Add e2e tests for Image Guide (#36716)
* Update Boost's CLI to include support for image guide module * Add e2e tests for image guide * Add Boost's image guide test configuration to e2e test matrix * add changelog
- Loading branch information
Showing
11 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: added | ||
Comment: Add e2e tests for Image Guide module. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
projects/plugins/boost/tests/e2e/lib/pages/frontend/FirstPostPage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import WpPage from 'jetpack-e2e-commons/pages/wp-page.js'; | ||
import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.js'; | ||
|
||
export default class FirstPostPage extends WpPage { | ||
constructor( page ) { | ||
const url = `${ resolveSiteUrl() }/?p=1`; | ||
super( page, { url } ); | ||
} | ||
|
||
async isImageGuideScriptPresent() { | ||
const selector = '#jetpack-boost-guide-js'; | ||
return ( await this.page.locator( selector ).count() ) > 0; | ||
} | ||
|
||
async isImageGuideAdminBarItemPresent() { | ||
const selector = '#wp-toolbar #jetpack-boost-guide-bar'; | ||
return ( await this.page.locator( selector ).count() ) > 0; | ||
} | ||
|
||
async isImageGuideUIPresent() { | ||
const selector = '.jetpack-boost-guide > .guide'; | ||
return this.waitForElementToBeVisible( selector, 5 * 1000 ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as JetpackBoostPage } from './wp-admin/JetpackBoostPage.js'; | ||
export { default as FirstPostPage } from './frontend/FirstPostPage.js'; |
Binary file added
BIN
+2.66 KB
projects/plugins/boost/tests/e2e/plugins/e2e-appended-image/assets/e2e-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
projects/plugins/boost/tests/e2e/plugins/e2e-appended-image/e2e-appended-image.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Boost E2E Appended image | ||
* Description: Appends an image at the end of posts' content. | ||
* Plugin URI: https://github.com/automattic/jetpack | ||
* Author: Heart of Gold | ||
* Version: 1.0.0 | ||
* Text Domain: jetpack | ||
* | ||
* @package automattic/jetpack | ||
*/ | ||
|
||
add_filter( | ||
'the_content', | ||
function ( $content ) { | ||
if ( is_single() ) { | ||
$content .= '<p><img id="e2e-test-image" src="' . plugins_url( 'assets/e2e-image.png', __FILE__ ) . '" /></p>'; | ||
} | ||
return $content; | ||
} | ||
); |
50 changes: 50 additions & 0 deletions
50
projects/plugins/boost/tests/e2e/specs/image-guide/image-guide.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; | ||
import { boostPrerequisitesBuilder } from '../../lib/env/prerequisites.js'; | ||
import { FirstPostPage } from '../../lib/pages/index.js'; | ||
import playwrightConfig from 'jetpack-e2e-commons/playwright.config.mjs'; | ||
|
||
test.describe( 'Image CDN', () => { | ||
let page; | ||
|
||
test.beforeAll( async ( { browser } ) => { | ||
page = await browser.newPage( playwrightConfig.use ); | ||
await boostPrerequisitesBuilder( page ).withCleanEnv( true ).withConnection( true ).build(); | ||
} ); | ||
|
||
test.afterAll( async () => {} ); | ||
|
||
test( 'Image Guide functionality shouldn`t be active when the module is inactive', async () => { | ||
await boostPrerequisitesBuilder( page ).withInactiveModules( [ 'image_guide' ] ).build(); | ||
const firstPostPage = await FirstPostPage.visit( page ); | ||
|
||
expect( | ||
await firstPostPage.isImageGuideScriptPresent(), | ||
'Image Guide script shouldn`t be present' | ||
).toBeFalsy(); | ||
} ); | ||
|
||
test( 'Image Guide functionality should be active when the module is active', async () => { | ||
await boostPrerequisitesBuilder( page ) | ||
.withActiveModules( [ 'image_guide' ] ) | ||
.withAppendedImage( true ) | ||
.build(); | ||
const firstPostPage = await FirstPostPage.visit( page ); | ||
|
||
expect( | ||
await firstPostPage.isImageGuideScriptPresent(), | ||
'Image Guide script should be present' | ||
).toBeTruthy(); | ||
|
||
expect( | ||
await firstPostPage.isImageGuideAdminBarItemPresent(), | ||
'Image Guide admin bar item should be present' | ||
).toBeTruthy(); | ||
|
||
console.log( await firstPostPage.isImageGuideUIPresent() ); | ||
|
||
expect( | ||
await firstPostPage.isImageGuideUIPresent(), | ||
'Image Guide UI item should be present' | ||
).toBeTruthy(); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters