Update dependencies and refactor page navigation logic
* Added `@wdio/cli` as a development dependency for improved test command handling. * Refactored URL construction in the `Page` class to enhance clarity and maintainability. * Updated import statements in `Subscribing.page.ts` for consistency and removed unnecessary options in the constructor.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
"devDependencies": {
|
||||
"@eslint/js": "9.33.0",
|
||||
"@types/bun": "latest",
|
||||
"@wdio/cli": "9.19.1",
|
||||
"globals": "16.3.0",
|
||||
"typescript-eslint": "8.40.0"
|
||||
},
|
||||
|
||||
@@ -20,14 +20,28 @@ export default class Page {
|
||||
|
||||
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('')}`;
|
||||
|
||||
// Build the URL path properly
|
||||
let pageUrl = this._baseUrl;
|
||||
if (endpoint) {
|
||||
pageUrl += `/${endpoint}`;
|
||||
}
|
||||
if (requestPath) {
|
||||
pageUrl += `/${requestPath}`;
|
||||
}
|
||||
|
||||
// Add query parameters if they exist
|
||||
if (queryParameters && Object.keys(queryParameters).length > 0) {
|
||||
const queryString = Object.entries(queryParameters)
|
||||
.map(([queryParameterName, queryParameterValue]) => `${queryParameterName}=${queryParameterValue}`)
|
||||
.join('&');
|
||||
pageUrl += `?${queryString}`;
|
||||
}
|
||||
|
||||
if (isNewTabRequest) {
|
||||
await browser.newWindow(pageUrl);
|
||||
await (browser as any).newWindow(pageUrl);
|
||||
} else {
|
||||
await browser.url(pageUrl);
|
||||
await (browser as any).url(pageUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import Page, {PageOpenOptions} from './Page.ts';
|
||||
|
||||
export type SubscribingPageOptions = {};
|
||||
import {$} from '@wdio/globals';
|
||||
import Page, {PageOpenOptions} from './Page';
|
||||
|
||||
export class SubscribingPage extends Page {
|
||||
constructor(baseUri: string, options: SubscribingPageOptions) {
|
||||
super(baseUri, options);
|
||||
constructor(baseUri: string) {
|
||||
super(baseUri);
|
||||
}
|
||||
|
||||
get videoElement() {
|
||||
return $('video');
|
||||
}
|
||||
|
||||
public async open(options?: PageOpenOptions): Promise<void> {
|
||||
public override async open(options?: PageOpenOptions): Promise<void> {
|
||||
await super.open(options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from './Subscribing.page.ts';
|
||||
export * from './Subscribing.page';
|
||||
|
||||
Reference in New Issue
Block a user