diff --git a/src/features/ll-lcp.feature b/src/features/ll-lcp.feature index 78be984..8257a00 100644 --- a/src/features/ll-lcp.feature +++ b/src/features/ll-lcp.feature @@ -3,8 +3,9 @@ Feature: Lazyload with LCP Background: Given I am logged in + And delete 'wp-rocket' plugin And plugin is installed 'new_release' - And plugin is activated + And plugin 'wp-rocket' is activated When I go to 'wp-admin/options-general.php?page=wprocket#dashboard' And I save settings 'media' 'lazyloadCssBgImg' diff --git a/src/support/steps/general.ts b/src/support/steps/general.ts index bde5458..9939ace 100644 --- a/src/support/steps/general.ts +++ b/src/support/steps/general.ts @@ -19,7 +19,7 @@ import { createReference, compareReference } from "../../../utils/helpers"; import type { Section } from "../../../utils/types"; import { Page } from '@playwright/test'; import { - deactivatePlugin, installRemotePlugin, + deactivatePlugin, deletePlugin, installRemotePlugin, } from "../../../utils/commands"; /** * Executes the step to log in. @@ -93,6 +93,13 @@ Given('activate {string} plugin', async function (this: ICustomWorld, plugin) { await this.utils.togglePluginActivation(plugin); }); +/** + * Executes the step to delete a WP plugin. + */ +Given('delete {string} plugin', async function (this: ICustomWorld, plugin) { + await deletePlugin(plugin) +}); + /** * Executes the step to log in. */ diff --git a/utils/commands.ts b/utils/commands.ts index 91c9ac3..b503a67 100644 --- a/utils/commands.ts +++ b/utils/commands.ts @@ -230,7 +230,7 @@ export async function rm(destination: string): Promise { */ export async function activatePlugin(name: string): Promise { await wp(`plugin activate ${name}`) - const status: boolean = await wp(`plugin is-active ${name}`);console.log(status) + const status: boolean = await wp(`plugin is-active ${name}`); if(!status) { throw new Error(`Plugin - ${name} is not active`); } @@ -239,7 +239,7 @@ export async function activatePlugin(name: string): Promise { /** * Check if plugin is installed * @function - * @name activatePlugin + * @name isPluginInstalled * @async * @param {string} name - The name of the plugin to be checked if installed. * @returns {Promise} - A Promise that resolves when the check is completed. @@ -248,6 +248,17 @@ export async function isPluginInstalled(name: string): Promise { return await wp(`plugin is-installed ${name}`, false); } +/** + * Delete a plugin if exist + * @function + * @name deletePlugin + * @async + * @param {string} name - The name of the plugin to be deleted if installed. + * @returns {Promise} - A Promise that resolves when the check is completed. + */ +export async function deletePlugin(name: string): Promise { + return await wp(`plugin delete ${name}`, false); +} /** * Install a WordPress plugin from a remote zip file using the WP-CLI command.