Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boost: Update e2e tests to account for lazy loading removal #33833

Merged
merged 6 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Updated e2e test to account for recent updates to the lazy loading module.
Original file line number Diff line number Diff line change
@@ -1,94 +1,23 @@
import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js';
import { JetpackBoostPage } from '../../lib/pages/index.js';
import { prerequisitesBuilder, isModuleActive } from 'jetpack-e2e-commons/env/prerequisites.js';
import { activateModules, deactivateModules } from 'jetpack-e2e-commons/env/index.js';
import {
boostPrerequisitesBuilder,
activateModules as activateBoostModules,
deactivateModules as deactivateBoostModules,
} from '../../lib/env/prerequisites.js';
import { prerequisitesBuilder } from 'jetpack-e2e-commons/env/prerequisites.js';
import { activateModules } from 'jetpack-e2e-commons/env/index.js';

test.describe( 'Jetpack compatibility', () => {
test.beforeAll( async () => {
await prerequisitesBuilder().withActivePlugins( [ 'jetpack' ] ).build();
} );

test( 'The Jetpack lazy-image module activation reflects in Boost dashboard', async ( {
test( 'The Jetpack lazy-image module can not be activated in Boost dashboard', async ( {
page,
} ) => {
await prerequisitesBuilder( page ).withInactiveModules( [ 'lazy-images' ] ).build();
await activateModules( [ 'lazy-images' ] );

dilirity marked this conversation as resolved.
Show resolved Hide resolved
const jetpackBoostPage = await JetpackBoostPage.visit( page );
expect(
await jetpackBoostPage.isModuleEnabled( 'lazy_images' ),
'lazy_images module should be enabled'
).toEqual( true );
} );

test( 'The Jetpack lazy-image module deactivation reflects in Boost dashboard', async ( {
page,
} ) => {
await prerequisitesBuilder( page ).withActiveModules( [ 'lazy-images' ] ).build();
await deactivateModules( [ 'lazy-images' ] );

const jetpackBoostPage = await JetpackBoostPage.visit( page );
expect(
await jetpackBoostPage.isModuleEnabled( 'lazy_images' ),
'lazy_images module should be disabled'
).toEqual( false );
} );

test( 'The Boost lazy-image module activation reflects in Jetpack dashboard', async ( {
page,
} ) => {
await boostPrerequisitesBuilder( page ).withInactiveModules( [ 'lazy_images' ] ).build();
await activateBoostModules( [ 'lazy_images' ] );

const isActive = await isModuleActive( 'lazy-images' );
expect( isActive, 'lazy-images module should be active' ).toBe( true );
} );

test( 'The Boost lazy-image module deactivation reflects in Jetpack dashboard', async ( {
page,
} ) => {
await boostPrerequisitesBuilder( page ).withActiveModules( [ 'lazy_images' ] ).build();
await deactivateBoostModules( [ 'lazy_images' ] );

const isActive = await isModuleActive( 'lazy-images' );
expect( isActive, 'lazy-images module should not be active' ).toBe( false );
} );

test( 'Lazy Image Toggle should work in Boost after using Jetpack dashboard to toogle lazy images.', async ( {
page,
} ) => {
const boostSlug = 'lazy_images';
const jetpackSlug = 'lazy-images';
await boostPrerequisitesBuilder( page )
.withConnection( true )
.withInactiveModules( [ boostSlug ] )
.build();

const jetpackBoostPage = await JetpackBoostPage.visit( page );

await boostPrerequisitesBuilder( page ).build();
await deactivateBoostModules( [ boostSlug ] );

// Turn on Lazy Images in Jetpack Boost via the UI
await jetpackBoostPage.toggleModule( boostSlug );

// Turn off Lazy Images with Jetpack
await deactivateModules( [ jetpackSlug ] );

// Turn on Lazy Images in Jetpack Boost via the UI
await jetpackBoostPage.reload();
await jetpackBoostPage.toggleModule( boostSlug );

await jetpackBoostPage.reload();
const isActiveInBoost = await jetpackBoostPage.isModuleEnabled( boostSlug );
const isActiveInJetpack = await isModuleActive( jetpackSlug );

expect( isActiveInBoost, 'lazy_images module should be active in Jetpack Boost' ).toBe( true );
expect( isActiveInJetpack, 'lazy-images module should be active in Jetpack' ).toBe( true );
} );
} );
10 changes: 0 additions & 10 deletions projects/plugins/boost/tests/e2e/specs/modules/lazy-images.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,4 @@ test.describe( 'Lazy Images module', () => {
'No images should be lazy loaded'
).toBe( 0 );
} );

test( 'Images on a post should be lazy loaded when the module is active', async () => {
await boostPrerequisitesBuilder( page ).withActiveModules( [ 'lazy_images' ] ).build();
const frontend = await PostFrontendPage.visit( page );
await frontend.click( `text=${ testPostTitle }` );
expect(
await page.locator( '.jetpack-lazy-image' ).count(),
'Images should be lazy loaded'
).toBeGreaterThan( 0 );
} );
} );
Loading