Skip to content

Commit

Permalink
Install required packages for testing inside the worfklow rather than…
Browse files Browse the repository at this point in the history
… as prerequisites.
  • Loading branch information
davidlonjon committed Dec 3, 2021
1 parent e4f163e commit fee8d30
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/e2e-tests-boost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ jobs:
pnpm install
pnpx jetpack build plugins/jetpack -v --production
pnpx jetpack build plugins/boost -v --production
pnpx jetpack build packages/lazy-images -v --production
pnpx jetpack build packages/jitm -v --production
- name: Environment set-up
working-directory: projects/plugins/boost/tests/e2e
Expand Down
15 changes: 1 addition & 14 deletions projects/plugins/boost/tests/e2e/lib/env/prerequisites.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logger from 'jetpack-e2e-commons/logger.cjs';
import { execWpCommand, buildPackage } from 'jetpack-e2e-commons/helpers/utils-helper.cjs';
import { execWpCommand } from 'jetpack-e2e-commons/helpers/utils-helper.cjs';

import { expect } from '@playwright/test';
import { JetpackBoostPage } from '../pages/index.js';
Expand All @@ -9,7 +9,6 @@ export function boostPrerequisitesBuilder( page ) {
testPostTitles: [],
clean: undefined,
modules: { active: undefined, inactive: undefined },
packages: [],
connected: undefined,
jetpackDeactivated: undefined,
};
Expand All @@ -23,10 +22,6 @@ export function boostPrerequisitesBuilder( page ) {
state.modules.inactive = modules;
return this;
},
withPackages( packages = [] ) {
state.packages = packages;
return this;
},
withConnection( shouldBeConnected ) {
state.connected = shouldBeConnected;
return this;
Expand All @@ -48,7 +43,6 @@ export function boostPrerequisitesBuilder( page ) {
async function buildPrerequisites( state, page ) {
const functions = {
modules: () => ensureModulesState( state.modules ),
packages: () => ensurePackages( state.packages ),
connected: () => ensureConnectedState( state.connected, page ),
testPostTitles: () => ensureTestPosts( state.testPostTitles ),
clean: () => ensureCleanState( state.clean ),
Expand Down Expand Up @@ -97,13 +91,6 @@ export async function deactivateModules( modules ) {
}
}

export async function ensurePackages( packages ) {
for ( const jetpackPackage of packages ) {
logger.prerequisites( `Installing package ${ jetpackPackage }` );
await buildPackage( jetpackPackage );
}
}

export async function ensureConnectedState( requiredConnected = undefined, page ) {
const isConnected = await checkIfConnected();

Expand Down
2 changes: 1 addition & 1 deletion projects/plugins/boost/tests/e2e/lib/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export default async function () {
const browser = await chromium.launch();
const page = await browser.newPage();
await prerequisitesBuilder( page ).withLoggedIn( true ).build();
await boostPrerequisitesBuilder( page ).withPackages( [ 'jitm' ] ).withConnection( true ).build();
await boostPrerequisitesBuilder( page ).withConnection( true ).build();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ test.describe.serial( 'Lazy Images module', () => {

test.beforeAll( async ( { browser } ) => {
page = await browser.newPage();
await boostPrerequisitesBuilder( page )
.withTestContent( [ testPostTitle ] )
.withPackages( [ 'lazy-images' ] )
.build();
await boostPrerequisitesBuilder( page ).withTestContent( [ testPostTitle ] ).build();
await execWpCommand( 'user session destroy wordpress --all' );
} );

Expand Down
6 changes: 0 additions & 6 deletions tools/e2e-commons/helpers/utils-helper.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,6 @@ async function getJetpackVersion() {
return version;
}

async function buildPackage( jetpackPackage ) {
const cmd = `pnpx jetpack build packages/${ jetpackPackage } -v --production`;
await execShellCommand( cmd );
}

module.exports = {
execShellCommand,
execSyncShellCommand,
Expand All @@ -360,5 +355,4 @@ module.exports = {
getMailchimpCredentials,
logEnvironment,
getJetpackVersion,
buildPackage,
};

0 comments on commit fee8d30

Please sign in to comment.