Skip to content

Commit

Permalink
Add new cli step to delete plugin to avoid conflict :closes: #129
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Sep 20, 2024
1 parent 221ea39 commit dcbd67a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/features/ll-lcp.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
9 changes: 8 additions & 1 deletion src/support/steps/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*/
Expand Down
15 changes: 13 additions & 2 deletions utils/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export async function rm(destination: string): Promise<void> {
*/
export async function activatePlugin(name: string): Promise<void> {
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`);
}
Expand All @@ -239,7 +239,7 @@ export async function activatePlugin(name: string): Promise<void> {
/**
* 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<boolean>} - A Promise that resolves when the check is completed.
Expand All @@ -248,6 +248,17 @@ export async function isPluginInstalled(name: string): Promise<boolean> {
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<boolean>} - A Promise that resolves when the check is completed.
*/
export async function deletePlugin(name: string): Promise<boolean> {
return await wp(`plugin delete ${name}`, false);
}

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

0 comments on commit dcbd67a

Please sign in to comment.