From 1cf223fd85220baeae1829e371c0b48fc64aa711 Mon Sep 17 00:00:00 2001 From: Alexander Zinn Date: Mon, 18 Aug 2025 21:55:30 -0400 Subject: [PATCH] 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. --- package.json | 1 + test/pages/Page.ts | 24 +++++++++++++++++++----- test/pages/Subscribing.page.ts | 11 +++++------ test/pages/index.ts | 2 +- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index ff89ef6..8b41453 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/test/pages/Page.ts b/test/pages/Page.ts index 0474cb4..8ee97f2 100644 --- a/test/pages/Page.ts +++ b/test/pages/Page.ts @@ -20,14 +20,28 @@ export default class Page { public async open(options: PageOpenOptions = {}): Promise { 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); } } } diff --git a/test/pages/Subscribing.page.ts b/test/pages/Subscribing.page.ts index 8ce9313..3fa7e41 100644 --- a/test/pages/Subscribing.page.ts +++ b/test/pages/Subscribing.page.ts @@ -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 { + public override async open(options?: PageOpenOptions): Promise { await super.open(options); } } diff --git a/test/pages/index.ts b/test/pages/index.ts index 600200c..fb0beaf 100644 --- a/test/pages/index.ts +++ b/test/pages/index.ts @@ -1 +1 @@ -export * from './Subscribing.page.ts'; +export * from './Subscribing.page';