@@ -19,10 +19,10 @@ import { ChromiumBrowser, chromium } from '@playwright/test';
1919import { Sections } from '../common/sections' ;
2020import { selectors as pluginSelectors } from "./../common/selectors" ;
2121import { PageUtils } from "../../utils/page-utils" ;
22- import { deleteFolder , isWprRelatedError } from "../../utils/helpers" ;
22+ import { deleteFolder , extractFromStdout , isWprRelatedError } from "../../utils/helpers" ;
2323import { WP_SSH_ROOT_DIR , } from "../../config/wp.config" ;
2424import { After , AfterAll , Before , BeforeAll , Status , setDefaultTimeout } from "@cucumber/cucumber" ;
25- import { rename , exists , rm , testSshConnection , installRemotePlugin , activatePlugin , uninstallPlugin , readFile , isPluginActive , isPluginInstalled } from "../../utils/commands" ;
25+ import { rename , exists , rm , testSshConnection , installRemotePlugin , activatePlugin , uninstallPlugin , readFile , isPluginActive , isPluginInstalled , getPostDataFromTitle } from "../../utils/commands" ;
2626import type { Selectors } from "../../utils/types" ;
2727import type { Section } from "../../utils/types" ;
2828// import {configurations, getWPDir} from "../../utils/configurations";
@@ -213,6 +213,25 @@ Before({tags: '@vr'}, async function (this: ICustomWorld) {
213213 this . wprOption = option ;
214214} ) ;
215215
216+ /**
217+ * Before each test scenario with the @performancehints tag, verifies required pages exist.
218+ */
219+ Before ( { tags : '@performancehints' } , async function ( this : ICustomWorld ) {
220+ const requiredPages = [ 'atf-lrc-1' , 'atf-lrc-2' ] ;
221+
222+ for ( const pageName of requiredPages ) {
223+ const pageDataStdout = await getPostDataFromTitle ( pageName , 'publish' , 'ID,post_status' ) ;
224+ const pageData = await extractFromStdout ( pageDataStdout ) ;
225+
226+ if ( ! pageData || pageData . length === 0 ) {
227+ throw new Error (
228+ `Required test page '${ pageName } ' does not exist. ` +
229+ `Template loader plugin may have failed.`
230+ ) ;
231+ }
232+ }
233+ } ) ;
234+
216235/**
217236 * After each test scenario, performs cleanup tasks and captures screenshots and videos in case of failure.
218237 */
0 commit comments