Skip to content

Commit

Permalink
Merge branch 'enhancement/167-failing-test-when-run-globally' into fi…
Browse files Browse the repository at this point in the history
…x/176-error-with-backstop-test-for-llcssbg-and-lrc
  • Loading branch information
jeawhanlee committed Nov 28, 2024
2 parents 583bf3d + aa3d206 commit 0095d97
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
3 changes: 0 additions & 3 deletions backstop_data/engine_scripts/mobileMenuThemeSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ module.exports = async (page) => {
}

switch (theme) {
case 'genesis-sample-develop':
target = '#genesis-mobile-nav-primary';
break;
case 'flatsome':
target = '[data-open="#main-menu"]';
break;
Expand Down
3 changes: 1 addition & 2 deletions src/features/delay-js.feature
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ Feature: No Regression with delayjs script udpate
| theme |
| astra |
| Divi |
| flatsome |
| genesis-sample-develop |
| flatsome |
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
5 changes: 1 addition & 4 deletions src/support/steps/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Given('activate {string} plugin', async function (this: ICustomWorld, plugin) {
* Executes the step to activate a theme.
*/
Given('theme {string} is activated', async function (this:ICustomWorld, theme) {
await this.utils.switchTheme(theme);
await this.utils.switchThemeViaUi(theme);

// Check tags via pickle.
if (! await isTagPresent(this.pickle, '@delayjs')) {
Expand Down Expand Up @@ -246,9 +246,6 @@ When('expand mobile menu', async function (this:ICustomWorld) {
}

switch (theme) {
case 'genesis-sample-develop':
target = '#genesis-mobile-nav-primary';
break;
case 'flatsome':
target = '[data-open="#main-menu"]';
break;
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 switchTheme
* @async
* @param {string} theme - The theme to activate.
* @returns {Promise<void>} - A Promise that resolves when the theme is activated.
*/
export async function switchTheme(theme: string): Promise<void> {
await wp(`theme activate ${theme}`);
}

/**
* Executes a SQL query on the WordPress database using WP-CLI.
*
Expand Down
7 changes: 5 additions & 2 deletions 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, switchTheme } 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 switchTheme('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 Expand Up @@ -667,7 +670,7 @@ export class PageUtils {
*
* @return {Promise<void>}
*/
public async switchTheme(theme: string): Promise<void> {
public async switchThemeViaUi(theme: string): Promise<void> {
await this.visitPage('wp-admin/themes.php');
await this.page.locator('#wp-filter-search-input').fill(theme);
// Wait for filtered theme to be displayed.
Expand Down

0 comments on commit 0095d97

Please sign in to comment.