Skip to content

Commit e4e9400

Browse files
authored
[Test] Fix up E2E tests according to starting duplicate workspaces (#23611)
* Update 'Factory' test * Remove unnecessary variables * Update 'getProjectNameFromGitUrl' method
1 parent 22de7db commit e4e9400

File tree

6 files changed

+35
-52
lines changed

6 files changed

+35
-52
lines changed

tests/e2e/constants/BASE_TEST_CONSTANTS.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ export const BASE_TEST_CONSTANTS: {
1616
OCP_INFRA: string;
1717
DELETE_WORKSPACE_ON_FAILED_TEST: boolean;
1818
DELETE_WORKSPACE_ON_SUCCESSFUL_TEST: boolean;
19-
SELECT_OPENING_EXISTING_WORKSPACE_INSTEAD_OF_CREATION_NEW: boolean;
20-
SELECT_CREATING_NEW_WORKSPACE: boolean;
2119
IS_CLUSTER_DISCONNECTED: () => boolean;
2220
IS_PRODUCT_DOCUMENTATION_RELEASED: any;
2321
OCP_VERSION: string;
@@ -139,19 +137,6 @@ export const BASE_TEST_CONSTANTS: {
139137
*/
140138
DELETE_WORKSPACE_ON_SUCCESSFUL_TEST: process.env.DELETE_WORKSPACE_ON_SUCCESSFUL_TEST !== 'false',
141139

142-
/**
143-
* select opening an existing workspace instead of creating a new one, if a duplicate workspace is created from the factory or sample list.
144-
* this option is false by default.
145-
*/
146-
SELECT_OPENING_EXISTING_WORKSPACE_INSTEAD_OF_CREATION_NEW:
147-
process.env.SELECT_OPENING_EXISTING_WORKSPACE_INSTEAD_OF_CREATION_NEW === 'true',
148-
149-
/**
150-
* select creation of a new workspace, if a duplicate workspace is created from the factory or sample list.
151-
* this option is false by default.
152-
*/
153-
SELECT_CREATING_NEW_WORKSPACE: process.env.SELECT_CREATING_NEW_WORKSPACE === 'true',
154-
155140
/**
156141
* constant, which prolong timeout constants for local debug.
157142
*/

tests/e2e/constants/FACTORY_TEST_CONSTANTS.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** *******************************************************************
2-
* copyright (c) 2020-2023 Red Hat, Inc.
2+
* copyright (c) 2020-2025 Red Hat, Inc.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -74,8 +74,7 @@ export const FACTORY_TEST_CONSTANTS: {
7474
*/
7575
TS_SELENIUM_FACTORY_URL(): string {
7676
return (
77-
process.env.TS_SELENIUM_FACTORY_URL ||
78-
BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL + '/dashboard/#/' + this.TS_SELENIUM_FACTORY_GIT_REPO_URL
77+
process.env.TS_SELENIUM_FACTORY_URL || BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL + '/#/' + this.TS_SELENIUM_FACTORY_GIT_REPO_URL
7978
);
8079
}
8180
};

tests/e2e/specs/SmokeTest.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** *******************************************************************
2-
* copyright (c) 2023 Red Hat, Inc.
2+
* copyright (c) 2023-2025 Red Hat, Inc.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0

tests/e2e/specs/dashboard-samples/RecommendedExtensions.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ for (const sample of samples) {
253253
let extensionSection: ExtensionsViewSection;
254254
let extensionsView: SideBarView | undefined;
255255
let publisherNames: string[];
256-
let skipSuite: boolean = false;
256+
const skipSuite: boolean = false;
257257

258258
const [pathToExtensionsListFileName, extensionsListFileName]: string[] = ['.vscode', 'extensions.json'];
259259

tests/e2e/specs/factory/Factory.spec.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,6 @@ suite(
7878
});
7979
}
8080

81-
if (BASE_TEST_CONSTANTS.SELECT_OPENING_EXISTING_WORKSPACE_INSTEAD_OF_CREATION_NEW) {
82-
test('Select opening an existing workspace instead of creating a new one', async function (): Promise<void> {
83-
await dashboard.waitExistingWorkspaceFoundAlert();
84-
await dashboard.clickOpenExistingWorkspaceButton();
85-
});
86-
}
87-
88-
if (BASE_TEST_CONSTANTS.SELECT_CREATING_NEW_WORKSPACE) {
89-
test('Select of creating a new workspace', async function (): Promise<void> {
90-
await dashboard.waitExistingWorkspaceFoundAlert();
91-
await dashboard.clickOnCreateNewWorkspaceButton();
92-
});
93-
}
94-
9581
test('Obtain workspace name from workspace loader page', async function (): Promise<void> {
9682
await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
9783
});

tests/e2e/utils/StringUtil.ts

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** *******************************************************************
2-
* copyright (c) 2019 Red Hat, Inc.
2+
* copyright (c) 2019-2025 Red Hat, Inc.
33
*
44
* This program and the accompanying materials are made
55
* available under the terms of the Eclipse Public License 2.0
@@ -14,27 +14,40 @@ import { injectable } from 'inversify';
1414
@injectable()
1515
export class StringUtil {
1616
/**
17-
* method extracts a test repo name from git clone https url;
18-
* it splits the url into string[] by "/" or ".", deletes empty elements and elements that contains just "git", "main" or "tree" word, than returns the last one;
19-
* please, avoid to call the test repo as just "git" or to use dots in the name, like: github.com/user/git.git, github.com/user/name.with.dots.
20-
* @param url git https url (which using for "git clone")
21-
* @return project name
17+
* extracts the project (repository) name from a Git HTTPS URL.
18+
*
19+
* Handles URLs from GitLab, GitHub, and Bitbucket by:
20+
* - Removing query parameters and hash fragments;
21+
* - Trimming branch or tree paths (e.g. `/tree/<branch>`, `/-/tree/<branch>`, `/src/<branch>`);
22+
* - Stripping the `.git` suffix.
23+
*
24+
* ⚠️ Avoid naming repositories as `"git"` or using dots in names (`name.with.dots`),
25+
* as they may be treated as separators.
26+
*
27+
* @param url Git HTTPS URL (as used for `git clone`)
28+
* @returns Extracted project name, or an empty string if parsing fails
2229
*/
2330
static getProjectNameFromGitUrl(url: string): string {
24-
Logger.debug(`${url}`);
31+
Logger.debug(`Original URL: ${url}`);
2532

26-
if (url.includes('?')) {
27-
url = url.substring(0, url.indexOf('?'));
28-
}
29-
if (url.includes('/tree/')) {
30-
url = url.split('/').slice(0, -2).join('/');
33+
try {
34+
// remove query and hash fragments
35+
url = url.split('?')[0].split('#')[0];
36+
37+
// remove branch/tree path fragments for major providers
38+
url = url
39+
.replace(/\/-?\/tree\/[^/]+$/, '') // gitLab, GitHub
40+
.replace(/\/src\/[^/]+.*$/, ''); // bitbucket
41+
42+
// take the last segment of the path and strip ".git"
43+
const projectName: string = (url.split('/').filter(Boolean).pop() || '').replace(/\.git$/, '');
44+
45+
Logger.debug(`Extracted project name: ${projectName}`);
46+
return projectName;
47+
} catch (err) {
48+
Logger.error(`Failed to extract project name from URL ${url}: ${err}`);
49+
return '';
3150
}
32-
const projectName: string = url
33-
.split(/[\/.]/)
34-
.filter((e: string): boolean => !['git', ''].includes(e))
35-
.reverse()[0];
36-
Logger.debug(`${projectName}`);
37-
return projectName;
3851
}
3952

4053
static sanitizeTitle(arg: string): string {

0 commit comments

Comments
 (0)