diff --git a/tests/e2e/pageobjects/dashboard/CreateWorkspace.ts b/tests/e2e/pageobjects/dashboard/CreateWorkspace.ts index 95cee2e4eb5..83296a8bc2e 100644 --- a/tests/e2e/pageobjects/dashboard/CreateWorkspace.ts +++ b/tests/e2e/pageobjects/dashboard/CreateWorkspace.ts @@ -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 @@ -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 { + 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 { Logger.debug(); - await this.driverHelper.waitAndClick(CreateWorkspace.CREATE_NEW_WORKPACE_CHECKBOX, timeout); + await this.driverHelper.scrollToAndClick(CreateWorkspace.CREATE_NEW_WORKPACE_CHECKBOX, timeout); } async setCreateNewWorkspaceCheckbox( @@ -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 { diff --git a/tests/e2e/specs/miscellaneous/CreateWorkspaceWithExistingNameFromGitUrl.spec.ts b/tests/e2e/specs/miscellaneous/CreateWorkspaceWithExistingNameFromGitUrl.spec.ts index f9417d59d4a..fbebda4839d 100644 --- a/tests/e2e/specs/miscellaneous/CreateWorkspaceWithExistingNameFromGitUrl.spec.ts +++ b/tests/e2e/specs/miscellaneous/CreateWorkspaceWithExistingNameFromGitUrl.spec.ts @@ -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 @@ -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(); @@ -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');