-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: mdolhalo <[email protected]>
- Loading branch information
mdolhalo
committed
Apr 26, 2023
1 parent
5e8a484
commit a9314eb
Showing
13 changed files
with
404 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/********************************************************************* | ||
* Copyright (c) 2019-2023 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
**********************************************************************/ | ||
import 'reflect-metadata'; | ||
import { inject, injectable } from 'inversify'; | ||
import { DriverHelper } from '../../utils/DriverHelper'; | ||
import { CLASSES } from '../../configs/inversify.types'; | ||
import { By } from 'selenium-webdriver'; | ||
import { Logger } from '../../utils/Logger'; | ||
import { TimeoutConstants } from '../../constants/TimeoutConstants'; | ||
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; | ||
|
||
@injectable() | ||
export class OcpApplicationPage { | ||
|
||
constructor( | ||
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper, | ||
@inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil) { | ||
} | ||
|
||
async waitApplicationIcon(): Promise<void> { | ||
Logger.debug(`${this.constructor.name}.${this.waitApplicationIcon.name}`); | ||
|
||
await this.driverHelper.waitPresence(By.xpath('//*[@data-test-id="base-node-handler"]'), TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT); | ||
} | ||
|
||
async waitAndOpenEditSourceCodeIcon(): Promise<void> { | ||
Logger.debug(`${this.constructor.name}.${this.waitAndOpenEditSourceCodeIcon.name}`); | ||
const parentGUID: string = await this.browserTabsUtil.getCurrentWindowHandle(); | ||
await this.driverHelper.waitAndClick(By.xpath('//*[@aria-label="Edit source code"]')); | ||
await this.browserTabsUtil.waitAndSwitchToAnotherWindow(parentGUID, TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/********************************************************************* | ||
* Copyright (c) 2019-2023 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
**********************************************************************/ | ||
import 'reflect-metadata'; | ||
import { inject, injectable } from 'inversify'; | ||
import { DriverHelper } from '../../utils/DriverHelper'; | ||
import { CLASSES } from '../../configs/inversify.types'; | ||
import { By } from 'selenium-webdriver'; | ||
import { Logger } from '../../utils/Logger'; | ||
import { OcpApplicationPage } from './OcpApplicationPage'; | ||
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; | ||
import { e2eContainer } from '../../configs/inversify.config'; | ||
|
||
@injectable() | ||
export class OcpImportFromGitPage { | ||
|
||
constructor( | ||
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper, | ||
@inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil) { | ||
} | ||
|
||
async enterGitRepoUrl(gitRepoUrl: string): Promise<void> { | ||
Logger.debug(`${this.constructor.name}.${this.enterGitRepoUrl.name} "${gitRepoUrl}"`); | ||
|
||
await this.driverHelper.enterValue(By.id('form-input-git-url-field'), gitRepoUrl); | ||
} | ||
|
||
async clickOnAdvancedOptionsButton(): Promise<void> { | ||
Logger.debug(`${this.constructor.name}.${this.clickOnAdvancedOptionsButton.name}`); | ||
|
||
if (!(await this.driverHelper.isVisible(By.xpath('//*[text()="Hide advanced Git options"]')))) { | ||
await this.driverHelper.waitAndClick(By.xpath('//*[text()="Show advanced Git options"]//ancestor::button')); | ||
} | ||
} | ||
|
||
async enterGitReference(gitReference: string): Promise<void> { | ||
Logger.debug(`${this.constructor.name}.${this.enterGitReference.name} "${gitReference}"`); | ||
|
||
await this.driverHelper.enterValue(By.id('form-input-git-ref-field'), gitReference); | ||
} | ||
|
||
async selectBuilderImageImportStrategy(): Promise<void> { | ||
Logger.debug(`${this.constructor.name}.${this.selectBuilderImageImportStrategy.name}`); | ||
|
||
await this.driverHelper.scrollToAndClick(By.xpath('//*[text()="Edit Import Strategy"]//ancestor::button')); | ||
await this.driverHelper.scrollToAndClick(By.xpath('//*[text()="Builder Image"]//parent::div//parent::div')); | ||
} | ||
|
||
async addLabel(label: string): Promise<void> { | ||
Logger.debug(`${this.constructor.name}.${this.addLabel.name} "${label}"`); | ||
|
||
await this.driverHelper.scrollToAndClick(By.xpath('//button[text()="Labels"]')); | ||
await this.driverHelper.scrollToAndEnterValue(By.id('form-selector-labels-field'), label); | ||
} | ||
|
||
async submitConfiguration(): Promise<OcpApplicationPage> { | ||
Logger.debug(`${this.constructor.name}.${this.submitConfiguration.name}`); | ||
|
||
await this.driverHelper.waitAndClick(By.xpath('//*[@data-test-id="submit-button"]')); | ||
return e2eContainer.get(CLASSES.OcpApplicationPage); | ||
} | ||
|
||
async fitAndSubmitConfiguration(gitRepoUrl: string, gitReference: string, label: string): Promise<OcpApplicationPage> { | ||
Logger.debug(`${this.constructor.name}.${this.fitAndSubmitConfiguration.name}`); | ||
|
||
await this.enterGitRepoUrl(gitRepoUrl); | ||
await this.clickOnAdvancedOptionsButton(); | ||
await this.enterGitReference(gitReference); | ||
await this.selectBuilderImageImportStrategy(); | ||
await this.addLabel(label); | ||
return await this.submitConfiguration(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/********************************************************************* | ||
* Copyright (c) 2019-2023 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
**********************************************************************/ | ||
import 'reflect-metadata'; | ||
import { inject, injectable } from 'inversify'; | ||
import { DriverHelper } from '../../utils/DriverHelper'; | ||
import { CLASSES } from '../../configs/inversify.types'; | ||
import { By } from 'selenium-webdriver'; | ||
import { Logger } from '../../utils/Logger'; | ||
import { TimeoutConstants } from '../../constants/TimeoutConstants'; | ||
import { OcpImportFromGitPage } from './OcpImportFromGitPage'; | ||
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; | ||
import { e2eContainer } from '../../configs/inversify.config'; | ||
|
||
@injectable() | ||
export class OcpMainPage { | ||
|
||
private static readonly MAIN_PAGE_HEADER_LOCATOR: By = By.id('page-main-header'); | ||
private static readonly SELECT_ROLE_BUTTON_LOCATOR: By = By.xpath('//*[@data-test-id="perspective-switcher-toggle"]'); | ||
private static readonly ADD_BUTTON_LOCATOR: By = By.xpath('//*[@data-test-id="+Add-header"]'); | ||
private static readonly IMPORT_FROM_GIT_ITEM_LOCATOR: By = By.xpath('//*[@data-test="item import-from-git"]'); | ||
private static readonly SELECT_PROJECT_DROPDOWN_LOCATOR: By = By.xpath('//div[@class="co-namespace-dropdown"]//button'); | ||
private static readonly PROJECT_FILTER_INPUT_LOCATOR: By = By.xpath('//*[@data-test="dropdown-text-filter"]'); | ||
|
||
constructor( | ||
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { } | ||
|
||
async waitOpenMainPage(): Promise<void> { | ||
Logger.debug(`${this.constructor.name}.${this.waitOpenMainPage.name}`); | ||
|
||
await this.driverHelper.waitVisibility(OcpMainPage.MAIN_PAGE_HEADER_LOCATOR, TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT); | ||
} | ||
|
||
async clickOnSelectRoleButton(): Promise<void> { | ||
Logger.debug(`${this.constructor.name}.${this.clickOnSelectRoleButton.name}`); | ||
|
||
await this.driverHelper.waitAndClick(OcpMainPage.SELECT_ROLE_BUTTON_LOCATOR); | ||
} | ||
|
||
async clickAddToProjectButton(): Promise<void> { | ||
Logger.debug(`${this.constructor.name}.${this.clickAddToProjectButton.name}`); | ||
|
||
await this.driverHelper.waitAndClick(OcpMainPage.ADD_BUTTON_LOCATOR); | ||
} | ||
|
||
async selectDeveloperRole(): Promise<void> { | ||
Logger.debug(`${this.constructor.name}.${this.selectDeveloperRole.name}`); | ||
|
||
await this.driverHelper.waitAndClick(this.getRoleLocator('Developer')); | ||
} | ||
|
||
async selectImportFromGitMethod(): Promise<OcpImportFromGitPage> { | ||
Logger.debug(`${this.constructor.name}.${this.selectImportFromGitMethod.name}`); | ||
|
||
await this.driverHelper.waitAndClick(OcpMainPage.IMPORT_FROM_GIT_ITEM_LOCATOR); | ||
return e2eContainer.get(CLASSES.OcpImportFromGitPage); | ||
} | ||
|
||
async openImportFromGitPage(): Promise<OcpImportFromGitPage> { | ||
await this.waitOpenMainPage(); | ||
await this.clickOnSelectRoleButton(); | ||
await this.selectDeveloperRole(); | ||
await this.clickAddToProjectButton(); | ||
return await this.selectImportFromGitMethod(); | ||
} | ||
|
||
async selectProject(projectName: string): Promise<void> { | ||
Logger.debug(`${this.constructor.name}.${this.selectProject.name}`); | ||
|
||
await this.driverHelper.waitAndClick(OcpMainPage.SELECT_PROJECT_DROPDOWN_LOCATOR); | ||
await this.driverHelper.enterValue(OcpMainPage.PROJECT_FILTER_INPUT_LOCATOR, projectName); | ||
await this.driverHelper.waitAndClick(this.getProjectDropdownItemLocator(projectName)); | ||
} | ||
|
||
private getRoleLocator(role: string): By { | ||
return By.xpath(`//a//*[text()="${role}"]`); | ||
} | ||
|
||
private getProjectDropdownItemLocator(projectName: string): By { | ||
return By.xpath(`//button//*[text()="${projectName}"]`); | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
tests/e2e/specs/devconsole-intergration/DevConsoleIntegration.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/********************************************************************* | ||
* Copyright (c) 2019-2023 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
**********************************************************************/ | ||
|
||
import { | ||
SideBarView, | ||
ViewItem, | ||
ViewSection | ||
} from 'monaco-page-objects'; | ||
import { registerRunningWorkspace } from '../MochaHooks'; | ||
import { LoginTests } from '../../tests-library/LoginTests'; | ||
import { e2eContainer } from '../../configs/inversify.config'; | ||
import { CLASSES } from '../../configs/inversify.types'; | ||
import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests'; | ||
import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests'; | ||
import { Logger } from '../../utils/Logger'; | ||
import { expect } from 'chai'; | ||
import { TestConstants } from '../../constants/TestConstants'; | ||
import { OcpMainPage } from '../../pageobjects/openshift/OcpMainPage'; | ||
import { OcpImportFromGitPage } from '../../pageobjects/openshift/OcpImportFromGitPage'; | ||
import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor'; | ||
import { GitUtil } from '../../utils/vsc/GitUtil'; | ||
import { OcpApplicationPage } from '../../pageobjects/openshift/OcpApplicationPage'; | ||
|
||
const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests); | ||
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); | ||
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); | ||
const ocpMainPage: OcpMainPage = e2eContainer.get(CLASSES.OcpMainPage); | ||
let ocpImportPage: OcpImportFromGitPage; | ||
let ocpApplicationPage: OcpApplicationPage; | ||
const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = new KubernetesCommandLineToolsExecutor(); | ||
|
||
// works only with no-admin user | ||
suite(`DevConsole Integration`, async function (): Promise<void> { | ||
// test specific data | ||
const gitImportRepo: string = 'https://github.com/musienko-maxim/summit-lab-spring-music'; | ||
const gitImportReference: string = 'pipeline'; | ||
const projectLabel: string = 'app.openshift.io/runtime=spring'; | ||
const projectName: string = 'devconsole-integration-test'; | ||
|
||
suiteSetup('Create new empty project using ocp', async function (): Promise<void> { | ||
kubernetesCommandLineToolsExecutor.loginToOcp(); | ||
kubernetesCommandLineToolsExecutor.deleteProject(projectName); | ||
kubernetesCommandLineToolsExecutor.createProject(projectName); | ||
}); | ||
|
||
loginTests.loginIntoOcpConsole(); | ||
|
||
test('Select test project on DevConsole', async function (): Promise<void> { | ||
await ocpMainPage.selectProject(projectName); | ||
}); | ||
|
||
test('Open import from git project page as Developer', async function (): Promise<void> { | ||
ocpImportPage = await ocpMainPage.openImportFromGitPage(); | ||
}); | ||
|
||
test('Fill and submit import data', async function (): Promise<void> { | ||
ocpApplicationPage = await ocpImportPage.fitAndSubmitConfiguration(gitImportRepo, gitImportReference, projectLabel); | ||
}); | ||
|
||
test('Wait until application creates', async function (): Promise<void> { | ||
await ocpApplicationPage.waitApplicationIcon(); | ||
}); | ||
|
||
test('Check if application has worked link "Open Source Code"', async function (): Promise<void> { | ||
await ocpApplicationPage.waitAndOpenEditSourceCodeIcon(); | ||
}); | ||
|
||
loginTests.loginIntoChe(); | ||
|
||
workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); | ||
|
||
test('Registering the running workspace', async function (): Promise<void> { | ||
registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName()); | ||
}); | ||
|
||
test('Check if application source code opens in workspace', async function (): Promise<void> { | ||
await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); | ||
}); | ||
|
||
test('Check if project and files imported', async function (): Promise<void> { | ||
const applicationSourceProjectName: string = GitUtil.getProjectNameFromGitUrl(gitImportRepo); | ||
const projectSection: ViewSection = await new SideBarView().getContent().getSection(applicationSourceProjectName as unknown as string); | ||
const isFileImported: ViewItem | undefined = await projectSection.findItem(TestConstants.TS_SELENIUM_PROJECT_ROOT_FILE_NAME); | ||
expect(isFileImported).not.eqls(undefined); | ||
}); | ||
|
||
loginTests.logoutFromChe(); | ||
|
||
suiteTeardown('Delete project using ocp', async function (): Promise<void> { | ||
kubernetesCommandLineToolsExecutor.deleteProject(projectName); | ||
}); | ||
}); |
Oops, something went wrong.