diff --git a/tests/e2e/configs/inversify.types.ts b/tests/e2e/configs/inversify.types.ts index eec756e6d29..511f9abcdba 100644 --- a/tests/e2e/configs/inversify.types.ts +++ b/tests/e2e/configs/inversify.types.ts @@ -9,7 +9,7 @@ **********************************************************************/ -const TYPES = { +const TYPES: any = { Driver: Symbol.for('Driver'), CheLogin: Symbol.for('CheLogin'), OcpLogin: Symbol.for('OcpLogin'), @@ -18,7 +18,7 @@ const TYPES = { ITokenHandler: Symbol.for('ITokenHandler') }; -const CLASSES = { +const CLASSES: any = { DriverHelper: 'DriverHelper', Dashboard: 'Dashboard', Workspaces: 'Workspaces', diff --git a/tests/e2e/constants/TestConstants.ts b/tests/e2e/constants/TestConstants.ts index 26da0aace29..51cfad738fd 100644 --- a/tests/e2e/constants/TestConstants.ts +++ b/tests/e2e/constants/TestConstants.ts @@ -23,7 +23,7 @@ export enum GitProviderType { BITBUCKET = 'bitbucket' } -export const TestConstants = { +export const TestConstants: any = { /** * Base URL of the application which should be checked */ @@ -217,7 +217,7 @@ export const TestConstants = { TS_SELENIUM_FACTORY_GIT_REPO_BRANCH: process.env.TS_SELENIUM_FACTORY_GIT_REPO_BRANCH || 'master', - TS_SELENIUM_FACTORY_URL() { + TS_SELENIUM_FACTORY_URL(): string { return process.env.TS_SELENIUM_FACTORY_URL || TestConstants.TS_SELENIUM_BASE_URL + '/dashboard/#/' + this.TS_SELENIUM_FACTORY_GIT_REPO_URL; }, diff --git a/tests/e2e/constants/TimeoutConstants.ts b/tests/e2e/constants/TimeoutConstants.ts index 4836623b799..eae04797a2e 100644 --- a/tests/e2e/constants/TimeoutConstants.ts +++ b/tests/e2e/constants/TimeoutConstants.ts @@ -8,7 +8,7 @@ * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ -export const TimeoutConstants = { +export const TimeoutConstants: any = { // -------------------------------------------- INSTALLING AND STARTUP -------------------------------------------- /** diff --git a/tests/e2e/driver/ChromeDriver.ts b/tests/e2e/driver/ChromeDriver.ts index c24b96b5897..27f5cb1de11 100644 --- a/tests/e2e/driver/ChromeDriver.ts +++ b/tests/e2e/driver/ChromeDriver.ts @@ -28,7 +28,7 @@ export class ChromeDriver implements IDriver { return this.driver; } - async setWindowSize() { + async setWindowSize(): Promise { await this.driver .manage() .window() @@ -49,7 +49,7 @@ export class ChromeDriver implements IDriver { } private getDriverBuilder(options: Options): Builder { - const disableW3copts = { 'goog:chromeOptions' : { 'w3c' : false }}; + const disableW3copts: object = { 'goog:chromeOptions' : { 'w3c' : false }}; let builder: Builder = new Builder() .forBrowser('chrome') .setChromeOptions(options); diff --git a/tests/e2e/pageobjects/dashboard/Dashboard.ts b/tests/e2e/pageobjects/dashboard/Dashboard.ts index 8ab36182b0f..0989d0fc212 100644 --- a/tests/e2e/pageobjects/dashboard/Dashboard.ts +++ b/tests/e2e/pageobjects/dashboard/Dashboard.ts @@ -41,7 +41,7 @@ export class Dashboard { @inject(CLASSES.Workspaces) private readonly workspaces: Workspaces) { } - async stopWorkspaceByUI(workspaceName: string) { + async stopWorkspaceByUI(workspaceName: string): Promise { Logger.debug(`Dashboard.stopWorkspaceByUI "${workspaceName}"`); await this.clickWorkspacesButton(); @@ -53,7 +53,7 @@ export class Dashboard { await this.workspaces.waitWorkspaceWithStoppedStatus(workspaceName); } - async deleteStoppedWorkspaceByUI(workspaceName: string) { + async deleteStoppedWorkspaceByUI(workspaceName: string): Promise { Logger.debug(`Dashboard.deleteStoppedWorkspaceByUI "${workspaceName}"`); await this.clickWorkspacesButton(); @@ -64,7 +64,7 @@ export class Dashboard { await this.workspaces.waitWorkspaceListItemAbcence(workspaceName); } - async stopAndRemoveWorkspaceByUI(workspaceName: string) { + async stopAndRemoveWorkspaceByUI(workspaceName: string): Promise { Logger.debug(`Dashboard.stopAndRemoveWorkspaceByUI "${workspaceName}"`); await this.stopWorkspaceByUI(workspaceName); @@ -72,69 +72,69 @@ export class Dashboard { await this.workspaces.waitWorkspaceListItemAbcence(workspaceName); } - async openDashboard() { + async openDashboard(): Promise { Logger.debug('Dashboard.openDashboard'); await this.driverHelper.getDriver().navigate().to(TestConstants.TS_SELENIUM_BASE_URL); await this.waitPage(); } - async waitPage(timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT) { + async waitPage(timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT): Promise { Logger.debug('Dashboard.waitPage'); await this.driverHelper.waitVisibility(By.xpath(Dashboard.WORKSPACES_BUTTON_XPATH), timeout); await this.driverHelper.waitVisibility(By.xpath(Dashboard.CREATE_WORKSPACE_BUTTON_XPATH), timeout); } - async clickWorkspacesButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT) { + async clickWorkspacesButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise { Logger.debug('Dashboard.clickWorkspacesButton'); await this.driverHelper.waitAndClick(By.xpath(Dashboard.WORKSPACES_BUTTON_XPATH), timeout); } - async clickCreateWorkspaceButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT) { + async clickCreateWorkspaceButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise { Logger.debug('Dashboard.clickCreateWorkspaceButton'); await this.driverHelper.waitAndClick(By.xpath(Dashboard.CREATE_WORKSPACE_BUTTON_XPATH), timeout); } - async getLoaderAlert(timeout: number = TimeoutConstants.TS_WAIT_LOADER_PRESENCE_TIMEOUT) { + async getLoaderAlert(timeout: number = TimeoutConstants.TS_WAIT_LOADER_PRESENCE_TIMEOUT): Promise { Logger.debug('Dashboard.getLoaderAlert'); return await this.driverHelper.waitAndGetText(By.xpath(Dashboard.LOADER_ALERT_XPATH), timeout); } - async waitLoader(timeout: number = TimeoutConstants.TS_WAIT_LOADER_PRESENCE_TIMEOUT) { + async waitLoader(timeout: number = TimeoutConstants.TS_WAIT_LOADER_PRESENCE_TIMEOUT): Promise { Logger.debug('Dashboard.waitLoader'); await this.driverHelper.waitAllPresence(By.xpath(Dashboard.LOADER_PAGE_STEP_TITLES_XPATH), timeout); } - async waitLoaderDisappearance(timeout: number = TimeoutConstants.TS_WAIT_LOADER_ABSENCE_TIMEOUT) { + async waitLoaderDisappearance(timeout: number = TimeoutConstants.TS_WAIT_LOADER_ABSENCE_TIMEOUT): Promise { Logger.debug('Dashboard.waitLoaderDisappearance'); await this.driverHelper.waitDisappearance(By.xpath(Dashboard.LOADER_PAGE_STEP_TITLES_XPATH), timeout); } - async waitDisappearanceNavigationMenu(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async waitDisappearanceNavigationMenu(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug('Dashboard.waitDisappearanceNavigationMenu'); await this.driverHelper.waitDisappearance(By.id('chenavmenu'), timeout); } - async waitWorkspaceStartingPage(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async waitWorkspaceStartingPage(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug(`Dashboard.waitWorkspaceStartingPage`); await this.driverHelper.waitPresence(By.css(Dashboard.WORKSPACE_STARTING_PAGE_CSS), timeout); } - async getRecentWorkspaceName(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async getRecentWorkspaceName(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug(`Dashboard.getRecentWorkspaceName`); return await this.driverHelper.waitAndGetText(By.css('[data-testid="recent-workspace-item"]'), timeout); } - async logout(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async logout(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug(`Dashboard.logout`); await this.openDashboard(); diff --git a/tests/e2e/pageobjects/dashboard/Workspaces.ts b/tests/e2e/pageobjects/dashboard/Workspaces.ts index 5a98ab15740..667710b5c84 100644 --- a/tests/e2e/pageobjects/dashboard/Workspaces.ts +++ b/tests/e2e/pageobjects/dashboard/Workspaces.ts @@ -28,25 +28,25 @@ export class Workspaces { constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { } - async waitPage(timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT) { + async waitPage(timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT): Promise { Logger.debug('Workspaces.waitPage'); await this.driverHelper.waitVisibility(By.xpath(Workspaces.ADD_WORKSPACE_BUTTON_XPATH), timeout); } - async clickAddWorkspaceButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT) { + async clickAddWorkspaceButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise { Logger.debug('Workspaces.clickAddWorkspaceButton'); await this.driverHelper.waitAndClick(By.xpath(Workspaces.ADD_WORKSPACE_BUTTON_XPATH), timeout); } - async clickOpenButton(workspaceName: string, timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT) { + async clickOpenButton(workspaceName: string, timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT): Promise { Logger.debug('Workspaces.clickOpenButton'); await this.driverHelper.waitAndClick(this.getOpenButtonLocator(workspaceName), timeout); } - async waitWorkspaceListItem(workspaceName: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async waitWorkspaceListItem(workspaceName: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug(`Workspaces.waitWorkspaceListItem "${workspaceName}"`); const workspaceListItemLocator: By = By.xpath(this.getWorkspaceListItemLocator(workspaceName)); @@ -54,7 +54,7 @@ export class Workspaces { await this.driverHelper.waitVisibility(workspaceListItemLocator, timeout); } - async waitWorkspaceWithRunningStatus(workspaceName: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async waitWorkspaceWithRunningStatus(workspaceName: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug(`Workspaces.waitWorkspaceWithRunningStatus "${workspaceName}"`); const runningStatusLocator: By = this.getWorkspaceStatusLocator(workspaceName, WorkspaceStatusUI.Running); @@ -62,7 +62,7 @@ export class Workspaces { await this.driverHelper.waitVisibility(runningStatusLocator, timeout); } - async waitWorkspaceWithStoppedStatus(workspaceName: string, timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT) { + async waitWorkspaceWithStoppedStatus(workspaceName: string, timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise { Logger.debug(`Workspaces.waitWorkspaceWithStoppedStatus "${workspaceName}"`); const stoppedStatusLocator: By = this.getWorkspaceStatusLocator(workspaceName, WorkspaceStatusUI.Stopped); @@ -70,7 +70,7 @@ export class Workspaces { await this.driverHelper.waitVisibility(stoppedStatusLocator, timeout); } - async clickWorkspaceListItem(workspaceName: string, timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT) { + async clickWorkspaceListItem(workspaceName: string, timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise { Logger.debug(`Workspaces.clickWorkspaceListItem "${workspaceName}"`); const workspaceListItemLocator: By = By.xpath(this.getWorkspaceListItemLocator(workspaceName)); @@ -78,31 +78,31 @@ export class Workspaces { await this.driverHelper.waitAndClick(workspaceListItemLocator, timeout); } - async clickActionsButton(workspaceName: string) { + async clickActionsButton(workspaceName: string): Promise { Logger.debug(`Workspaces.clickActionsButton of the '${workspaceName}' list item`); await this.driverHelper.waitAndClick(this.getActionsLocator(workspaceName)); } - async waitActionsPopup(workspaceName: string, timeout: number = TimeoutConstants.TS_CONTEXT_MENU_TIMEOUT) { + async waitActionsPopup(workspaceName: string, timeout: number = TimeoutConstants.TS_CONTEXT_MENU_TIMEOUT): Promise { Logger.debug(`Workspaces.waitActionsPopup of the '${workspaceName}' list item`); await this.driverHelper.waitVisibility(this.getExpandedActionsLocator(workspaceName), timeout); } - async openActionsPopup(workspaceName: string, timeout: number = TimeoutConstants.TS_CONTEXT_MENU_TIMEOUT) { + async openActionsPopup(workspaceName: string, timeout: number = TimeoutConstants.TS_CONTEXT_MENU_TIMEOUT): Promise { Logger.debug(`Workspaces.openActionsPopup for the '${workspaceName}' list item`); await this.clickActionsButton(workspaceName); await this.waitActionsPopup(workspaceName, timeout); } - async clickActionsDeleteButton(workspaceName: string) { + async clickActionsDeleteButton(workspaceName: string): Promise { Logger.debug(`Workspaces.clickActionsDeleteButton for the '${workspaceName}' list item`); await this.driverHelper.waitAndClick(this.getActionsPopupButtonLocator(workspaceName, 'Delete Workspace')); } - async clickActionsStopWorkspaceButton(workspaceName: string) { + async clickActionsStopWorkspaceButton(workspaceName: string): Promise { Logger.debug(`Workspaces.clickActionsStopWorkspaceButton for the '${workspaceName}' list item`); // todo: workaround because of issue CRW-3649 try { @@ -115,7 +115,7 @@ export class Workspaces { } } - async waitDeleteWorkspaceConfirmationWindow(timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT) { + async waitDeleteWorkspaceConfirmationWindow(timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise { Logger.debug(`Workspaces.waitDeleteWorkspaceConfirmationWindow`); const confirmationWindowLocator: By = By.xpath(`//div[@aria-label='Delete workspaces confirmation window']`); @@ -124,7 +124,7 @@ export class Workspaces { } - async clickToDeleteConfirmationCheckbox(timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT) { + async clickToDeleteConfirmationCheckbox(timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise { Logger.debug(`Workspaces.clickToDeleteConfirmationCheckbox`); const deleteConfirmationCheckboxLocator: By = By.xpath(`//input[@data-testid='confirmation-checkbox']`); @@ -132,7 +132,7 @@ export class Workspaces { await this.driverHelper.waitAndClick(deleteConfirmationCheckboxLocator, timeout); } - async waitAndClickEnabledConfirmationWindowDeleteButton(timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT) { + async waitAndClickEnabledConfirmationWindowDeleteButton(timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise { Logger.debug(`Workspaces.waitEnabledConfirmationWindowDeleteButton`); const enabledConfirmationWindowDeleteButton: By = By.xpath(`//button[@data-testid='delete-workspace-button' and not(@disabled)]`); @@ -141,7 +141,7 @@ export class Workspaces { } - async deleteWorkspaceByActionsButton(workspaceName: string, timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT) { + async deleteWorkspaceByActionsButton(workspaceName: string, timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise { Logger.debug('Workspaces.deleteWorkspaceByActionsButton'); await this.waitWorkspaceListItem(workspaceName, timeout); @@ -152,7 +152,7 @@ export class Workspaces { await this.waitAndClickEnabledConfirmationWindowDeleteButton(timeout); } - async stopWorkspaceByActionsButton(workspaceName: string, timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT) { + async stopWorkspaceByActionsButton(workspaceName: string, timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise { Logger.debug('Workspaces.stopWorkspaceByActionsButton'); await this.waitWorkspaceListItem(workspaceName, timeout); @@ -160,7 +160,7 @@ export class Workspaces { await this.clickActionsStopWorkspaceButton(workspaceName); } - async waitWorkspaceListItemAbcence(workspaceName: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async waitWorkspaceListItemAbcence(workspaceName: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug(`Workspaces.waitWorkspaceListItemAbcence "${workspaceName}"`); const workspaceListItemLocator: By = By.xpath(this.getWorkspaceListItemLocator(workspaceName)); @@ -168,7 +168,7 @@ export class Workspaces { await this.driverHelper.waitDisappearance(workspaceListItemLocator, timeout); } - async getAllCreatedWorkspacesNames(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async getAllCreatedWorkspacesNames(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug('Workspaces.getAllCreatedWorkspacesNames'); const workspaceNames: string[] = []; @@ -207,7 +207,7 @@ export class Workspaces { return By.xpath(`${this.getWorkspaceListItemLocator(workspaceName)}//li[@role='menuitem']//button[text()='${buttonText}']`); } - private getOpenButtonLocator(workspaceName: string) { + private getOpenButtonLocator(workspaceName: string): By { return By.xpath(`${this.getWorkspaceListItemLocator(workspaceName)}//td[@data-key=5]//a[text()='Open']`); } } diff --git a/tests/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts b/tests/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts index 0fdb1dbba75..8fd5202844f 100644 --- a/tests/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +++ b/tests/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts @@ -31,13 +31,13 @@ export class WorkspaceDetails { @inject(TYPES.WorkspaceUtil) private readonly testWorkspaceUtil: ITestWorkspaceUtil, @inject(CLASSES.ProjectAndFileTests) private readonly testProjectAndFileCheCode: ProjectAndFileTests) { } - async waitLoaderDisappearance(attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS, polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING) { + async waitLoaderDisappearance(attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS, polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING): Promise { Logger.debug('WorkspaceDetails.waitLoaderDisappearance'); await this.driverHelper.waitDisappearance(By.css(WorkspaceDetails.WORKSPACE_DETAILS_LOADER_CSS), attempts, polling); } - async saveChanges() { + async saveChanges(): Promise { Logger.debug('WorkspaceDetails.saveChanges'); await this.waitSaveButton(); @@ -45,7 +45,7 @@ export class WorkspaceDetails { await this.waitSaveButtonDisappearance(); } - async waitPage(workspaceName: string, timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT) { + async waitPage(workspaceName: string, timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT): Promise { Logger.debug(`WorkspaceDetails.saveChanges workspace: "${workspaceName}"`); await this.waitWorkspaceTitle(workspaceName, timeout); @@ -55,7 +55,7 @@ export class WorkspaceDetails { await this.waitLoaderDisappearance(timeout); } - async waitWorkspaceTitle(workspaceName: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async waitWorkspaceTitle(workspaceName: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug(`WorkspaceDetails.waitWorkspaceTitle title: "${workspaceName}"`); const workspaceTitleLocator: By = By.css(this.getWorkspaceTitleCssLocator(workspaceName)); @@ -63,25 +63,25 @@ export class WorkspaceDetails { await this.driverHelper.waitVisibility(workspaceTitleLocator, timeout); } - async waitRunButton(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async waitRunButton(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug('WorkspaceDetails.waitRunButton'); await this.driverHelper.waitVisibility(By.css(WorkspaceDetails.RUN_BUTTON_CSS), timeout); } - async clickOnRunButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT) { + async clickOnRunButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise { Logger.debug('WorkspaceDetails.clickOnRunButton'); await this.driverHelper.waitAndClick(By.css(WorkspaceDetails.RUN_BUTTON_CSS), timeout); } - async waitOpenButton(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async waitOpenButton(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug('WorkspaceDetails.waitOpenButton'); await this.driverHelper.waitVisibility(By.css(WorkspaceDetails.OPEN_BUTTON_CSS), timeout); } - async openWorkspace(namespace: string, workspaceName: string, timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT) { + async openWorkspace(namespace: string, workspaceName: string, timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT): Promise { Logger.debug(`WorkspaceDetails.openWorkspace "${namespace}/${workspaceName}"`); await this.clickOnOpenButton(timeout); @@ -89,7 +89,7 @@ export class WorkspaceDetails { await this.testWorkspaceUtil.waitWorkspaceStatus(namespace, workspaceName, WorkspaceStatus.STARTING); } - async waitTabsPresence(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async waitTabsPresence(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug('WorkspaceDetails.waitTabsPresence'); const workspaceDetailsTabs: Array = ['Overview', 'Projects', 'Containers', 'Servers', @@ -102,7 +102,7 @@ export class WorkspaceDetails { } } - async selectTab(tabTitle: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + async selectTab(tabTitle: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { Logger.debug(`WorkspaceDetails.selectTab ${tabTitle}`); await this.clickOnTab(tabTitle, timeout); @@ -121,30 +121,30 @@ export class WorkspaceDetails { return `//md-tabs-canvas[@role='tablist']//md-tab-item[@aria-selected='true']//span[text()='${tabTitle}']`; } - private async waitSaveButton(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + private async waitSaveButton(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { await this.driverHelper.waitVisibility(By.css(WorkspaceDetails.ENABLED_SAVE_BUTTON_CSS), timeout); } - private async waitSaveButtonDisappearance(attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS, polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING) { + private async waitSaveButtonDisappearance(attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS, polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING): Promise { await this.driverHelper.waitDisappearance(By.css(WorkspaceDetails.SAVE_BUTTON_CSS), attempts, polling); } - private async clickOnSaveButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT) { + private async clickOnSaveButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise { await this.driverHelper.waitAndClick(By.css(WorkspaceDetails.ENABLED_SAVE_BUTTON_CSS), timeout); } - private async clickOnOpenButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT) { + private async clickOnOpenButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise { await this.driverHelper.waitAndClick(By.css(WorkspaceDetails.OPEN_BUTTON_CSS), timeout); } - private async clickOnTab(tabTitle: string, timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT) { + private async clickOnTab(tabTitle: string, timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise { const workspaceDetailsTabLocator: By = By.xpath(this.getTabXpathLocator(tabTitle)); await this.driverHelper.waitAndClick(workspaceDetailsTabLocator, timeout); } - private async waitTabSelected(tabTitle: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { + private async waitTabSelected(tabTitle: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise { const selectedTabLocator: By = By.xpath(this.getSelectedTabXpathLocator(tabTitle)); await this.driverHelper.waitVisibility(selectedTabLocator, timeout); diff --git a/tests/e2e/pageobjects/git-providers/OauthPage.ts b/tests/e2e/pageobjects/git-providers/OauthPage.ts index b922387ee61..000346363bb 100644 --- a/tests/e2e/pageobjects/git-providers/OauthPage.ts +++ b/tests/e2e/pageobjects/git-providers/OauthPage.ts @@ -55,7 +55,7 @@ export class OauthPage { } } - async waitLoginPage() { + async waitLoginPage(): Promise { Logger.debug('OauthPage.waitLoginPage'); // for gitlab server https://gitlab.cee.redhat.com @@ -70,55 +70,55 @@ export class OauthPage { await this.driverHelper.waitVisibility(this.loginForm, TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM * 3); } - async enterUserName(userName: string) { + async enterUserName(userName: string): Promise { Logger.debug(`this.enterUserName "${userName}"`); await this.driverHelper.enterValue(this.loginForm, userName); } - async enterPassword(password: string) { + async enterPassword(password: string): Promise { Logger.debug(`OauthPage.enterPassword`); await this.driverHelper.enterValue(this.passwordForm, password); } - async clickOnLoginButton() { + async clickOnLoginButton(): Promise { Logger.debug('OauthPage.clickOnLoginButton'); await this.driverHelper.waitAndClick(this.submitButton); } - async waitClosingLoginPage() { + async waitClosingLoginPage(): Promise { Logger.debug('OauthPage.waitClosingLoginPage'); await this.driverHelper.waitDisappearance(this.loginForm); } - async waitOauthPage() { + async waitOauthPage(): Promise { Logger.debug('OauthPage.waitOauthPage'); await this.driverHelper.waitVisibility(this.approveButton); } - async clickOnApproveButton() { + async clickOnApproveButton(): Promise { Logger.debug('OauthPage.clickOnApproveButton'); await this.driverHelper.waitAndClick(this.approveButton); } - async clickOnDenyAccessButton() { + async clickOnDenyAccessButton(): Promise { Logger.debug('OauthPage.clickOnDenyAccessButton'); await this.driverHelper.waitAndClick(this.denyAccessButton); } - async waitDisappearanceOauthPage() { + async waitDisappearanceOauthPage(): Promise { Logger.debug('OauthPage.waitDisappearanceOauthPage'); await this.driverHelper.waitDisappearance(this.approveButton); } - async login() { + async login(): Promise { Logger.debug('OauthPage.login'); await this.waitLoginPage(); @@ -128,7 +128,7 @@ export class OauthPage { await this.waitClosingLoginPage(); } - async confirmAccess() { + async confirmAccess(): Promise { Logger.debug('OauthPage.confirmAccess'); try { @@ -147,7 +147,7 @@ export class OauthPage { } } - async denyAccess() { + async denyAccess(): Promise { Logger.debug('OauthPage.denyAccess'); await this.clickOnDenyAccessButton(); diff --git a/tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts b/tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts index 31beceb940d..67f970ced86 100644 --- a/tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts +++ b/tests/e2e/pageobjects/ide/CheCodeLocatorLoader.ts @@ -39,7 +39,7 @@ export class CheCodeLocatorLoader extends LocatorLoader { }; } - private merge(target: any, obj: any) { + private merge(target: any, obj: any): object { for (const key in obj) { if (!Object.prototype.hasOwnProperty.call(obj, key)) { continue; diff --git a/tests/e2e/pageobjects/login/OcpUserLoginPage.ts b/tests/e2e/pageobjects/login/OcpUserLoginPage.ts index 949d4fcfaf1..924e0b32283 100644 --- a/tests/e2e/pageobjects/login/OcpUserLoginPage.ts +++ b/tests/e2e/pageobjects/login/OcpUserLoginPage.ts @@ -21,7 +21,7 @@ export class OcpUserLoginPage implements IOcpLoginPage { constructor( @inject(CLASSES.OcpLoginPage) private readonly ocpLogin: OcpLoginPage) { } - async login() { + async login(): Promise { Logger.debug('OcpUserLoginPage.login'); if (TestConstants.TS_OCP_LOGIN_PAGE_PROVIDER_TITLE !== '') { diff --git a/tests/e2e/pageobjects/login/RedHatLoginPage.ts b/tests/e2e/pageobjects/login/RedHatLoginPage.ts index b60f3fa5924..12f3fb7493e 100644 --- a/tests/e2e/pageobjects/login/RedHatLoginPage.ts +++ b/tests/e2e/pageobjects/login/RedHatLoginPage.ts @@ -27,34 +27,34 @@ export class RedHatLoginPage { constructor( @inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { } - async waitRedHatLoginWelcomePage() { + async waitRedHatLoginWelcomePage(): Promise { Logger.debug('RedHatLoginPage.waitRedHatLoginWelcomePage'); await this.driverHelper.waitVisibility(By.id(USERNAME_INPUT_ID)); } - async enterPasswordRedHat() { + async enterPasswordRedHat(): Promise { Logger.debug('RedHatLoginPage.enterPasswordRedHat'); const passwordFieldLocator: By = By.id(PASSWORD_INPUT_ID); await this.driverHelper.waitVisibility(passwordFieldLocator, 3000); await this.driverHelper.enterValue(passwordFieldLocator, TestConstants.TS_SELENIUM_PASSWORD, timeout ); } - async clickOnLoginButton() { + async clickOnLoginButton(): Promise { Logger.debug('RedHatLoginPage.clickOnLoginButton'); const loginButtonLocator: By = By.id(LOGIN_BUTTON_ID); await this.driverHelper.waitAndClick(loginButtonLocator, timeout); } - async waitDisappearanceRedHatLoginWelcomePage() { + async waitDisappearanceRedHatLoginWelcomePage(): Promise { Logger.debug('RedHatLoginPage.waitDisappearanceRedHatLoginWelcomePage'); await this.driverHelper.waitDisappearance(By.id(LOGIN_BUTTON_ID)); } - async enterUserNameRedHat() { + async enterUserNameRedHat(): Promise { Logger.debug('RedHatLoginPage.enterUserNameRedHat'); const usernameFieldLocator: By = By.id(USERNAME_INPUT_ID); await this.driverHelper.waitVisibility(usernameFieldLocator, 20000); await this.driverHelper.enterValue(usernameFieldLocator, TestConstants.TS_SELENIUM_USERNAME, timeout ); } - async clickNextButton() { + async clickNextButton(): Promise { Logger.debug('RedHatLoginPage.clickNextButton'); const nextButtonLocator: By = By.id(NEXT_BUTTON_ID); await this.driverHelper.waitAndClick(nextButtonLocator, timeout); diff --git a/tests/e2e/pageobjects/login/RegularUserOcpCheLoginPage.ts b/tests/e2e/pageobjects/login/RegularUserOcpCheLoginPage.ts index a5d25cc2fe1..c6dccc332e1 100644 --- a/tests/e2e/pageobjects/login/RegularUserOcpCheLoginPage.ts +++ b/tests/e2e/pageobjects/login/RegularUserOcpCheLoginPage.ts @@ -28,7 +28,7 @@ export class RegularUserOcpCheLoginPage implements ICheLoginPage { @inject(CLASSES.OcpLoginPage) private readonly ocpLogin: OcpLoginPage, @inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { } - async login() { + async login(): Promise { Logger.debug('RegularUserOcpCheLoginPage.login'); Logger.debug('RegularUserOcpCheLoginPage.login wait for LogInWithOpenShift page and click button'); diff --git a/tests/e2e/pageobjects/openshift/CheLoginPage.ts b/tests/e2e/pageobjects/openshift/CheLoginPage.ts index 99cca12f17c..6bf2b0de205 100644 --- a/tests/e2e/pageobjects/openshift/CheLoginPage.ts +++ b/tests/e2e/pageobjects/openshift/CheLoginPage.ts @@ -22,19 +22,19 @@ export class CheLoginPage { @inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { } - async waitEclipseCheLoginFormPage() { + async waitEclipseCheLoginFormPage(): Promise { Logger.debug('CheLoginPage.waitEclipseCheLoginFormPage'); await this.driverHelper.waitVisibility(By.id('login'), TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT); } - async inputUserNameEclipseCheLoginPage(userName: string) { + async inputUserNameEclipseCheLoginPage(userName: string): Promise { Logger.debug(`CheLoginPage.inputUserNameEclipseCheLoginPage username: "${userName}"`); await this.driverHelper.enterValue(By.id('login'), userName); } - async clickEclipseCheLoginButton() { + async clickEclipseCheLoginButton(): Promise { Logger.debug('CheLoginPage.clickEclipseCheLoginButton'); await this.driverHelper.waitAndClick(By.id('submit-login')); diff --git a/tests/e2e/pageobjects/openshift/OcpLoginPage.ts b/tests/e2e/pageobjects/openshift/OcpLoginPage.ts index 786fd7645a5..98e2de57064 100644 --- a/tests/e2e/pageobjects/openshift/OcpLoginPage.ts +++ b/tests/e2e/pageobjects/openshift/OcpLoginPage.ts @@ -24,13 +24,13 @@ export class OcpLoginPage { constructor( @inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { } - async waitOpenShiftLoginWelcomePage() { + async waitOpenShiftLoginWelcomePage(): Promise { Logger.debug('OcpLoginPage.waitOpenShiftLoginWelcomePage'); await this.driverHelper.waitVisibility(By.xpath(OcpLoginPage.LOGIN_PAGE_OPENSHIFT_XPATH), TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT); } - async clickOnLoginProviderTitle() { + async clickOnLoginProviderTitle(): Promise { Logger.debug('OcpLoginPage.clickOnLoginProviderTitle'); const loginProviderTitleLocator: By = By.xpath(`//a[text()=\'${TestConstants.TS_OCP_LOGIN_PAGE_PROVIDER_TITLE}\']`); @@ -51,40 +51,40 @@ export class OcpLoginPage { return await this.driverHelper.isVisible(authorizeOpenshiftIdentityProviderPageLocator); } - async waitAuthorizeOpenShiftIdentityProviderPage() { + async waitAuthorizeOpenShiftIdentityProviderPage(): Promise { Logger.debug('OcpLoginPage.waitAuthorizeOpenShiftIdentityProviderPage'); const authorizeOpenshiftIdentityProviderPageLocator: By = By.xpath('//h1[text()=\'Authorize Access\']'); await this.driverHelper.waitVisibility(authorizeOpenshiftIdentityProviderPageLocator, TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT); } - async clickOnApproveAuthorizeAccessButton() { + async clickOnApproveAuthorizeAccessButton(): Promise { Logger.debug('OcpLoginPage.clickOnApproveAuthorizeAccessOpenshift'); const approveAuthorizeAccessOcpLocator: By = By.css('input[name=\'approve\']'); await this.driverHelper.waitAndClick(approveAuthorizeAccessOcpLocator); } - async enterUserNameOpenShift(userName: string) { + async enterUserNameOpenShift(userName: string): Promise { Logger.debug(`OcpLoginPage.enterUserNameOpenShift "${userName}"`); await this.driverHelper.enterValue(By.id('inputUsername'), userName); } - async enterPasswordOpenShift(passw: string) { + async enterPasswordOpenShift(passw: string): Promise { Logger.debug(`OcpLoginPage.enterPasswordOpenShift"`); await this.driverHelper.enterValue(By.id('inputPassword'), passw); } - async clickOnLoginButton() { + async clickOnLoginButton(): Promise { Logger.debug('OcpLoginPage.clickOnLoginButton'); const loginButtonlocator: By = By.css('button[type=submit]'); await this.driverHelper.waitAndClick(loginButtonlocator); } - async waitDisappearanceOpenShiftLoginWelcomePage() { + async waitDisappearanceOpenShiftLoginWelcomePage(): Promise { Logger.debug('OcpLoginPage.waitDisappearanceOpenShiftLoginWelcomePage'); await this.driverHelper.waitDisappearance(By.xpath(OcpLoginPage.LOGIN_PAGE_OPENSHIFT_XPATH)); diff --git a/tests/e2e/specs/MochaHooks.ts b/tests/e2e/specs/MochaHooks.ts index 3f939a5534e..36910352e08 100644 --- a/tests/e2e/specs/MochaHooks.ts +++ b/tests/e2e/specs/MochaHooks.ts @@ -25,31 +25,31 @@ const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUt let latestWorkspace: string = ''; -export function registerRunningWorkspace(workspaceName: string) { +export function registerRunningWorkspace(workspaceName: string): void { Logger.debug(`MochaHooks.registerRunningWorkspace with workspaceName:${workspaceName}`); latestWorkspace = workspaceName; } exports.mochaHooks = { beforeAll: [ - async function enableRequestInterceptor() { + async function enableRequestInterceptor(): Promise { if (TestConstants.TS_SELENIUM_REQUEST_INTERCEPTOR) { CheApiRequestHandler.enableRequestInterceptor(); } }, - async function enableResponseInterceptor() { + async function enableResponseInterceptor(): Promise { if (TestConstants.TS_SELENIUM_RESPONSE_INTERCEPTOR) { CheApiRequestHandler.enableResponseInterceptor(); } }, - async function initMonacoPageObjects() { + async function initMonacoPageObjects(): Promise { // init vscode-extension-tester monaco-page-objects monacoPageObjects.initPageObjects(TestConstants.TS_SELENIUM_MONACO_PAGE_OBJECTS_USE_VERSION, TestConstants.TS_SELENIUM_MONACO_PAGE_OBJECTS_BASE_VERSION, vscodeExtensionTesterLocators.getLocatorsPath(), driverHelper.getDriver(), 'google-chrome'); }, - async function prolongTimeoutConstantsInDebugMode() { + async function prolongTimeoutConstantsInDebugMode(): Promise { if (TestConstants.TS_DEBUG_MODE) { for (let [timeout, seconds] of Object.entries(TimeoutConstants)) { - Object.defineProperty(TimeoutConstants, timeout, {value: seconds * 100}); + Object.defineProperty(TimeoutConstants, timeout, {value: seconds as number * 100}); } } }, @@ -62,7 +62,7 @@ exports.mochaHooks = { testWorkspaceUtil.stopAndDeleteWorkspaceByName(latestWorkspace); } }, - async function stopTheDriver() { + async function stopTheDriver(): Promise { if (!TestConstants.TS_DEBUG_MODE) { await driverHelper.getDriver().quit(); Logger.info('Chrome driver session stopped.'); diff --git a/tests/e2e/specs/SmokeTest.spec.ts b/tests/e2e/specs/SmokeTest.spec.ts index 8e2b89629b4..4e25afd6632 100644 --- a/tests/e2e/specs/SmokeTest.spec.ts +++ b/tests/e2e/specs/SmokeTest.spec.ts @@ -22,28 +22,28 @@ const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.Projec const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); -suite(`The SmokeTest userstory`, async function () { +suite(`The SmokeTest userstory`, async function (): Promise { let projectSection: ViewSection; - suite(`Create workspace from factory:${factoryUrl}`, async function () { + suite(`Create workspace from factory:${factoryUrl}`, async function (): Promise { loginTests.loginIntoChe(); workspaceHandlingTests.createAndOpenWorkspaceFromGitRepository(factoryUrl); workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); test('Register running workspace', async () => { registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName()); }); - test('Wait workspace readiness', async function () { + test('Wait workspace readiness', async function (): Promise { await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); }); - test('Check a project folder has been created', async function () { + test('Check a project folder has been created', async function (): Promise { projectSection = await new SideBarView().getContent().getSection(projectName); Logger.debug(`new SideBarView().getContent().getSection: get ${projectName}`); }); - test('Check the project files was imported', async function () { + test('Check the project files was imported', async function (): Promise { const label: string = 'devfile.yaml'; await projectSection.findItem(label); Logger.debug(`projectSection.findItem: find ${label}`); }); - test('Stopping and deleting the workspace', async function () { + test('Stopping and deleting the workspace', async function (): Promise { await workspaceHandlingTests.stopAndRemoveWorkspace(WorkspaceHandlingTests.getWorkspaceName()); }); }); diff --git a/tests/e2e/specs/devfiles/Quarkus.spec.ts b/tests/e2e/specs/devfiles/Quarkus.spec.ts index 7db19b53e66..998f11da5e9 100644 --- a/tests/e2e/specs/devfiles/Quarkus.spec.ts +++ b/tests/e2e/specs/devfiles/Quarkus.spec.ts @@ -23,28 +23,28 @@ const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.Projec const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); -suite(`The ${stackName} userstory`, async function () { +suite(`The ${stackName} userstory`, async function (): Promise { let projectSection: ViewSection; - suite(`Create workspace from ${stackName} simple`, async function () { + suite(`Create workspace from ${stackName} simple`, async function (): Promise { loginTests.loginIntoChe(); workspaceHandlingTests.createAndOpenWorkspace(stackName); workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); test('Register running workspace', async () => { registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName()); }); - test('Wait workspace readiness', async function () { + test('Wait workspace readiness', async function (): Promise { await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); }); - test('Check a project folder has been created', async function () { + test('Check a project folder has been created', async function (): Promise { projectSection = await new SideBarView().getContent().getSection(projectName); Logger.debug(`new SideBarView().getContent().getSection: get ${projectName}`); }); - test('Check the project files was imported', async function () { + test('Check the project files was imported', async function (): Promise { const label: string = 'devfile.yaml'; await projectSection.findItem(label); Logger.debug(`projectSection.findItem: find ${label}`); }); - test('Stopping and deleting the workspace', async function () { + test('Stopping and deleting the workspace', async function (): Promise { await workspaceHandlingTests.stopAndRemoveWorkspace(WorkspaceHandlingTests.getWorkspaceName()); }); loginTests.logoutFromChe(); diff --git a/tests/e2e/specs/factory/Factory.spec.ts b/tests/e2e/specs/factory/Factory.spec.ts index 9ff3ad1d097..f0248a5863d 100644 --- a/tests/e2e/specs/factory/Factory.spec.ts +++ b/tests/e2e/specs/factory/Factory.spec.ts @@ -47,7 +47,7 @@ const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); const webCheCodeLocators: Locators = new CheCodeLocatorLoader().webCheCodeLocators; -suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository`, async function () { +suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository`, async function (): Promise { const oauthPage: OauthPage = new OauthPage(driverHelper); let projectSection: ViewSection; @@ -66,12 +66,12 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE const testRepoProjectName: string = gitUtilCheCode.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL); loginTests.loginIntoChe(); - test(`Navigate to the factory URL`, async function () { + test(`Navigate to the factory URL`, async function (): Promise { await browserTabsUtil.navigateTo(TestConstants.TS_SELENIUM_FACTORY_URL()); }); if (TestConstants.TS_SELENIUM_GIT_PROVIDER_OAUTH) { - test(`Authorize with a ${TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER} OAuth`, async function () { + test(`Authorize with a ${TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER} OAuth`, async function (): Promise { await oauthPage.login(); await oauthPage.waitOauthPage(); await oauthPage.confirmAccess(); @@ -80,27 +80,27 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); - test('Registering the running workspace', async function () { + test('Registering the running workspace', async function (): Promise { registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName()); }); - test('Wait the workspace readiness', async function () { + test('Wait the workspace readiness', async function (): Promise { await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); }); - test('Check if a project folder has been created', async function () { + test('Check if a project folder has been created', async function (): Promise { Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`); projectSection = await new SideBarView().getContent().getSection(testRepoProjectName as unknown as string); }); - test('Check if the project files were imported', async function () { + test('Check if the project files were imported', async function (): Promise { const label: string = TestConstants.TS_SELENIUM_PROJECT_ROOT_FILE_NAME; Logger.debug(`projectSection.findItem: find ${label}`); const isFileImported: ViewItem | undefined = await projectSection.findItem(label); expect(isFileImported).not.eqls(undefined); }); - test('Accept the project as a trusted one', async function () { + test('Accept the project as a trusted one', async function (): Promise { const buttonYesITrustTheAuthors: string = `Yes, I trust the authors`; const trustedProjectDialog: ModalDialog = new ModalDialog(); await driverHelper.waitVisibility(webCheCodeLocators.WelcomeContent.button); @@ -108,7 +108,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE await trustedProjectDialog.pushButton(buttonYesITrustTheAuthors); }); - test('Make changes to the file', async function () { + test('Make changes to the file', async function (): Promise { Logger.debug(`projectSection.openItem: "${fileToChange}"`); await projectSection.openItem(fileToChange); const editor: TextEditor = await new EditorView().openEditor(fileToChange) as TextEditor; @@ -119,7 +119,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE await editor.typeTextAt(1, 1, changesToCommit); }); - test('Open a source control manager', async function () { + test('Open a source control manager', async function (): Promise { const viewSourceControl: string = `Source Control`; const sourceControl: ViewControl = await new ActivityBar().getViewControl(viewSourceControl) as ViewControl; Logger.debug(`sourceControl.openView: "${viewSourceControl}"`); @@ -130,7 +130,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE Logger.debug(`scmView.getProviders: "${scmProvider}, ${scmProvider}"`); }); - test('Check if the changes is displayed in the source control manager', async function () { + test('Check if the changes is displayed in the source control manager', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); await driverHelper.wait(timeToRefresh); Logger.debug(`scmProvider.takeAction: "${refreshButtonLabel}"`); @@ -142,7 +142,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE expect(changes).eql(1); }); - test('Stage the changes', async function () { + test('Stage the changes', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); Logger.debug(`scmProvider.openMoreActions`); scmContextMenu = await scmProvider.openMoreActions(); @@ -151,7 +151,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE await scmContextMenu.select('Changes', 'Stage All Changes'); }); - test('Commit the changes', async function () { + test('Commit the changes', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel)); Logger.debug(`scmProvider.commitChanges: commit name "Commit ${changesToCommit}"`); await scmProvider.commitChanges('Commit ' + changesToCommit); @@ -166,7 +166,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE expect(changes).eql(0); }); - test('Push the changes', async function () { + test('Push the changes', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.actionConstructor(`Push 1 commits to origin/${TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_BRANCH}`)); await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); Logger.debug(`scmProvider.openMoreActions`); @@ -176,7 +176,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE await scmContextMenu.select(pushItemLabel); }); - test('Check if the changes were pushed', async function () { + test('Check if the changes were pushed', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); await driverHelper.wait(timeToRefresh); Logger.debug(`scmProvider.takeAction: "${refreshButtonLabel}"`); @@ -185,13 +185,13 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE expect(isCommitButtonDisabled).eql('true'); }); - test(`Stop and remove the workspace`, async function () { + test(`Stop and remove the workspace`, async function (): Promise { await workspaceHandlingTests.stopAndRemoveWorkspace(WorkspaceHandlingTests.getWorkspaceName()); }); loginTests.logoutFromChe(); - suiteTeardown('Close the browser', async function () { + suiteTeardown('Close the browser', async function (): Promise { if (!TestConstants.TS_DEBUG_MODE) { await driverHelper.getDriver().close(); } diff --git a/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts b/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts index 4be77c2b896..b71f480cf7d 100644 --- a/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts +++ b/tests/e2e/specs/factory/NoSetupRepoFactory.spec.ts @@ -52,7 +52,7 @@ const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); const workspaces: Workspaces = e2eContainer.get(CLASSES.Workspaces); const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); -suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository without OAuth setup`, async function () { +suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository without OAuth setup`, async function (): Promise { let projectSection: ViewSection; let scmProvider: SingleScmProvider; @@ -74,26 +74,26 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE loginTests.loginIntoChe(); - test('Get number of previously created workspaces', async function () { + test('Get number of previously created workspaces', async function (): Promise { await dashboard.clickWorkspacesButton(); await workspaces.waitPage(); numberOfCreatedWorkspaces = (await workspaces.getAllCreatedWorkspacesNames()).length; }); - test(`Navigate to the ${isPrivateRepo} repository factory URL`, async function () { + test(`Navigate to the ${isPrivateRepo} repository factory URL`, async function (): Promise { await browserTabsUtil.navigateTo(TestConstants.TS_SELENIUM_FACTORY_URL()); }); if (TestConstants.TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO) { - test(`Check that workspace cannot be created without OAuth for ${isPrivateRepo} repo`, async function () { + test(`Check that workspace cannot be created without OAuth for ${isPrivateRepo} repo`, async function (): Promise { await dashboard.waitLoader(); const loaderAlert: string = await dashboard.getLoaderAlert(); expect(loaderAlert).contains('Failed to create the workspace') .and.contains('Cause: Unsupported OAuth provider '); }); - test(`Check that workspace was not created`, async function () { + test(`Check that workspace was not created`, async function (): Promise { await dashboard.openDashboard(); await dashboard.clickWorkspacesButton(); await workspaces.waitPage(); @@ -106,20 +106,20 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE } else { workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); - test('Registering the running workspace', async function () { + test('Registering the running workspace', async function (): Promise { registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName()); }); - test('Wait the workspace readiness', async function () { + test('Wait the workspace readiness', async function (): Promise { await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); }); - test('Check if a project folder has been created', async function () { + test('Check if a project folder has been created', async function (): Promise { Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`); projectSection = await new SideBarView().getContent().getSection(testRepoProjectName as unknown as string); }); - test('Accept the project as a trusted one', async function () { + test('Accept the project as a trusted one', async function (): Promise { // click somewhere to trigger "Welcome Content" dialog try { await driverHelper.waitAndClick(webCheCodeLocators.Workbench.notificationItem); @@ -142,14 +142,14 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE } }); - test('Check if the project files were imported', async function () { + test('Check if the project files were imported', async function (): Promise { Logger.debug(`projectSection.findItem: find ${label}`); const isFileImported: ViewItem | undefined = await projectSection.findItem(label); // projectSection.findItem(label) can return undefined but test will goes on expect(isFileImported).not.eqls(undefined); }); - test('Make changes to the file', async function () { + test('Make changes to the file', async function (): Promise { Logger.debug(`projectSection.openItem: "${fileToChange}"`); await projectSection.openItem(fileToChange); const editor: TextEditor = await new EditorView().openEditor(fileToChange) as TextEditor; @@ -160,7 +160,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE await editor.typeTextAt(1, 1, changesToCommit); }); - test('Open a source control manager', async function () { + test('Open a source control manager', async function (): Promise { const viewSourceControl: string = `Source Control`; const sourceControl: ViewControl = await new ActivityBar().getViewControl(viewSourceControl) as ViewControl; Logger.debug(`sourceControl.openView: "${viewSourceControl}"`); @@ -171,7 +171,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE Logger.debug(`scmView.getProviders: "${scmProvider}, ${scmProvider}"`); }); - test('Check if the changes is displayed in the source control manager', async function () { + test('Check if the changes is displayed in the source control manager', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); await driverHelper.wait(timeToRefresh); Logger.debug(`scmProvider.takeAction: "${refreshButtonLabel}"`); @@ -183,7 +183,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE expect(changes).eql(1); }); - test('Stage the changes', async function () { + test('Stage the changes', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); Logger.debug(`scmProvider.openMoreActions`); scmContextMenu = await scmProvider.openMoreActions(); @@ -192,7 +192,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE await scmContextMenu.select('Changes', 'Stage All Changes'); }); - test('Commit the changes', async function () { + test('Commit the changes', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel)); Logger.debug(`scmProvider.commitChanges: commit name "Commit ${changesToCommit}"`); await scmProvider.commitChanges('Commit ' + changesToCommit); @@ -207,7 +207,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE expect(changes).eql(0); }); - test('Push the changes', async function () { + test('Push the changes', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.actionConstructor(`Push 1 commits to origin/${TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_BRANCH}`)); await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); Logger.debug(`scmProvider.openMoreActions`); @@ -218,14 +218,14 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE }); if (TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER === GitProviderType.GITHUB) { - test('Decline GitHub Extension', async function () { + test('Decline GitHub Extension', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.Dialog.details); const gitHaExtensionDialog: ModalDialog = new ModalDialog(); await gitHaExtensionDialog.pushButton('Cancel'); }); } - test('Insert git credentials which were asked after push', async function () { + test('Insert git credentials which were asked after push', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); try { @@ -244,7 +244,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE await driverHelper.wait(timeToRefresh); }); - test('Check if the changes were pushed', async function () { + test('Check if the changes were pushed', async function (): Promise { try { Logger.debug(`scmProvider.takeAction: "${refreshButtonLabel}"`); await scmProvider.takeAction(refreshButtonLabel); @@ -257,14 +257,14 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE expect(isCommitButtonDisabled).eql('true'); }); - test(`Stop and remove the workspace`, async function () { + test(`Stop and remove the workspace`, async function (): Promise { await workspaceHandlingTests.stopAndRemoveWorkspace(WorkspaceHandlingTests.getWorkspaceName()); }); loginTests.logoutFromChe(); } - suiteTeardown('Close the browser', async function () { + suiteTeardown('Close the browser', async function (): Promise { if (!TestConstants.TS_DEBUG_MODE) { await driverHelper.getDriver().close(); } diff --git a/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts b/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts index 69eafc637b5..ce4ab098813 100644 --- a/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts +++ b/tests/e2e/specs/factory/RefusedOAuthFactory.spec.ts @@ -49,7 +49,7 @@ const webCheCodeLocators: Locators = new CheCodeLocatorLoader().webCheCodeLocato const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); -suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository and deny the access`, async function () { +suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER} repository and deny the access`, async function (): Promise { const oauthPage: OauthPage = new OauthPage(driverHelper); let projectSection: ViewSection; @@ -71,12 +71,12 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE loginTests.loginIntoChe(); - test(`Navigate to the ${isPrivateRepo} repository factory URL`, async function () { + test(`Navigate to the ${isPrivateRepo} repository factory URL`, async function (): Promise { await browserTabsUtil.navigateTo(TestConstants.TS_SELENIUM_FACTORY_URL()); }); if (TestConstants.TS_SELENIUM_GIT_PROVIDER_OAUTH) { - test(`Authorize with a ${TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER} OAuth and deny access`, async function () { + test(`Authorize with a ${TestConstants.TS_SELENIUM_FACTORY_GIT_PROVIDER} OAuth and deny access`, async function (): Promise { await oauthPage.login(); await oauthPage.waitOauthPage(); await oauthPage.denyAccess(); @@ -85,24 +85,24 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); - test('The workspace starts with access deny flag in the url', async function () { + test('The workspace starts with access deny flag in the url', async function (): Promise { expect(await driverHelper.getDriver().getCurrentUrl()).contains('&error_code=access_denied'); }); - test('Registering the running workspace', async function () { + test('Registering the running workspace', async function (): Promise { registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName()); }); - test('Wait the workspace readiness', async function () { + test('Wait the workspace readiness', async function (): Promise { await projectAndFileTests.waitWorkspaceReadinessForCheCodeEditor(); }); - test('Check if a project folder has been created', async function () { + test('Check if a project folder has been created', async function (): Promise { Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`); projectSection = await new SideBarView().getContent().getSection(testRepoProjectName as unknown as string); }); - test('Accept the project as a trusted one', async function () { + test('Accept the project as a trusted one', async function (): Promise { // click somewhere to trigger "Welcome Content" dialog try { await driverHelper.waitAndClick(webCheCodeLocators.Workbench.notificationItem); @@ -126,27 +126,27 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE }); if (TestConstants.TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO) { - test('Check that project can not be cloned', async function () { + test('Check that project can not be cloned', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.Dialog.message); const workspaceDoesNotExistDialog: ModalDialog = new ModalDialog(); const message: string = await workspaceDoesNotExistDialog.getMessage(); expect(message).contains('space does not exist'); }); - test('Check that project files were not imported', async function () { + test('Check that project files were not imported', async function (): Promise { const isFileImported: ViewItem | undefined = await projectSection.findItem(label); expect(isFileImported).eqls(undefined); }); } else { - test('Check if the project files were imported', async function () { + test('Check if the project files were imported', async function (): Promise { Logger.debug(`projectSection.findItem: find ${label}`); const isFileImported: ViewItem | undefined = await projectSection.findItem(label); // projectSection.findItem(label) can return undefined but test will goes on expect(isFileImported).not.eqls(undefined); }); - test('Make changes to the file', async function () { + test('Make changes to the file', async function (): Promise { Logger.debug(`projectSection.openItem: "${fileToChange}"`); await projectSection.openItem(fileToChange); const editor: TextEditor = await new EditorView().openEditor(fileToChange) as TextEditor; @@ -157,7 +157,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE await editor.typeTextAt(1, 1, changesToCommit); }); - test('Open a source control manager', async function () { + test('Open a source control manager', async function (): Promise { const viewSourceControl: string = `Source Control`; const sourceControl: ViewControl = await new ActivityBar().getViewControl(viewSourceControl) as ViewControl; Logger.debug(`sourceControl.openView: "${viewSourceControl}"`); @@ -168,7 +168,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE Logger.debug(`scmView.getProviders: "${scmProvider}, ${scmProvider}"`); }); - test('Check if the changes is displayed in the source control manager', async function () { + test('Check if the changes is displayed in the source control manager', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); await driverHelper.wait(timeToRefresh); Logger.debug(`scmProvider.takeAction: "${refreshButtonLabel}"`); @@ -180,7 +180,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE expect(changes).eql(1); }); - test('Stage the changes', async function () { + test('Stage the changes', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); Logger.debug(`scmProvider.openMoreActions`); scmContextMenu = await scmProvider.openMoreActions(); @@ -189,7 +189,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE await scmContextMenu.select('Changes', 'Stage All Changes'); }); - test('Commit the changes', async function () { + test('Commit the changes', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.actionConstructor(commitChangesButtonLabel)); Logger.debug(`scmProvider.commitChanges: commit name "Commit ${changesToCommit}"`); await scmProvider.commitChanges('Commit ' + changesToCommit); @@ -204,7 +204,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE expect(changes).eql(0); }); - test('Push the changes', async function () { + test('Push the changes', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.actionConstructor(`Push 1 commits to origin/${TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_BRANCH}`)); await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); Logger.debug(`scmProvider.openMoreActions`); @@ -214,7 +214,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE await scmContextMenu.select(pushItemLabel); }); - test('Insert git credentials which were asked after push', async function () { + test('Insert git credentials which were asked after push', async function (): Promise { await driverHelper.waitVisibility(webCheCodeLocators.ScmView.more); try { @@ -232,7 +232,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE await driverHelper.wait(timeToRefresh); }); - test('Check if the changes were pushed', async function () { + test('Check if the changes were pushed', async function (): Promise { try { Logger.debug(`scmProvider.takeAction: "${refreshButtonLabel}"`); await scmProvider.takeAction(refreshButtonLabel); @@ -246,13 +246,13 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE }); } - test(`Stop and remove the workspace`, async function () { + test(`Stop and remove the workspace`, async function (): Promise { await workspaceHandlingTests.stopAndRemoveWorkspace(WorkspaceHandlingTests.getWorkspaceName()); }); loginTests.logoutFromChe(); - suiteTeardown('Close the browser', async function () { + suiteTeardown('Close the browser', async function (): Promise { if (!TestConstants.TS_DEBUG_MODE) { await driverHelper.getDriver().close(); } diff --git a/tests/e2e/specs/miscellaneous/PredefinedNamespace.spec.ts b/tests/e2e/specs/miscellaneous/PredefinedNamespace.spec.ts index fc629051ddd..cd3478fb0ea 100644 --- a/tests/e2e/specs/miscellaneous/PredefinedNamespace.spec.ts +++ b/tests/e2e/specs/miscellaneous/PredefinedNamespace.spec.ts @@ -1,10 +1,10 @@ import { e2eContainer } from '../../configs/inversify.config'; import { assert } from 'chai'; -import { registerRunningWorkspace } from '../MochaHooks'; import { CLASSES } from '../../configs/inversify.types'; import { WorkspaceHandlingTests } from '../../tests-library/WorkspaceHandlingTests'; import { Logger } from '../../utils/Logger'; import { LoginTests } from '../../tests-library/LoginTests'; +import { registerRunningWorkspace } from '../MochaHooks'; const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); const util: any = require('node:util'); @@ -19,7 +19,7 @@ async function runShellScript(shellCommandToExecution: string): Promise return stdout; } -suite(`Create predefined workspace and check it `, async function () { +suite(`Create predefined workspace and check it `, async function (): Promise { let workspaceName: string = ''; const setEditRightsForUser: string = `oc adm policy add-role-to-user edit user -n ${predefinedNamespaceName}`; @@ -37,7 +37,7 @@ suite(`Create predefined workspace and check it `, async function () { ' che.eclipse.org/username: user\n' + 'EOF'; // create a predefined namespace for user using shell script and login into user dashboard - suiteSetup(async function () { + suiteSetup(async function (): Promise { Logger.info('Test prerequisites:'); Logger.info(' (1) there is OCP user with username and user password that have been set in the TS_SELENIUM_USERNAME and TS_SELENIUM_PASSWORD variables'); Logger.info(' (2) \'oc\' client installed and logged into test OCP cluster with admin rights.'); @@ -46,7 +46,7 @@ suite(`Create predefined workspace and check it `, async function () { await runShellScript(setEditRightsForUser); }); - suiteTeardown(async () => { + suiteTeardown(async (): Promise => { const workspaceName: string = WorkspaceHandlingTests.getWorkspaceName(); try { await runShellScript(deletePredefinedNamespace); @@ -61,7 +61,7 @@ suite(`Create predefined workspace and check it `, async function () { workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); // verify that just created workspace with unique name is present in the predefined namespace - test('Validate the created workspace is present in predefined namespace', async function () { + test('Validate the created workspace is present in predefined namespace', async function (): Promise { workspaceName = WorkspaceHandlingTests.getWorkspaceName(); registerRunningWorkspace(workspaceName); const ocDevWorkspaceOutput: string = await runShellScript(getDevWorkspaceFromPredefinedNameSpace); diff --git a/tests/e2e/tslint.json b/tests/e2e/tslint.json index 33b0d3f8587..ce5a2b93abb 100644 --- a/tests/e2e/tslint.json +++ b/tests/e2e/tslint.json @@ -95,11 +95,11 @@ ], "typedef": [ true, - // "call-signature", - // "member-variable-declaration", + "call-signature", + "member-variable-declaration", "parameter", - "property-declaration" - // "variable-declaration" + "property-declaration", + "variable-declaration" ], "typedef-whitespace": [ true, diff --git a/tests/e2e/utils/BrowserTabsUtil.ts b/tests/e2e/utils/BrowserTabsUtil.ts index 655dd85fd4e..efb0f7256d8 100644 --- a/tests/e2e/utils/BrowserTabsUtil.ts +++ b/tests/e2e/utils/BrowserTabsUtil.ts @@ -18,7 +18,7 @@ import { TimeoutConstants } from '../constants/TimeoutConstants'; export class BrowserTabsUtil { constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { } - async switchToWindow(windowHandle: string) { + async switchToWindow(windowHandle: string): Promise { Logger.debug('BrowserTabsUtil.switchToWindow'); await this.driverHelper.getDriver().switchTo().window(windowHandle); } @@ -35,20 +35,20 @@ export class BrowserTabsUtil { return await this.driverHelper.getDriver().getWindowHandle(); } - async navigateTo(url: string) { + async navigateTo(url: string): Promise { Logger.debug(`BrowserTabsUtil.navigateTo ${url}`); await this.driverHelper.getDriver().navigate().to(url); } - async navigateAndWaitToUrl(url: string, timeout: number = TimeoutConstants.TS_SELENIUM_WAIT_FOR_URL) { + async navigateAndWaitToUrl(url: string, timeout: number = TimeoutConstants.TS_SELENIUM_WAIT_FOR_URL): Promise { Logger.trace(`BrowserTabsUtil.navigateAndWaitToUrl ${url}`); await this.navigateTo(url); await this.waitURL(url, timeout); } - async waitAndSwitchToAnotherWindow(currentWindowHandle: string, timeout: number) { + async waitAndSwitchToAnotherWindow(currentWindowHandle: string, timeout: number): Promise { Logger.debug('BrowserTabsUtil.waitAndSwitchToAnotherWindow'); await this.driverHelper.waitUntilTrue(async () => { @@ -66,7 +66,7 @@ export class BrowserTabsUtil { } } - async refreshPage() { + async refreshPage(): Promise { Logger.debug('BrowserTabsUtil.refreshPage'); await (await this.driverHelper.getDriver()).navigate().refresh(); @@ -76,7 +76,7 @@ export class BrowserTabsUtil { return await this.driverHelper.getDriver().getCurrentUrl(); } - async waitURL(expectedUrl: string, timeout: number) { + async waitURL(expectedUrl: string, timeout: number): Promise { Logger.trace(`BrowserTabsUtil.waitURL ${expectedUrl}`); await this.driverHelper.getDriver().wait(async () => { @@ -89,7 +89,7 @@ export class BrowserTabsUtil { }, timeout); } - public async maximize() { + public async maximize(): Promise { Logger.trace(`BrowserTabsUtil.maximize`); await this.driverHelper.getDriver().manage().window().maximize(); diff --git a/tests/e2e/utils/CheReporter.ts b/tests/e2e/utils/CheReporter.ts index 5b16cbee84b..f8b8b5e1a26 100644 --- a/tests/e2e/utils/CheReporter.ts +++ b/tests/e2e/utils/CheReporter.ts @@ -20,6 +20,7 @@ import { TimeoutConstants } from '../constants/TimeoutConstants'; import { Logger } from './Logger'; import { Sanitizer } from './Sanitizer'; import { e2eContainer } from '../configs/inversify.config'; +import { WriteStream } from 'fs'; const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); const screenCatcher: ScreenCatcher = e2eContainer.get(CLASSES.ScreenCatcher); @@ -35,7 +36,7 @@ class CheReporter extends mocha.reporters.Spec { constructor(runner: mocha.Runner, options: mocha.MochaOptions) { super(runner, options); - runner.on('start', async (test: mocha.Test) => { + runner.on('start', async () => { let launchInformation: string = `################## Launch Information ################## @@ -76,7 +77,7 @@ class CheReporter extends mocha.reporters.Spec { rm.sync(TestConstants.TS_SELENIUM_REPORT_FOLDER); }); - runner.on('test', async function (test: mocha.Test) { + runner.on('test', async function (test: mocha.Test): Promise { if (!TestConstants.TS_SELENIUM_EXECUTION_SCREENCAST) { return; } @@ -97,7 +98,7 @@ class CheReporter extends mocha.reporters.Spec { if (TestConstants.TS_LOAD_TESTS) { const loadTestReportFolder: string = TestConstants.TS_SELENIUM_LOAD_TEST_REPORT_FOLDER; const loadTestFilePath: string = loadTestReportFolder + '/load-test-results.txt'; - const report = test.title + ': ' + test.duration + '\r'; + const report: string = test.title + ': ' + test.duration + '\r'; if (!fs.existsSync(loadTestReportFolder)) { fs.mkdirSync(loadTestReportFolder); } @@ -106,7 +107,7 @@ class CheReporter extends mocha.reporters.Spec { }); - runner.on('end', async function (test: mocha.Test) { + runner.on('end', async function (): Promise { // ensure that fired events done await driverHelper.wait(5000); @@ -119,7 +120,7 @@ class CheReporter extends mocha.reporters.Spec { } }); - runner.on('fail', async function (test: mocha.Test) { + runner.on('fail', async function (test: mocha.Test): Promise { Logger.error(`CheReporter runner.on.fail: ${test.fullTitle()} failed after ${test.duration}ms`); // raise flag for keeping the screencast deleteScreencast = false; @@ -153,13 +154,13 @@ class CheReporter extends mocha.reporters.Spec { // take screenshot and write to file const screenshot: string = await driverHelper.getDriver().takeScreenshot(); - const screenshotStream = fs.createWriteStream(screenshotFileName); + const screenshotStream: WriteStream = fs.createWriteStream(screenshotFileName); screenshotStream.write(Buffer.from(screenshot, 'base64')); screenshotStream.end(); // take pagesource and write to file const pageSource: string = await driverHelper.getDriver().getPageSource(); - const pageSourceStream = fs.createWriteStream(pageSourceFileName); + const pageSourceStream: WriteStream = fs.createWriteStream(pageSourceFileName); pageSourceStream.write(Buffer.from(pageSource)); pageSourceStream.end(); @@ -171,7 +172,7 @@ class CheReporter extends mocha.reporters.Spec { browserLogs += `\"${log.level}\" \"${log.type}\" \"${log.message}\"\n`; }); - const browserLogsStream = fs.createWriteStream(browserLogsFileName); + const browserLogsStream: WriteStream = fs.createWriteStream(browserLogsFileName); browserLogsStream.write(Buffer.from(browserLogs)); browserLogsStream.end(); diff --git a/tests/e2e/utils/DriverHelper.ts b/tests/e2e/utils/DriverHelper.ts index 844b5d825d0..921b7f560c5 100644 --- a/tests/e2e/utils/DriverHelper.ts +++ b/tests/e2e/utils/DriverHelper.ts @@ -42,7 +42,7 @@ export class DriverHelper { } } - public async wait(milliseconds: number) { + public async wait(milliseconds: number): Promise { Logger.trace(`DriverHelper.wait (${milliseconds} milliseconds)`); await this.driver.sleep(milliseconds); @@ -54,7 +54,7 @@ export class DriverHelper { Logger.trace(`DriverHelper.waitVisibilityBoolean ${locator}`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { const isVisible: boolean = await this.isVisible(locator); if (isVisible) { @@ -73,7 +73,7 @@ export class DriverHelper { Logger.trace(`DriverHelper.waitDisappearanceBoolean ${locator}`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { const isVisible: boolean = await this.isVisible(locator); if (!isVisible) { @@ -92,7 +92,7 @@ export class DriverHelper { Logger.trace(`DriverHelper.waitVisibility ${elementLocator}`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { let element: WebElement; try { element = await this.driver.wait(until.elementLocated(elementLocator), polling); @@ -119,7 +119,7 @@ export class DriverHelper { } try { - const visibleWebElement = await this.driver.wait(until.elementIsVisible(element), polling); + const visibleWebElement: WebElement = await this.driver.wait(until.elementIsVisible(element), polling); Logger.trace('DriverHelper.waitVisibility - Element is located and is visible.'); return visibleWebElement; } catch (err) { @@ -150,7 +150,7 @@ export class DriverHelper { Logger.trace(`DriverHelper.waitPresence ${elementLocator}`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { try { return await this.driver.wait(until.elementLocated(elementLocator), polling); } catch (err) { @@ -178,7 +178,7 @@ export class DriverHelper { Logger.trace(`DriverHelper.waitAllPresence ${elementLocator}`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { try { return await this.driver.wait(until.elementsLocated(elementLocator), polling); } catch (err) { @@ -200,7 +200,7 @@ export class DriverHelper { throw new error.TimeoutError(`Exceeded maximum presence checkings attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`); } - public async waitAllVisibility(locators: Array, timeout: number) { + public async waitAllVisibility(locators: Array, timeout: number): Promise { Logger.trace(`DriverHelper.waitAllVisibility ${locators}`); for (const elementLocator of locators) { @@ -210,18 +210,18 @@ export class DriverHelper { public async waitDisappearance(elementLocator: By, attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS, - polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING) { + polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING): Promise { Logger.trace(`DriverHelper.waitDisappearance ${elementLocator}`); - const isDisappeared = await this.waitDisappearanceBoolean(elementLocator, attempts, polling); + const isDisappeared: boolean = await this.waitDisappearanceBoolean(elementLocator, attempts, polling); if (!isDisappeared) { throw new error.TimeoutError(`Waiting attempts exceeded, element '${elementLocator}' is still visible`); } } - public async waitDisappearanceWithTimeout(elementLocator: By, timeout: number) { + public async waitDisappearanceWithTimeout(elementLocator: By, timeout: number): Promise { Logger.trace(`DriverHelper.waitDisappearanceWithTimeout ${elementLocator}`); await this.getDriver().wait(async () => { @@ -235,7 +235,7 @@ export class DriverHelper { public async waitAllDisappearance(locators: Array, attemptsPerLocator: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS, - pollingPerLocator: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING) { + pollingPerLocator: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING): Promise { Logger.trace(`DriverHelper.waitAllDisappearance ${locators}`); @@ -244,13 +244,13 @@ export class DriverHelper { } } - public async waitAndClick(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM) { + public async waitAndClick(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise { const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING; const attempts: number = Math.ceil(timeout / polling); Logger.trace(`DriverHelper.waitAndClick ${elementLocator}`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { let element: WebElement; try { element = await this.waitVisibility(elementLocator, polling); @@ -294,7 +294,7 @@ export class DriverHelper { Logger.trace(`DriverHelper.waitAndGetElementAttribute ${elementLocator} attribute: '${attribute}'`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { let element: WebElement; try { element = await this.waitVisibility(elementLocator, polling); @@ -336,7 +336,7 @@ export class DriverHelper { Logger.trace(`DriverHelper.waitAndGetCssValue ${elementLocator} cssAttribute: ${cssAttribute}`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { let element: WebElement; try { element = await this.waitVisibility(elementLocator, polling); @@ -374,7 +374,7 @@ export class DriverHelper { public async waitAttributeValue(elementLocator: By, attribute: string, expectedValue: string, - timeout: number) { + timeout: number): Promise { Logger.trace(`DriverHelper.waitAttributeValue ${elementLocator}`); @@ -387,7 +387,7 @@ export class DriverHelper { `The '${attribute}' attribute value doesn't match with expected value '${expectedValue}'`); } - public async type(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM) { + public async type(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise { const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING; const attempts: number = Math.ceil(timeout / polling); @@ -397,7 +397,7 @@ export class DriverHelper { Logger.trace(`DriverHelper.type ${elementLocator} text: ${text}`); } - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { let element: WebElement; try { element = await this.waitVisibility(elementLocator, polling); @@ -433,13 +433,13 @@ export class DriverHelper { throw new error.TimeoutError(`Exceeded maximum typing attempts, to the '${elementLocator}' element`); } - public async typeToInvisible(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM) { + public async typeToInvisible(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise { const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING; const attempts: number = Math.ceil(timeout / polling); Logger.trace(`DriverHelper.typeToInvisible ${elementLocator} text: ${text}`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { let element: WebElement; try { element = await this.waitPresence(elementLocator, polling); @@ -475,13 +475,13 @@ export class DriverHelper { throw new error.TimeoutError(`Exceeded maximum typing attempts, to the '${elementLocator}' element`); } - public async clear(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM) { + public async clear(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise { const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING; const attempts: number = Math.ceil(timeout / polling); Logger.trace(`DriverHelper.clear ${elementLocator}`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { let element: WebElement; try { element = await this.waitVisibility(elementLocator, polling); @@ -517,13 +517,13 @@ export class DriverHelper { throw new error.TimeoutError(`Exceeded maximum clearing attempts, to the '${elementLocator}' element`); } - public async clearInvisible(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM) { + public async clearInvisible(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise { const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING; const attempts: number = Math.ceil(timeout / polling); Logger.trace(`DriverHelper.clearInvisible ${elementLocator}`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { let element: WebElement; try { element = await this.waitPresence(elementLocator, polling); @@ -559,7 +559,7 @@ export class DriverHelper { throw new error.TimeoutError(`Exceeded maximum clearing attempts, to the '${elementLocator}' element`); } - public async enterValue(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM) { + public async enterValue(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise { if (elementLocator.toString().toLocaleLowerCase().includes('password')) { Logger.trace(`DriverHelper.enterValue ${elementLocator} text: ***`); } else { @@ -573,7 +573,7 @@ export class DriverHelper { await this.waitAttributeValue(elementLocator, 'value', text, timeout); } - public async waitAndSwitchToFrame(iframeLocator: By, timeout: number) { + public async waitAndSwitchToFrame(iframeLocator: By, timeout: number): Promise { Logger.trace(`DriverHelper.waitAndSwitchToFrame ${iframeLocator}`); await this.driver.wait(until.ableToSwitchToFrame(iframeLocator), timeout); @@ -585,7 +585,7 @@ export class DriverHelper { Logger.trace(`DriverHelper.waitAndGetText ${elementLocator}`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { let element: WebElement; try { element = await this.waitVisibility(elementLocator, polling); @@ -626,19 +626,19 @@ export class DriverHelper { return await this.waitAndGetElementAttribute(elementLocator, 'value', timeout); } - public async waitUntilTrue(callback: any, timeout: number) { + public async waitUntilTrue(callback: any, timeout: number): Promise { Logger.trace('DriverHelper.waitUntilTrue'); await this.driver.wait(callback, timeout); } - public async scrollTo(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM) { + public async scrollTo(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise { const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING; const attempts: number = Math.ceil(timeout / polling); Logger.trace(`DriverHelper.scrollTo ${elementLocator}`); - for (let i = 0; i < attempts; i++) { + for (let i: number = 0; i < attempts; i++) { let element: WebElement; try { element = await this.waitPresence(elementLocator, polling); diff --git a/tests/e2e/utils/Logger.ts b/tests/e2e/utils/Logger.ts index 509dca3e6be..739465fcee7 100644 --- a/tests/e2e/utils/Logger.ts +++ b/tests/e2e/utils/Logger.ts @@ -17,7 +17,7 @@ export abstract class Logger { * @param text log text * @param indentLevel log level */ - public static error(text: string, indentLevel: number = 1) { + public static error(text: string, indentLevel: number = 1): void { this.logText(indentLevel, `[ERROR] ${text}`); } @@ -26,7 +26,7 @@ export abstract class Logger { * @param text log text * @param indentLevel log level */ - public static warn(text: string, indentLevel: number = 1) { + public static warn(text: string, indentLevel: number = 1): void { if (TestConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR') { return; } @@ -38,7 +38,7 @@ export abstract class Logger { * @param text log text * @param indentLevel log level */ - public static info(text: string, indentLevel: number = 3) { + public static info(text: string, indentLevel: number = 3): void { if (TestConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' || TestConstants.TS_SELENIUM_LOG_LEVEL === 'WARN') { return; @@ -51,7 +51,7 @@ export abstract class Logger { * @param text log text * @param indentLevel log level */ - public static debug(text: string, indentLevel: number = 5) { + public static debug(text: string, indentLevel: number = 5): void { if (TestConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' || TestConstants.TS_SELENIUM_LOG_LEVEL === 'WARN' || TestConstants.TS_SELENIUM_LOG_LEVEL === 'INFO') { @@ -66,7 +66,7 @@ export abstract class Logger { * @param text log text * @param indentLevel log level */ - public static trace(text: string, indentLevel: number = 6) { + public static trace(text: string, indentLevel: number = 6): void { if (TestConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' || TestConstants.TS_SELENIUM_LOG_LEVEL === 'WARN' || TestConstants.TS_SELENIUM_LOG_LEVEL === 'INFO' || @@ -76,16 +76,16 @@ export abstract class Logger { this.logText(indentLevel, `‣ ${text}`); } - private static logText(messageIndentationLevel: number, text: string) { + private static logText(messageIndentationLevel: number, text: string): void { // start group for every level - for (let i = 0; i < messageIndentationLevel; i++) { + for (let i: number = 0; i < messageIndentationLevel; i++) { console.group(); } // print the trimmed text // if multiline, the message should be properly padded console.log(text); // end group for every level - for (let i = 0; i < messageIndentationLevel; i++) { + for (let i: number = 0; i < messageIndentationLevel; i++) { console.groupEnd(); } } diff --git a/tests/e2e/utils/ScreenCatcher.ts b/tests/e2e/utils/ScreenCatcher.ts index b694b8c3e2f..bb09bd215f5 100644 --- a/tests/e2e/utils/ScreenCatcher.ts +++ b/tests/e2e/utils/ScreenCatcher.ts @@ -14,15 +14,16 @@ import { DriverHelper } from './DriverHelper'; import { Sanitizer } from './Sanitizer'; import { error } from 'selenium-webdriver'; import { TestConstants } from '../constants/TestConstants'; +import { WriteStream } from 'fs'; @injectable() export class ScreenCatcher { constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper, @inject(CLASSES.Sanitizer) private readonly sanitizer: Sanitizer) { } - async catchMethodScreen(methodName: string, methodIndex: number, screenshotIndex: number) { - const executionScreenCastDir = `${TestConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencast`; - const executionScreenCastErrorsDir = `${TestConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencastErrors`; + async catchMethodScreen(methodName: string, methodIndex: number, screenshotIndex: number): Promise { + const executionScreenCastDir: string = `${TestConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencast`; + const executionScreenCastErrorsDir: string = `${TestConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencastErrors`; const formattedMethodIndex: string = new Intl.NumberFormat('en-us', { minimumIntegerDigits: 3 }).format(methodIndex); const formattedScreenshotIndex: string = new Intl.NumberFormat('en-us', { minimumIntegerDigits: 5 }).format(screenshotIndex).replace(/,/g, ''); @@ -54,18 +55,18 @@ export class ScreenCatcher { } } - async catchScreen(screenshotPath: string) { + async catchScreen(screenshotPath: string): Promise { const screenshot: string = await this.driverHelper.getDriver().takeScreenshot(); - const screenshotStream = fs.createWriteStream(screenshotPath); + const screenshotStream: WriteStream = fs.createWriteStream(screenshotPath); screenshotStream.write(Buffer.from(screenshot, 'base64')); screenshotStream.end(); } - async writeErrorLog(errorLogPath: string, err: error.IError) { + async writeErrorLog(errorLogPath: string, err: error.IError): Promise { console.log(`Failed to save screenshot, additional information in the ${errorLogPath}`); if (err.stack) { - const screenshotStream = fs.createWriteStream(errorLogPath); + const screenshotStream: WriteStream = fs.createWriteStream(errorLogPath); screenshotStream.write(Buffer.from(err.stack, 'utf8')); screenshotStream.end(); } diff --git a/tests/e2e/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts b/tests/e2e/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts index cee829bab63..b56f148fa63 100644 --- a/tests/e2e/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +++ b/tests/e2e/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts @@ -13,6 +13,7 @@ import { inject, injectable } from 'inversify'; import { DriverHelper } from '../../DriverHelper'; import { CLASSES } from '../../../configs/inversify.types'; import { Logger } from '../../Logger'; +import { IWebDriverCookie } from 'selenium-webdriver'; @injectable() export class CheMultiuserAuthorizationHeaderHandler implements IAuthorizationHeaderHandler { @@ -22,7 +23,7 @@ export class CheMultiuserAuthorizationHeaderHandler implements IAuthorizationHea async get(): Promise { try { - let token = await this.driverHelper.getDriver().manage().getCookie('_oauth_proxy'); + let token: IWebDriverCookie = await this.driverHelper.getDriver().manage().getCookie('_oauth_proxy'); if (this.authorizationToken !== token.value) { this.authorizationToken = token.value; } diff --git a/tests/e2e/utils/vsc/GitUtil.ts b/tests/e2e/utils/vsc/GitUtil.ts index 94ba5aa8c35..0d0d7bcb8d5 100644 --- a/tests/e2e/utils/vsc/GitUtil.ts +++ b/tests/e2e/utils/vsc/GitUtil.ts @@ -19,7 +19,7 @@ export class GitUtil { * @param url git https url (which using for "git clone") * @return project name */ - getProjectNameFromGitUrl(url: string) { + getProjectNameFromGitUrl(url: string): string { return url.split(/[\/.]/).filter((e: string) => e !== '' && e !== 'git').reverse()[0]; } } diff --git a/tests/e2e/utils/workspace/ApiUrlResolver.ts b/tests/e2e/utils/workspace/ApiUrlResolver.ts index 2603048b507..7a95eb277ab 100644 --- a/tests/e2e/utils/workspace/ApiUrlResolver.ts +++ b/tests/e2e/utils/workspace/ApiUrlResolver.ts @@ -11,6 +11,7 @@ import { inject, injectable } from 'inversify'; import { CLASSES } from '../../configs/inversify.types'; import { Logger } from '../Logger'; import { CheApiRequestHandler } from '../request-handlers/CheApiRequestHandler'; +import { AxiosResponse } from 'axios'; @injectable() export class ApiUrlResolver { @@ -26,7 +27,7 @@ export class ApiUrlResolver { } public async getWorkspacesApiUrl(): Promise { - const namespace = await this.obtainUserNamespace(); + const namespace: string = await this.obtainUserNamespace(); return `${ApiUrlResolver.DASHBOARD_API_URL}/${namespace}/devworkspaces`; } @@ -34,7 +35,7 @@ export class ApiUrlResolver { Logger.debug(`ApiUrlResolver.obtainUserNamespace ${this.userNamespace}`); if (this.userNamespace.length === 0) { Logger.trace(`ApiUrlResolver.obtainUserNamespace USER_NAMESPACE.length = 0, calling kubernetes API`); - const kubernetesResponse = await this.processRequestHandler.get(ApiUrlResolver.KUBERNETES_API_URL); + const kubernetesResponse: AxiosResponse = await this.processRequestHandler.get(ApiUrlResolver.KUBERNETES_API_URL); if (kubernetesResponse.status !== 200) { throw new Error(`Cannot get user namespace from kubernetes API. Code: ${kubernetesResponse.status} Data: ${kubernetesResponse.data}`); } diff --git a/tests/e2e/utils/workspace/TestWorkspaceUtil.ts b/tests/e2e/utils/workspace/TestWorkspaceUtil.ts index e19c8e74314..d8eb1bf752f 100644 --- a/tests/e2e/utils/workspace/TestWorkspaceUtil.ts +++ b/tests/e2e/utils/workspace/TestWorkspaceUtil.ts @@ -17,7 +17,7 @@ import { error } from 'selenium-webdriver'; import { CheApiRequestHandler } from '../request-handlers/CheApiRequestHandler'; import { CLASSES } from '../../configs/inversify.types'; import { Logger } from '../Logger'; -import axios from 'axios'; +import axios, { AxiosResponse } from 'axios'; import { ITestWorkspaceUtil } from './ITestWorkspaceUtil'; import { ApiUrlResolver } from './ApiUrlResolver'; @@ -32,13 +32,13 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil { @inject(CLASSES.ApiUrlResolver) private readonly apiUrlResolver: ApiUrlResolver ) { } - public async waitWorkspaceStatus(workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus) { + public async waitWorkspaceStatus(workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus): Promise { Logger.debug('TestWorkspaceUtil.waitWorkspaceStatus'); let workspaceStatus: string = ''; let expectedStatus: boolean = false; - for (let i = 0; i < this.attempts; i++) { - const response = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspaceApiUrl(workspaceName)); + for (let i: number = 0; i < this.attempts; i++) { + const response: AxiosResponse = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspaceApiUrl(workspaceName)); if (response.status !== 200) { throw new Error(`Can not get status of a workspace. Code: ${response.status} Data: ${response.data}`); @@ -55,16 +55,16 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil { } if (!expectedStatus) { - let waitTime = this.attempts * this.polling; - throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms. Currnet status is: ${workspaceStatus}`); + let waitTime: number = this.attempts * this.polling; + throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms. Current status is: ${workspaceStatus}`); } } - public async stopWorkspaceByName(workspaceName: string) { + public async stopWorkspaceByName(workspaceName: string): Promise { Logger.debug('TestWorkspaceUtil.stopWorkspaceByName'); const stopWorkspaceApiUrl: string = await this.apiUrlResolver.getWorkspaceApiUrl(workspaceName); - let stopWorkspaceResponse; + let stopWorkspaceResponse: AxiosResponse; try { stopWorkspaceResponse = await this.processRequestHandler.patch(stopWorkspaceApiUrl, [{'op': 'replace', 'path': '/spec/started', 'value': false}]); @@ -81,11 +81,11 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil { } // delete a workspace without stopping phase (similar with force deleting) - public async deleteWorkspaceByName(workspaceName: string) { + public async deleteWorkspaceByName(workspaceName: string): Promise { Logger.debug(`TestWorkspaceUtil.deleteWorkspaceByName ${workspaceName}` ); const deleteWorkspaceApiUrl: string = await this.apiUrlResolver.getWorkspaceApiUrl(workspaceName); - let deleteWorkspaceResponse; + let deleteWorkspaceResponse: AxiosResponse; let deleteWorkspaceStatus: boolean = false; try { deleteWorkspaceResponse = await this.processRequestHandler.delete(deleteWorkspaceApiUrl); @@ -102,7 +102,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil { throw new Error(`Can not delete workspace. Code: ${deleteWorkspaceResponse.status} Data: ${deleteWorkspaceResponse.data}`); } - for (let i = 0; i < this.attempts; i++) { + for (let i: number = 0; i < this.attempts; i++) { try { deleteWorkspaceResponse = await this.processRequestHandler.get(deleteWorkspaceApiUrl); } catch (error) { @@ -114,13 +114,13 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil { } if (!deleteWorkspaceStatus) { - let waitTime = this.attempts * this.polling; + let waitTime: number = this.attempts * this.polling; throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms.`); } } // stop workspace before deleting with checking stopping phase - public async stopAndDeleteWorkspaceByName(workspaceName: string) { + public async stopAndDeleteWorkspaceByName(workspaceName: string): Promise { Logger.debug('TestWorkspaceUtil.stopAndDeleteWorkspaceByName'); await this.stopWorkspaceByName(workspaceName); @@ -128,21 +128,21 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil { } // stop all run workspaces in the namespace - public async stopAllRunningWorkspaces(namespace: string) { + public async stopAllRunningWorkspaces(namespace: string): Promise { Logger.debug('TestWorkspaceUtil.stopAllRunProjects'); - let response = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl()); - for (let i = 0; i < response.data.items.length; i++) { + let response: AxiosResponse = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl()); + for (let i: number = 0; i < response.data.items.length; i++) { Logger.info('The project is being stopped: ' + response.data.items[i].metadata.name); await this.stopWorkspaceByName(response.data.items[i].metadata.name); } } // stop all run workspaces, check statuses and remove the workspaces - public async stopAndDeleteAllRunningWorkspaces(namespace: string) { + public async stopAndDeleteAllRunningWorkspaces(namespace: string): Promise { Logger.debug('TestWorkspaceUtil.stopAndDeleteAllRunProjects'); - let response = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl()); + let response: AxiosResponse = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl()); await this.stopAllRunningWorkspaces(namespace); - for (let i = 0; i < response.data.items.length; i++) { + for (let i: number = 0; i < response.data.items.length; i++) { Logger.info('The project is being deleted: ' + response.data.items[i].metadata.name); await this.deleteWorkspaceByName(response.data.items[i].metadata.name); } @@ -150,11 +150,11 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil { // stop all run workspaces without stopping and waiting for of 'Stopped' phase // similar with 'force' deleting - public async deleteAllWorkspaces(namespace: string) { + public async deleteAllWorkspaces(namespace: string): Promise { Logger.debug('TestWorkspaceUtil.deleteAllRunProjects'); - let response = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl()); + let response: AxiosResponse = await this.processRequestHandler.get(await this.apiUrlResolver.getWorkspacesApiUrl()); - for (let i = 0; i < response.data.items.length; i++) { + for (let i: number = 0; i < response.data.items.length; i++) { Logger.info('The project is being deleted .......: ' + response.data.items[i].metadata.name); await this.deleteWorkspaceByName(response.data.items[i].metadata.name); }