Compare commits
2 Commits
f3ecb8c35b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e93eb5fe84 | |||
| 1cf223fd85 |
@@ -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"
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import SupportedBrowser from './SupportedBrowser';
|
||||
import type {SupportedBrowser} from './SupportedBrowser';
|
||||
|
||||
// Source: https://github.com/browserstack/api
|
||||
|
||||
@@ -10,13 +10,15 @@ export class BrowserstackApi {
|
||||
this._authorizationHeader = `Basic ${Buffer.from(`${username}:${accessKey}`).toString('base64')}`;
|
||||
}
|
||||
|
||||
public async getSupportedBrowsers(): Promise<SupportedBrowser[]> {
|
||||
const endpoint = `${this._baseUrl}/browsers?flat=true`;
|
||||
public async getListOfSupportedBrowsers(): Promise<SupportedBrowser[]> {
|
||||
const requestPath = `${this._baseUrl}/browsers?flat=true`;
|
||||
const headers = {
|
||||
Authorization: this._authorizationHeader
|
||||
Authorization: this._authorizationHeader,
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json'
|
||||
};
|
||||
|
||||
const response = await fetch(endpoint, {headers});
|
||||
const response = await fetch(requestPath, {headers});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch BrowserStack supported browsers due to [${response.statusText}]`);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
type SupportedBrowser = {
|
||||
export type SupportedBrowser = {
|
||||
os: string;
|
||||
os_version: string;
|
||||
browser: string;
|
||||
@@ -6,5 +6,3 @@ type SupportedBrowser = {
|
||||
browser_version: string | null;
|
||||
real_mobile: boolean;
|
||||
};
|
||||
|
||||
export default SupportedBrowser;
|
||||
|
||||
@@ -37,6 +37,11 @@ export default class CommandLine {
|
||||
// Convert the string log level back to LoggingLevel enum
|
||||
const logLevel = rawOptions.logLevel ? LoggingLevelMapping.convertLoggingLevelTypeToLoggingLevel(rawOptions.logLevel) : defaultLogLevel;
|
||||
|
||||
// Validate required options are present
|
||||
if (!rawOptions.applicationId || !rawOptions.secret || !rawOptions.pcastUri || !rawOptions.channelUri) {
|
||||
throw new Error('Missing required command line options: applicationId, secret, pcastUri, and channelUri are required');
|
||||
}
|
||||
|
||||
return {
|
||||
...rawOptions,
|
||||
logLevel
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type {CommandLineOptions} from './CommandLine';
|
||||
import {LoggingLevel} from '../logger/LoggingLevel';
|
||||
|
||||
type ApplicationCredentials = {
|
||||
applicationId: string;
|
||||
@@ -26,6 +27,7 @@ export default class TestConfiguration {
|
||||
private readonly _publishers: string[];
|
||||
private readonly _tests: string[];
|
||||
private readonly _browserstack: BrowserstackConfiguration;
|
||||
private readonly _logLevel: LoggingLevel;
|
||||
|
||||
constructor(commandLineOptions: CommandLineOptions) {
|
||||
this._applicationCredentials = {
|
||||
@@ -43,6 +45,7 @@ export default class TestConfiguration {
|
||||
this._viewers = commandLineOptions.viewers;
|
||||
this._publishers = commandLineOptions.publishers;
|
||||
this._tests = commandLineOptions.tests;
|
||||
this._logLevel = commandLineOptions.logLevel;
|
||||
this._browserstack = {
|
||||
enabled: commandLineOptions.useBrowserstack,
|
||||
local: commandLineOptions.useBrowserstackLocal,
|
||||
@@ -74,4 +77,8 @@ export default class TestConfiguration {
|
||||
get browserstack(): BrowserstackConfiguration {
|
||||
return this._browserstack;
|
||||
}
|
||||
|
||||
get logLevel(): LoggingLevel {
|
||||
return this._logLevel;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +1,44 @@
|
||||
import {browser} from '@wdio/globals';
|
||||
import {browser as wdio} from '@wdio/globals';
|
||||
|
||||
export type PageOptions = {
|
||||
browser?: typeof browser; // MultiRemote usecase
|
||||
browser?: typeof wdio; // MultiRemote usecase
|
||||
};
|
||||
|
||||
export type PageOpenOptions = {
|
||||
queryParameters?: Record<string, string | number>;
|
||||
isNewTabRequest?: boolean;
|
||||
endpoint?: string;
|
||||
requestPath?: string;
|
||||
};
|
||||
|
||||
export default class Page {
|
||||
private readonly _baseUrl: string;
|
||||
private readonly _browser: typeof wdio;
|
||||
|
||||
constructor(baseUrl: string) {
|
||||
constructor(baseUrl: string, browser: typeof wdio) {
|
||||
this._baseUrl = baseUrl;
|
||||
this._browser = browser;
|
||||
}
|
||||
|
||||
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 {queryParameters, isNewTabRequest, requestPath} = options;
|
||||
|
||||
let pageUrl = this._baseUrl;
|
||||
|
||||
if (requestPath) {
|
||||
pageUrl += `/${requestPath}`;
|
||||
}
|
||||
|
||||
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 (this._browser as any).newWindow(pageUrl);
|
||||
} else {
|
||||
await browser.url(pageUrl);
|
||||
await (this._browser as any).url(pageUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import Page, {PageOpenOptions} from './Page.ts';
|
||||
|
||||
export type SubscribingPageOptions = {};
|
||||
import {browser as wdio, $} from '@wdio/globals';
|
||||
import Page, {PageOpenOptions} from './Page';
|
||||
|
||||
export class SubscribingPage extends Page {
|
||||
constructor(baseUri: string, options: SubscribingPageOptions) {
|
||||
super(baseUri, options);
|
||||
constructor(baseUri: string, browser: typeof wdio) {
|
||||
super(baseUri, browser);
|
||||
}
|
||||
|
||||
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