Skip to content

Commit

Permalink
Closes #146: Adds headless config
Browse files Browse the repository at this point in the history
  • Loading branch information
Miraeld committed Sep 19, 2024
1 parent 704cdd4 commit 3479b6d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 5 additions & 1 deletion config/wp.config.sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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;
Expand All @@ -124,5 +127,6 @@ export {
WP_SSH_ADDRESS,
WP_SSH_KEY,
WP_SSH_ROOT_DIR,
ENV_HEADLESS,
SCENARIO_URLS
};
8 changes: 5 additions & 3 deletions healthcheck.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -36,13 +36,15 @@ async function setupBrowser(headless: boolean = false):Promise<Page> {
}

export async function openE2EPage(): Promise<void> {
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<void> {
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);

Expand Down
5 changes: 3 additions & 2 deletions src/support/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 : '';

Expand Down

0 comments on commit 3479b6d

Please sign in to comment.