From 989e605eb48819b2c9e1d0cdbcc380d44d3699cf Mon Sep 17 00:00:00 2001 From: Skoryk Serhii Date: Wed, 6 Sep 2023 12:21:51 +0300 Subject: [PATCH] create WebTerminalTest typescript test --- .../e2e/pageobjects/openshift/OcpMainPage.ts | 18 +++++++++++++ .../web-terminal/WebTerminalTest.spec.ts | 25 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tests/e2e/specs/web-terminal/WebTerminalTest.spec.ts diff --git a/tests/e2e/pageobjects/openshift/OcpMainPage.ts b/tests/e2e/pageobjects/openshift/OcpMainPage.ts index e9792728198..8e90e2ca384 100644 --- a/tests/e2e/pageobjects/openshift/OcpMainPage.ts +++ b/tests/e2e/pageobjects/openshift/OcpMainPage.ts @@ -26,6 +26,8 @@ export class OcpMainPage { private static readonly SELECT_PROJECT_DROPDOWN: By = By.xpath('//div[@class="co-namespace-dropdown"]//button'); private static readonly PROJECT_FILTER_INPUT: By = By.xpath('//*[@data-test="dropdown-text-filter"]'); private static readonly SKIP_TOUR_BUTTON: By = By.xpath('//*[text()="Skip tour"]'); + private static readonly WEB_TERMINAL_BUTTON: By = By.xpath('//button[@data-quickstart-id="qs-masthead-cloudshell"]'); + private static readonly WEB_TERMINAL_PAGE: By = By.xpath('//*[@class="xterm-helper-textarea"]'); constructor( @inject(CLASSES.DriverHelper) @@ -81,6 +83,22 @@ export class OcpMainPage { await this.driverHelper.enterValue(OcpMainPage.PROJECT_FILTER_INPUT, projectName); await this.driverHelper.waitAndClick(this.getProjectDropdownItemLocator(projectName)); } + + async openWebTerminal(): Promise { + Logger.debug(); + + await this.waitOpenMainPage(); + await this.driverHelper.waitAndClick(OcpMainPage.WEB_TERMINAL_BUTTON); + await this.driverHelper.waitPresence(OcpMainPage.WEB_TERMINAL_PAGE, TIMEOUT_CONSTANTS.TS_IDE_LOAD_TIMEOUT); + } + + async typeToWebTerminal(text: string): Promise { + Logger.debug(); + + await this.driverHelper.waitPresence(OcpMainPage.WEB_TERMINAL_PAGE, TIMEOUT_CONSTANTS.TS_IDE_LOAD_TIMEOUT); + await this.driverHelper.typeToInvisible(OcpMainPage.WEB_TERMINAL_PAGE, text); + } + private getRoleLocator(role: string): By { return By.xpath(`//a//*[text()="${role}"]`); } diff --git a/tests/e2e/specs/web-terminal/WebTerminalTest.spec.ts b/tests/e2e/specs/web-terminal/WebTerminalTest.spec.ts new file mode 100644 index 00000000000..a0e2f0f977b --- /dev/null +++ b/tests/e2e/specs/web-terminal/WebTerminalTest.spec.ts @@ -0,0 +1,25 @@ +/** ******************************************************************* + * copyright (c) 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 { CLASSES } from '../../configs/inversify.types'; +import { e2eContainer } from '../../configs/inversify.config'; +import { LoginTests } from '../../tests-library/LoginTests'; +import { OcpMainPage } from '../../pageobjects/openshift/OcpMainPage'; + +suite('Login to Openshift console and start WebTerminal', function (): void { + const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); + const ocpMainPage: OcpMainPage = e2eContainer.get(CLASSES.OcpMainPage); + + loginTests.loginIntoOcpConsole(); + + test('Open Web Terminal', async function (): Promise { + await ocpMainPage.waitOpenMainPage(); + await ocpMainPage.openWebTerminal(); + }); +});