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:
2025-08-18 21:55:30 -04:00
parent f3ecb8c35b
commit 1cf223fd85
4 changed files with 26 additions and 12 deletions

View File

@@ -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);
}
}
}