Skip to content

Commit 5808533

Browse files
authored
[Test] Fix up 'StringUtils' and 'SmokeTest' (#23656)
* Fix up 'getProjectNameFromGitUrl' method * Update 'SmokeTest' E2E test
1 parent 248e274 commit 5808533

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

tests/e2e/specs/SmokeTest.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ suite(`The SmokeTest userstory ${BASE_TEST_CONSTANTS.TEST_ENVIRONMENT}`, functio
2626
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
2727
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil);
2828
const factoryUrl: string =
29-
FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL ||
30-
'https://github.com/che-incubator/quarkus-api-example.git?policies.create=perclick';
29+
FACTORY_TEST_CONSTANTS.TS_SELENIUM_FACTORY_GIT_REPO_URL || 'https://github.com/che-incubator/quarkus-api-example.git?new';
3130
let projectSection: ViewSection;
3231
suite(`Create workspace from factory:${factoryUrl}`, function (): void {
3332
suiteSetup('Login', async function (): Promise<void> {

tests/e2e/utils/StringUtil.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,15 @@ export class StringUtil {
3434
url = url.split('?')[0].split('#')[0];
3535

3636
// remove branch/tree fragments for GitHub, GitLab, Bitbucket
37-
if (url.includes('/tree/') || url.includes('/-/tree/') || url.includes('/src/')) {
38-
url = url.split('/').slice(0, -2).join('/');
37+
if (url.includes('/-/tree/')) {
38+
// gitLab specific pattern: remove everything from /-/tree/ onwards
39+
url = url.substring(0, url.indexOf('/-/tree/'));
40+
} else if (url.includes('/tree/')) {
41+
// gitHub pattern: remove /tree/ and everything after it
42+
url = url.substring(0, url.indexOf('/tree/'));
43+
} else if (url.includes('/src/')) {
44+
// bitbucket pattern: remove /src/ and everything after it
45+
url = url.substring(0, url.indexOf('/src/'));
3946
}
4047

4148
const projectName: string = url

0 commit comments

Comments
 (0)