diff --git a/config/wp.config.sample.ts b/config/wp.config.sample.ts index 0c72d60..c0dc5f4 100755 --- a/config/wp.config.sample.ts +++ b/config/wp.config.sample.ts @@ -29,6 +29,7 @@ const WP_ADMIN_USER = { * WP_SSH_ADDRESS: string; * WP_SSH_KEY: string; * WP_SSH_ROOT_DIR: string; + * ENV_HEADLESS: string; * }} */ const { @@ -42,7 +43,8 @@ const { WP_SSH_USERNAME = '', WP_SSH_ADDRESS = '', WP_SSH_KEY = '', - WP_SSH_ROOT_DIR = '' + WP_SSH_ROOT_DIR = '', + ENV_HEADLESS = 'true' } = process.env; /** @@ -104,6 +106,7 @@ const SCENARIO_URLS = { * WP_SSH_ADDRESS: string; * WP_SSH_KEY: string; * WP_SSH_ROOT_DIR: string; + * ENV_HEADLESS: boolean; * SCENARIO_URLS: { * home: string; * llcss: string; @@ -124,5 +127,6 @@ export { WP_SSH_ADDRESS, WP_SSH_KEY, WP_SSH_ROOT_DIR, + ENV_HEADLESS, SCENARIO_URLS }; \ No newline at end of file diff --git a/healthcheck.ts b/healthcheck.ts index 4831081..6a0739f 100644 --- a/healthcheck.ts +++ b/healthcheck.ts @@ -1,7 +1,7 @@ import chalk from "chalk"; import wp from "./utils/commands"; import {PageUtils} from './utils/page-utils'; -import {WP_BASE_URL} from "./config/wp.config"; +import {WP_BASE_URL, ENV_HEADLESS,} from "./config/wp.config"; import {chromium as chrome, expect, Page} from '@playwright/test'; import {Sections} from "./src/common/sections"; import {selectors as pluginSelectors} from "./src/common/selectors"; @@ -36,13 +36,15 @@ async function setupBrowser(headless: boolean = false):Promise { } export async function openE2EPage(): Promise { - const page = await setupBrowser(false); + const isHeadless = ENV_HEADLESS === 'true'; + const page = await setupBrowser(isHeadless); await page.goto(WP_BASE_URL); } export async function auth(): Promise { - const page = await setupBrowser(false); + const isHeadless = ENV_HEADLESS === 'true'; + const page = await setupBrowser(isHeadless); const sections = new Sections(page, pluginSelectors); const utils = new PageUtils(page, sections); diff --git a/src/support/hooks.ts b/src/support/hooks.ts index 8e12671..8b1a675 100644 --- a/src/support/hooks.ts +++ b/src/support/hooks.ts @@ -22,7 +22,7 @@ import { PageUtils } from "../../utils/page-utils"; import { batchUpdateVRTestUrl } from "../../utils/helpers"; import { deleteFolder } from "../../utils/helpers"; import backstop from 'backstopjs'; -import {SCENARIO_URLS, WP_SSH_ROOT_DIR,} from "../../config/wp.config"; +import {SCENARIO_URLS, WP_SSH_ROOT_DIR, ENV_HEADLESS,} from "../../config/wp.config"; import { After, AfterAll, Before, BeforeAll, Status, setDefaultTimeout } from "@cucumber/cucumber"; import {rename, exists, rm, testSshConnection, installRemotePlugin, activatePlugin, uninstallPlugin} from "../../utils/commands"; @@ -56,7 +56,8 @@ BeforeAll(async function (this: ICustomWorld) { await rm(debugLogPath); await deleteFolder('./backstop_data/bitmaps_test'); - browser = await chromium.launch({ headless: false }); + const isHeadless = ENV_HEADLESS === 'true'; + browser = await chromium.launch({ headless: isHeadless }); const theme = process.env.THEME ? process.env.THEME : '';