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: Add jetpack compatibility tests #22124

Merged
merged 9 commits into from
Dec 24, 2021
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Add Jetpack compatibility tests.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { test, expect } from '../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';

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

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

const jetpackBoostPage = await JetpackBoostPage.visit( page );
expect( await jetpackBoostPage.isModuleEnabled( 'lazy-images' ) ).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' ) ).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 ).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 ).toBe( false );
} );
} );
6 changes: 6 additions & 0 deletions tools/e2e-commons/env/prerequisites.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ export async function deactivateModules( modulesList ) {
}
}

export async function isModuleActive( module ) {
logger.prerequisites( `Checking if ${ module } module is active` );
const result = await execWpCommand( `jetpack options get active_modules` );
return result.includes( module );
}

export async function ensurePluginsState( plugins ) {
if ( ! isLocalSite() ) {
logger.prerequisites( 'Site is not local, skipping plugins setup.' );
Expand Down