Skip to content

Commit

Permalink
:feat: Review modifications --#103
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Jun 7, 2024
1 parent ba2f8ba commit f196ccf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/features/lcp-beacon-script.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Feature: Beacon script captures the right images.
Scenario: Beacon captures expected images in mobile
Given I install plugin 'https://github.com/wp-media/wp-rocket-e2e-test-helper/raw/main/helper-plugin/force-wp-mobile.zip'
And plugin 'force-wp-mobile' is activated
And plugin 'force-wp-mobile' is-active
When I log out
And I visit the urls for 'mobile'
And plugin 'force-wp-mobile' is deactivated
Expand Down
9 changes: 1 addition & 8 deletions src/support/steps/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import {expect} from "@playwright/test";
import {AfterAll, BeforeAll} from "@cucumber/cucumber";
import wp, {
activatePlugin, checkPluginStatus,
activatePlugin,
cp,
generateUsers,
resetWP,
Expand Down Expand Up @@ -66,13 +66,6 @@ Given('plugin {word} is activated', async function (plugin) {
await activatePlugin(plugin)
});

/**
* Check if a plugin is active.
*/
Given('plugin {word} is-active', async function (plugin) {
await checkPluginStatus(plugin)
});

/**
* Executes the step to assert the visibility of a banner with specific text.
*/
Expand Down
16 changes: 3 additions & 13 deletions utils/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,25 +224,15 @@ export async function rm(destination: string): Promise<void> {
* @returns {Promise<void>} - A Promise that resolves when the activation is completed.
*/
export async function activatePlugin(name: string): Promise<void> {
await wp(`plugin activate ${name}`)
}

/**
* Check if a WordPress plugin is active using the WP-CLI command.
*
* @function
* @name checkPluginStatus
* @async
* @param {string} name - The name of the plugin to check.
* @returns {Promise<void>} - A Promise that resolves when the activation is completed.
*/
export async function checkPluginStatus(name: string): Promise<void> {
await wp(`plugin activate ${name}`)
const status: boolean = await wp(`plugin is-active ${name}`);
if(!status) {
throw new Error('Plugin is not active')
}
}



/**
* Install a WordPress plugin from a remote zip file using the WP-CLI command.
*
Expand Down

0 comments on commit f196ccf

Please sign in to comment.