-
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 tests for Image CDN (#36694)
* Add tests for Image CDN * Add Boost's image cdn test configuration to e2e test matrix * add changelog * Remove e2e helper plugin
- Loading branch information
1 parent
66f1382
commit ca3e607
Showing
5 changed files
with
82 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: added | ||
Comment: Add e2e tests for Image CDN. | ||
|
||
|
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
63 changes: 63 additions & 0 deletions
63
projects/plugins/boost/tests/e2e/specs/image-cdn/image-cdn.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,63 @@ | ||
import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; | ||
import { boostPrerequisitesBuilder } from '../../lib/env/prerequisites.js'; | ||
import { JetpackBoostPage, 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( 'No Image CDN meta information should show on the admin when the module is inactive', async () => { | ||
await boostPrerequisitesBuilder( page ).withInactiveModules( [ 'image_cdn' ] ).build(); | ||
const jetpackBoostPage = await JetpackBoostPage.visit( page ); | ||
|
||
expect( | ||
await jetpackBoostPage.isImageCdnUpgradeSectionVisible(), | ||
'Image CDN upgrade section should not be visible' | ||
).toBeFalsy(); | ||
} ); | ||
|
||
test( 'Image CDN functionality shouldn`t be active when the module is inactive', async () => { | ||
await boostPrerequisitesBuilder( page ) | ||
.withInactiveModules( [ 'image_cdn' ] ) | ||
.withAppendedImage( true ) | ||
.build(); | ||
const firstPostPage = await FirstPostPage.visit( page ); | ||
|
||
expect( | ||
// The image is added via a helper plugin. | ||
await firstPostPage.page.locator( '[id="e2e-test-image"]' ).getAttribute( 'src' ), | ||
'Image shouldn`t use CDN' | ||
).not.toMatch( /https:\/\/.*\.wp\.com/ ); | ||
} ); | ||
|
||
test( 'Upgrade section should be visible when the module is active', async () => { | ||
await boostPrerequisitesBuilder( page ).withActiveModules( [ 'image_cdn' ] ).build(); | ||
const jetpackBoostPage = await JetpackBoostPage.visit( page ); | ||
|
||
expect( | ||
await jetpackBoostPage.isImageCdnUpgradeSectionVisible(), | ||
'Image CDN upgrade section should be visible' | ||
).toBeTruthy(); | ||
} ); | ||
|
||
test( 'Image should be loaded via CDN when Image CDN is active', async () => { | ||
await boostPrerequisitesBuilder( page ) | ||
.withActiveModules( [ 'image_cdn' ] ) | ||
.withAppendedImage( true ) | ||
.build(); | ||
const firstPostPage = await FirstPostPage.visit( page ); | ||
|
||
expect( | ||
// The image is added via a helper plugin. | ||
await firstPostPage.page.locator( '[id="e2e-test-image"]' ).getAttribute( 'src' ), | ||
'Image should use CDN' | ||
).toMatch( /https:\/\/.*\.wp\.com/ ); | ||
} ); | ||
} ); |