This commit is contained in:
2025-08-18 21:51:28 -04:00
parent 1eb0637d38
commit f3ecb8c35b
19 changed files with 179 additions and 646 deletions

View File

@@ -1,33 +1,33 @@
import {browser} from '@wdio/globals';
import {browser} from '@wdio/globals';
export type PageOptions = {
browser?: typeof browser; // MultiRemote usecase
};
export type PageOptions = {
browser?: typeof browser; // MultiRemote usecase
export type PageOpenOptions = {
queryParameters?: Record<string, string | number>;
isNewTabRequest?: boolean;
endpoint?: string;
requestPath?: string;
};
}
export default class Page {
private readonly _baseUrl: string;
export type PageOpenOptions = {
queryParameters?: Record<string, string | number>;
isNewTabRequest?: boolean;
endpoint?: string;
requestPath?: string;
};
export default class Page {
private readonly _baseUrl: string;
constructor(baseUrl: string) {
constructor(baseUrl: string) {
this._baseUrl = baseUrl;
}
public async open(options: PageOpenOptions = {}): Promise<void> {
public async open(options: PageOpenOptions = {}): Promise<void> {
const {queryParameters, isNewTabRequest, endpoint, requestPath} = options;
const pageUrl = `${this._baseUrl}/${endpoint}${requestPath}?${Object.entries(queryParameters ?? {}).map(([queryParameterName, queryParamterValue]) => (`${queryParameterName}=${queryParamterValue}&`)).join('')}`;
const pageUrl = `${this._baseUrl}/${endpoint}${requestPath}?${Object.entries(queryParameters ?? {})
.map(([queryParameterName, queryParamterValue]) => `${queryParameterName}=${queryParamterValue}&`)
.join('')}`;
if (isNewTabRequest) {
await browser.newWindow(pageUrl);
} else {
await browser.url(pageUrl);
}
} else {
await browser.url(pageUrl);
}
}
}

View File

@@ -1,6 +1,6 @@
import Page, { PageOpenOptions } from './Page.ts';
import Page, {PageOpenOptions} from './Page.ts';
export type SubscribingPageOptions = { };
export type SubscribingPageOptions = {};
export class SubscribingPage extends Page {
constructor(baseUri: string, options: SubscribingPageOptions) {
@@ -12,7 +12,6 @@ export class SubscribingPage extends Page {
}
public async open(options?: PageOpenOptions): Promise<void> {
await super.open(options);
await super.open(options);
}
}