Skip to content

Commit 6acaeda

Browse files
authored
Fix Git branch selection in CreateWorkspace pageobject from available branches list (#23768)
* select branch from branches list * restore default branch name * update locators * update locator name
1 parent b9af639 commit 6acaeda

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

tests/e2e/pageobjects/dashboard/CreateWorkspace.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import { TrustAuthorPopup } from './TrustAuthorPopup';
2121
export class CreateWorkspace {
2222
private static readonly FACTORY_URL: By = By.xpath('//input[@id="git-repo-url"]');
2323
private static readonly GIT_REPO_OPTIONS: By = By.xpath('//span[text()="Git Repo Options"]');
24-
private static readonly GIT_BRANCH_NAME: By = By.xpath('//input[@aria-label="Git Branch"]');
24+
private static readonly GIT_BRANCH_NAME: By = By.xpath(
25+
'//div[text()="Select the branch of the Git Repository"]/preceding-sibling::div'
26+
);
27+
private static readonly GIT_BRANCH_SEARCH_FIELD: By = By.css('input[type="search"]');
2528
private static readonly PATH_TO_DEVFILE: By = By.xpath('//input[@aria-label="Path to Devfile"]');
2629
private static readonly CREATE_AND_OPEN_BUTTON: By = By.xpath('//button[@id="create-and-open-button"]');
2730
private static readonly CREATE_NEW_WORKPACE_CHECKBOX: By = By.xpath('//label[@for="create-new-if-exist-switch"]');
@@ -75,7 +78,7 @@ export class CreateWorkspace {
7578
async importFromGitUsingUI(
7679
factoryUrl: string,
7780
branchName?: string,
78-
timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT
81+
timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT
7982
): Promise<void> {
8083
Logger.debug(`factoryUrl: "${factoryUrl}"`);
8184

@@ -85,8 +88,11 @@ export class CreateWorkspace {
8588
if (branchName) {
8689
await this.driverHelper.waitAndClick(CreateWorkspace.GIT_REPO_OPTIONS, timeout);
8790

88-
await this.driverHelper.waitVisibility(CreateWorkspace.GIT_BRANCH_NAME, timeout);
89-
await this.driverHelper.type(CreateWorkspace.GIT_BRANCH_NAME, Key.chord(branchName, Key.ENTER), timeout);
91+
await this.driverHelper.waitAndClick(CreateWorkspace.GIT_BRANCH_NAME, timeout);
92+
93+
await this.driverHelper.waitVisibility(CreateWorkspace.GIT_BRANCH_SEARCH_FIELD, timeout);
94+
await this.driverHelper.type(CreateWorkspace.GIT_BRANCH_SEARCH_FIELD, Key.chord(branchName), timeout);
95+
await this.driverHelper.waitAndClick(this.getGitBranchListItemLocator(branchName), timeout);
9096
}
9197

9298
await this.driverHelper.waitAndClick(CreateWorkspace.CREATE_AND_OPEN_BUTTON, timeout);
@@ -209,4 +215,8 @@ export class CreateWorkspace {
209215

210216
return By.xpath(`//article[contains(@class, 'sample-card')]//div[text()='${sampleName}']`);
211217
}
218+
219+
private getGitBranchListItemLocator(branchName: string): By {
220+
return By.css(`li[id="${branchName}"] button.pf-c-select__menu-item`);
221+
}
212222
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** *******************************************************************
2-
* copyright (c) 2024 Red Hat, Inc.
2+
* copyright (c) 2026 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

0 commit comments

Comments
 (0)