Skip to content

Commit

Permalink
refactor(test): getServerUrl to handle different base URL formats
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Szuc <[email protected]>
  • Loading branch information
martinszuc committed Nov 8, 2024
1 parent c875c46 commit f6af61e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,20 @@ export class KubernetesCommandLineToolsExecutor implements IKubernetesCommandLin

getServerUrl(): string {
Logger.debug(`${this.kubernetesCommandLineTool} - get server api url.`);
const baseUrl = new URL(BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL);

Check failure on line 205 in tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts

View workflow job for this annotation

GitHub Actions / pr-check

Expected baseUrl to have a type annotation
let apiHostname: string;

return BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443';
if (baseUrl.hostname.includes('devspaces.apps')) {
apiHostname = baseUrl.hostname.replace('devspaces.apps', 'api');
} else if (baseUrl.hostname.includes('console-openshift-console.apps')) {
apiHostname = baseUrl.hostname.replace('console-openshift-console.apps', 'api');
} else {
throw new Error(`Unexpected base URL hostname format: ${baseUrl.hostname}`);
}

const apiUrl = `https://${apiHostname}:6443`;

Check failure on line 216 in tests/e2e/utils/KubernetesCommandLineToolsExecutor.ts

View workflow job for this annotation

GitHub Actions / pr-check

Expected apiUrl to have a type annotation
Logger.debug(`Generated API server URL: ${apiUrl}`);
return apiUrl;
}
}

Expand Down

0 comments on commit f6af61e

Please sign in to comment.