Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions tests/e2e/pageobjects/dashboard/CreateWorkspace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** *******************************************************************
* copyright (c) 2019-2023 Red Hat, Inc.
* copyright (c) 2019-2026 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -134,10 +134,31 @@ export class CreateWorkspace {
return await element.isSelected();
}

async waitForCheckboxState(
expectedState: boolean,
timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT
): Promise<void> {
Logger.debug(`waiting for checkbox to be ${expectedState ? 'checked' : 'unchecked'}`);

const polling: number = 500;
const attempts: number = Math.ceil(timeout / polling);

for (let i: number = 0; i < attempts; i++) {
const currentState: boolean = await this.isCreateNewWorkspaceCheckboxChecked();
if (currentState === expectedState) {
Logger.debug(`Checkbox reached expected state: ${expectedState}`);
return;
}
await this.driverHelper.wait(polling);
}

throw new Error(`Checkbox did not reach expected state ${expectedState} within ${timeout}ms`);
}

async clickOnCreateNewWorkspaceCheckbox(timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_WAIT_FOR_URL): Promise<void> {
Logger.debug();

await this.driverHelper.waitAndClick(CreateWorkspace.CREATE_NEW_WORKPACE_CHECKBOX, timeout);
await this.driverHelper.scrollToAndClick(CreateWorkspace.CREATE_NEW_WORKPACE_CHECKBOX, timeout);
}

async setCreateNewWorkspaceCheckbox(
Expand All @@ -157,8 +178,7 @@ export class CreateWorkspace {

// click to change state
Logger.debug(`Checkbox is ${isCurrentlyChecked ? 'set' : 'unset'}, ${checked ? 'setting' : 'unsetting'} it now`);
await this.driverHelper.waitAndClick(CreateWorkspace.CREATE_NEW_WORKPACE_CHECKBOX, timeout);
await this.driverHelper.wait(1000);
await this.driverHelper.scrollToAndClick(CreateWorkspace.CREATE_NEW_WORKPACE_CHECKBOX, timeout);
}

private getEditorsDropdownListLocator(sampleName: string): By {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** *******************************************************************
* copyright (c) 2020-2025 Red Hat, Inc.
* copyright (c) 2020-2026 Red Hat, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -75,7 +75,7 @@ suite(`"Start workspace with existed workspace name" test ${BASE_TEST_CONSTANTS.
await waitDashboardPage();

await createWorkspace.setGitRepositoryUrl(factoryUrl);
expect(await createWorkspace.isCreateNewWorkspaceCheckboxChecked()).to.be.false;
await createWorkspace.waitForCheckboxState(false);
expect(await createWorkspace.getGitRepositoryUrl()).to.be.equal(factoryUrl);
await createWorkspace.clickOnCreateAndOpenButton();
await createWorkspace.performTrustAuthorPopup();
Expand All @@ -102,7 +102,9 @@ suite(`"Start workspace with existed workspace name" test ${BASE_TEST_CONSTANTS.
await waitDashboardPage();

await createWorkspace.setGitRepositoryUrl(factoryUrl);
await createWorkspace.waitForCheckboxState(false);
await createWorkspace.setCreateNewWorkspaceCheckbox(true);
await createWorkspace.waitForCheckboxState(true);

expect(await createWorkspace.getGitRepositoryUrl()).to.be.equal(factoryUrl + '?new');

Expand Down
Loading