Skip to content

Commit

Permalink
Fixes #173 Adds to clean-up the switch theme via WP CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
hanna-meda committed Nov 25, 2024
1 parent 80bde4e commit fabb47a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/features/performance-hints.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Feature: Clear lcp/performance hints data tests
Given performance hints data added to DB
And switching the theme
Then data is removed from the performance hints tables
Then theme 'Twenty Twenty' is activated

Scenario: Should clear performance hints of the current URL
Given I log out
Expand Down
13 changes: 13 additions & 0 deletions utils/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,19 @@ export async function updatePermalinkStructure(structure: string): Promise<void>
await wp(`option update permalink_structure ${structure}`);
}

/**
* Switch Theme.
*
* @function
* @name switchToDefaultTheme
* @async
* @param {string} theme - The theme to activate.
* @returns {Promise<void>} - A Promise that resolves when the theme is activated.
*/
export async function switchToDefaultTheme(theme: string): Promise<void> {
await wp(`theme activate ${theme}`);
}

/**
* Executes a SQL query on the WordPress database using WP-CLI.
*
Expand Down
5 changes: 4 additions & 1 deletion utils/page-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ICustomWorld } from '../src/common/custom-world';
import fs from "fs/promises";

import {WP_BASE_URL, WP_PASSWORD, WP_USERNAME} from '../config/wp.config';
import { uninstallPlugin, updatePermalinkStructure, deactivatePlugin } from "./commands";
import { uninstallPlugin, updatePermalinkStructure, deactivatePlugin, switchToDefaultTheme } from "./commands";

/**
* Utility class for interacting with a Playwright Page instance in WordPress testing.
Expand Down Expand Up @@ -583,6 +583,9 @@ export class PageUtils {
// Reset permalink structure.
await updatePermalinkStructure('/%postname%/');

// Switch to "Twenty Twenty" theme.
await switchToDefaultTheme('twentytwenty');

// Remove WP Rocket from UI if on local run is explicitly parsed.
if ( process.env.npm_config_env !== undefined && process.env.npm_config_env === 'local' ) {
// Start the process to remove wp-rocket.
Expand Down

0 comments on commit fabb47a

Please sign in to comment.