From 1bebab75a175fc53688e0891064b23fefba8d50c Mon Sep 17 00:00:00 2001 From: kkanova Date: Wed, 14 Aug 2019 13:47:03 +0200 Subject: [PATCH] Working version Signed-off-by: kkanova --- e2e/TestConstants.ts | 7 +- e2e/driver/CheReporter.ts | 11 +++ e2e/driver/ContainerInitializer.ts | 77 +++++++++++++++++++ e2e/index.ts | 3 + e2e/inversify.config.ts | 67 +--------------- e2e/inversify.types.ts | 4 +- e2e/pageobjects/dashboard/NewWorkspace.ts | 6 +- .../workspace-details/WorkspaceDetails.ts | 7 +- .../WorkspaceDetailsPlugins.ts | 7 +- e2e/pageobjects/ide/Ide.ts | 7 +- e2e/tslint.json | 2 +- e2e/utils/workspace/ITestWorkspaceUtil.ts | 19 +++++ e2e/utils/workspace/TestWorkspaceUtil.ts | 22 ++++-- e2e/utils/workspace/WorkspaceStatus.ts | 15 ++++ 14 files changed, 168 insertions(+), 86 deletions(-) create mode 100644 e2e/driver/ContainerInitializer.ts create mode 100644 e2e/utils/workspace/ITestWorkspaceUtil.ts create mode 100644 e2e/utils/workspace/WorkspaceStatus.ts diff --git a/e2e/TestConstants.ts b/e2e/TestConstants.ts index f47cf052a2..b2aedad8a8 100644 --- a/e2e/TestConstants.ts +++ b/e2e/TestConstants.ts @@ -152,5 +152,10 @@ export const TestConstants = { /** * Remote driver URL. */ - TS_SELENIUM_REMOTE_DRIVER_URL: process.env.TS_SELENIUM_REMOTE_DRIVER_URL || '' + TS_SELENIUM_REMOTE_DRIVER_URL: process.env.TS_SELENIUM_REMOTE_DRIVER_URL || '', + + /** + * Stop and remove workspace if a test fails. + */ + DELETE_WORKSPACE_ON_FAILED_TEST: process.env.DELETE_WORKSPACE_ON_FAILED_TEST || 'false' }; diff --git a/e2e/driver/CheReporter.ts b/e2e/driver/CheReporter.ts index f9a1c6510f..d0cd786742 100644 --- a/e2e/driver/CheReporter.ts +++ b/e2e/driver/CheReporter.ts @@ -17,12 +17,14 @@ import { TestConstants } from '../TestConstants'; import { logging } from 'selenium-webdriver'; import { DriverHelper } from '../utils/DriverHelper'; import { ScreenCatcher } from '../utils/ScreenCatcher'; +import { ITestWorkspaceUtil } from '../utils/workspace/ITestWorkspaceUtil'; const driver: IDriver = e2eContainer.get(TYPES.Driver); const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); const screenCatcher: ScreenCatcher = e2eContainer.get(CLASSES.ScreenCatcher); let methodIndex: number = 0; let deleteScreencast: boolean = true; +let testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); class CheReporter extends mocha.reporters.Spec { constructor(runner: mocha.Runner, options: mocha.MochaOptions) { @@ -153,6 +155,15 @@ class CheReporter extends mocha.reporters.Spec { const browserLogsStream = fs.createWriteStream(browserLogsFileName); browserLogsStream.write(new Buffer(browserLogs)); browserLogsStream.end(); + + // stop and remove running workspace + if (TestConstants.DELETE_WORKSPACE_ON_FAILED_TEST) { + console.log("Property DELETE_WORKSPACE_ON_FAILED_TEST se to true - trying to stop and delete running workspace.") + let namespace = TestConstants.TS_SELENIUM_USERNAME; + let workspaceId = await testWorkspaceUtil.getIdOfRunningWorkspace(namespace); + testWorkspaceUtil.stopWorkspaceById(workspaceId); + testWorkspaceUtil.removeWorkspaceById(workspaceId); + } }); } } diff --git a/e2e/driver/ContainerInitializer.ts b/e2e/driver/ContainerInitializer.ts new file mode 100644 index 0000000000..7f2d8f1ac7 --- /dev/null +++ b/e2e/driver/ContainerInitializer.ts @@ -0,0 +1,77 @@ +/********************************************************************* + * Copyright (c) 2019 Red Hat, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + **********************************************************************/ +import { Container } from 'inversify'; +import { IDriver } from './IDriver'; +import { TYPES, CLASSES } from '../inversify.types'; +import { ChromeDriver } from './ChromeDriver'; +import { DriverHelper } from '../utils/DriverHelper'; +import { ICheLoginPage } from '../pageobjects/login/ICheLoginPage'; +import { IOcpLoginPage } from '../pageobjects/login/IOcpLoginPage'; +import { SingleUserLoginPage } from '../pageobjects/login/SingleUserLoginPage'; +import { Dashboard } from '../pageobjects/dashboard/Dashboard'; +import { Workspaces } from '../pageobjects/dashboard/Workspaces'; +import { NewWorkspace } from '../pageobjects/dashboard/NewWorkspace'; +import { WorkspaceDetails } from '../pageobjects/dashboard/workspace-details/WorkspaceDetails'; +import { WorkspaceDetailsPlugins } from '../pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins'; +import { Ide } from '../pageobjects/ide/Ide'; +import { TestWorkspaceUtil } from '../utils/workspace/TestWorkspaceUtil'; +import { ProjectTree } from '../pageobjects/ide/ProjectTree'; +import { Editor } from '../pageobjects/ide/Editor'; +import { TopMenu } from '../pageobjects/ide/TopMenu'; +import { QuickOpenContainer } from '../pageobjects/ide/QuickOpenContainer'; +import { PreviewWidget } from '../pageobjects/ide/PreviewWidget'; +import { GitHubPlugin } from '../pageobjects/ide/GitHubPlugin'; +import { RightToolbar } from '../pageobjects/ide/RightToolbar'; +import { Terminal } from '../pageobjects/ide/Terminal'; +import { DebugView } from '../pageobjects/ide/DebugView'; +import { WarningDialog } from '../pageobjects/ide/WarningDialog'; +import { ScreenCatcher } from '../utils/ScreenCatcher'; +import { MultiUserLoginPage } from '../pageobjects/login/MultiUserLoginPage'; +import { TestConstants } from '../TestConstants'; +import { OcpLoginPage } from '../pageobjects/openshift/OcpLoginPage'; +import { OcpWebConsolePage } from '../pageobjects/openshift/OcpWebConsolePage'; +import { OcpLoginByTempAdmin } from '../pageobjects/login/OcpLoginByTempAdmin'; +import { ITestWorkspaceUtil } from '..'; + +export function getContainer(): Container { + const e2eContainer = new Container(); + + e2eContainer.bind(TYPES.Driver).to(ChromeDriver).inSingletonScope(); + e2eContainer.bind(TYPES.WorkspaceUtil).to(TestWorkspaceUtil).inSingletonScope(); + e2eContainer.bind(TYPES.OcpLogin).to(OcpLoginByTempAdmin).inSingletonScope(); + + if (TestConstants.TS_SELENIUM_MULTIUSER) { + e2eContainer.bind(TYPES.CheLogin).to(MultiUserLoginPage).inSingletonScope(); + } else { + e2eContainer.bind(TYPES.CheLogin).to(SingleUserLoginPage).inSingletonScope(); + } + + e2eContainer.bind(CLASSES.DriverHelper).to(DriverHelper).inSingletonScope(); + e2eContainer.bind(CLASSES.Dashboard).to(Dashboard).inSingletonScope(); + e2eContainer.bind(CLASSES.Workspaces).to(Workspaces).inSingletonScope(); + e2eContainer.bind(CLASSES.NewWorkspace).to(NewWorkspace).inSingletonScope(); + e2eContainer.bind(CLASSES.WorkspaceDetails).to(WorkspaceDetails).inSingletonScope(); + e2eContainer.bind(CLASSES.WorkspaceDetailsPlugins).to(WorkspaceDetailsPlugins).inSingletonScope(); + e2eContainer.bind(CLASSES.Ide).to(Ide).inSingletonScope(); + e2eContainer.bind(CLASSES.ProjectTree).to(ProjectTree).inSingletonScope(); + e2eContainer.bind(CLASSES.Editor).to(Editor).inSingletonScope(); + e2eContainer.bind(CLASSES.TopMenu).to(TopMenu).inSingletonScope(); + e2eContainer.bind(CLASSES.QuickOpenContainer).to(QuickOpenContainer).inSingletonScope(); + e2eContainer.bind(CLASSES.PreviewWidget).to(PreviewWidget).inSingletonScope(); + e2eContainer.bind(CLASSES.GitHubPlugin).to(GitHubPlugin).inSingletonScope(); + e2eContainer.bind(CLASSES.RightToolbar).to(RightToolbar).inSingletonScope(); + e2eContainer.bind(CLASSES.Terminal).to(Terminal).inSingletonScope(); + e2eContainer.bind(CLASSES.DebugView).to(DebugView).inSingletonScope(); + e2eContainer.bind(CLASSES.WarningDialog).to(WarningDialog).inSingletonScope(); + e2eContainer.bind(CLASSES.ScreenCatcher).to(ScreenCatcher).inSingletonScope(); + e2eContainer.bind(CLASSES.OcpLoginPage).to(OcpLoginPage).inSingletonScope(); + e2eContainer.bind(CLASSES.OcpWebConsolePage).to(OcpWebConsolePage).inSingletonScope(); + return e2eContainer; +} diff --git a/e2e/index.ts b/e2e/index.ts index 06b6fdf619..556bad3dad 100644 --- a/e2e/index.ts +++ b/e2e/index.ts @@ -6,6 +6,7 @@ export * from './TestConstants'; // driver export * from './driver/IDriver'; export * from './driver/ChromeDriver'; +export * from './driver/ContainerInitializer'; // pageobjects - dashboard export * from './pageobjects/dashboard/Dashboard'; @@ -44,3 +45,5 @@ export * from './pageobjects/openshift/OcpWebConsolePage'; export * from './utils/DriverHelper'; export * from './utils/NameGenerator'; export * from './utils/workspace/TestWorkspaceUtil'; +export * from './utils/workspace/ITestWorkspaceUtil'; +export * from './utils/workspace/WorkspaceStatus'; diff --git a/e2e/inversify.config.ts b/e2e/inversify.config.ts index d20107d454..7a143c2559 100644 --- a/e2e/inversify.config.ts +++ b/e2e/inversify.config.ts @@ -7,70 +7,11 @@ * * SPDX-License-Identifier: EPL-2.0 **********************************************************************/ +import * as path from 'path'; import { Container } from 'inversify'; -import { IDriver } from './driver/IDriver'; -import { TYPES, CLASSES } from './inversify.types'; -import { ChromeDriver } from './driver/ChromeDriver'; -import { DriverHelper } from './utils/DriverHelper'; -import { ICheLoginPage } from './pageobjects/login/ICheLoginPage'; -import { IOcpLoginPage } from './pageobjects/login/IOcpLoginPage'; -import { SingleUserLoginPage } from './pageobjects/login/SingleUserLoginPage'; -import { Dashboard } from './pageobjects/dashboard/Dashboard'; -import { Workspaces } from './pageobjects/dashboard/Workspaces'; -import { NewWorkspace } from './pageobjects/dashboard/NewWorkspace'; -import { WorkspaceDetails } from './pageobjects/dashboard/workspace-details/WorkspaceDetails'; -import { WorkspaceDetailsPlugins } from './pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins'; -import { Ide } from './pageobjects/ide/Ide'; -import { TestWorkspaceUtil } from './utils/workspace/TestWorkspaceUtil'; -import { ProjectTree } from './pageobjects/ide/ProjectTree'; -import { Editor } from './pageobjects/ide/Editor'; -import { TopMenu } from './pageobjects/ide/TopMenu'; -import { QuickOpenContainer } from './pageobjects/ide/QuickOpenContainer'; -import { PreviewWidget } from './pageobjects/ide/PreviewWidget'; -import { GitHubPlugin } from './pageobjects/ide/GitHubPlugin'; -import { RightToolbar } from './pageobjects/ide/RightToolbar'; -import { Terminal } from './pageobjects/ide/Terminal'; -import { DebugView } from './pageobjects/ide/DebugView'; -import { WarningDialog } from './pageobjects/ide/WarningDialog'; -import { ScreenCatcher } from './utils/ScreenCatcher'; -import { MultiUserLoginPage } from './pageobjects/login/MultiUserLoginPage'; -import { TestConstants } from './TestConstants'; -import { OcpLoginPage } from './pageobjects/openshift/OcpLoginPage'; -import { OcpWebConsolePage } from './pageobjects/openshift/OcpWebConsolePage'; -import { OcpLoginByTempAdmin } from './pageobjects/login/OcpLoginByTempAdmin'; -const e2eContainer = new Container(); - -e2eContainer.bind(TYPES.Driver).to(ChromeDriver).inSingletonScope(); - -e2eContainer.bind(TYPES.OcpLogin).to(OcpLoginByTempAdmin).inSingletonScope(); - -if (TestConstants.TS_SELENIUM_MULTIUSER) { - e2eContainer.bind(TYPES.CheLogin).to(MultiUserLoginPage).inSingletonScope(); -} else { - e2eContainer.bind(TYPES.CheLogin).to(SingleUserLoginPage).inSingletonScope(); -} - -e2eContainer.bind(CLASSES.DriverHelper).to(DriverHelper).inSingletonScope(); -e2eContainer.bind(CLASSES.Dashboard).to(Dashboard).inSingletonScope(); -e2eContainer.bind(CLASSES.Workspaces).to(Workspaces).inSingletonScope(); -e2eContainer.bind(CLASSES.NewWorkspace).to(NewWorkspace).inSingletonScope(); -e2eContainer.bind(CLASSES.WorkspaceDetails).to(WorkspaceDetails).inSingletonScope(); -e2eContainer.bind(CLASSES.WorkspaceDetailsPlugins).to(WorkspaceDetailsPlugins).inSingletonScope(); -e2eContainer.bind(CLASSES.Ide).to(Ide).inSingletonScope(); -e2eContainer.bind(CLASSES.TestWorkspaceUtil).to(TestWorkspaceUtil).inSingletonScope(); -e2eContainer.bind(CLASSES.ProjectTree).to(ProjectTree).inSingletonScope(); -e2eContainer.bind(CLASSES.Editor).to(Editor).inSingletonScope(); -e2eContainer.bind(CLASSES.TopMenu).to(TopMenu).inSingletonScope(); -e2eContainer.bind(CLASSES.QuickOpenContainer).to(QuickOpenContainer).inSingletonScope(); -e2eContainer.bind(CLASSES.PreviewWidget).to(PreviewWidget).inSingletonScope(); -e2eContainer.bind(CLASSES.GitHubPlugin).to(GitHubPlugin).inSingletonScope(); -e2eContainer.bind(CLASSES.RightToolbar).to(RightToolbar).inSingletonScope(); -e2eContainer.bind(CLASSES.Terminal).to(Terminal).inSingletonScope(); -e2eContainer.bind(CLASSES.DebugView).to(DebugView).inSingletonScope(); -e2eContainer.bind(CLASSES.WarningDialog).to(WarningDialog).inSingletonScope(); -e2eContainer.bind(CLASSES.ScreenCatcher).to(ScreenCatcher).inSingletonScope(); -e2eContainer.bind(CLASSES.OcpLoginPage).to(OcpLoginPage).inSingletonScope(); -e2eContainer.bind(CLASSES.OcpWebConsolePage).to(OcpWebConsolePage).inSingletonScope(); +let pathh = path.resolve('.'); +let containerInitializer = require(`${pathh}/dist/driver/ContainerInitializer.js`); +let e2eContainer : Container = containerInitializer.getContainer(); export { e2eContainer }; diff --git a/e2e/inversify.types.ts b/e2e/inversify.types.ts index 1f0a9baa01..a746c9a4dc 100644 --- a/e2e/inversify.types.ts +++ b/e2e/inversify.types.ts @@ -12,7 +12,8 @@ const TYPES = { Driver: Symbol.for('Driver'), CheLogin: Symbol.for('CheLogin'), - OcpLogin: Symbol.for('OcpLogin') + OcpLogin: Symbol.for('OcpLogin'), + WorkspaceUtil: Symbol.for('WorkspaceUtil') }; const CLASSES = { @@ -23,7 +24,6 @@ const CLASSES = { WorkspaceDetails: 'WorkspaceDetails', WorkspaceDetailsPlugins: 'WorkspaceDetailsPlugins', Ide: 'Ide', - TestWorkspaceUtil: 'TestWorkspaceUtil', ProjectTree: 'ProjectTree', Editor: 'Editor', TopMenu: 'TopMenu', diff --git a/e2e/pageobjects/dashboard/NewWorkspace.ts b/e2e/pageobjects/dashboard/NewWorkspace.ts index f2b3f77a66..5a32ed245b 100644 --- a/e2e/pageobjects/dashboard/NewWorkspace.ts +++ b/e2e/pageobjects/dashboard/NewWorkspace.ts @@ -9,14 +9,14 @@ **********************************************************************/ import { injectable, inject } from 'inversify'; import { DriverHelper } from '../../utils/DriverHelper'; -import { CLASSES } from '../../inversify.types'; +import { CLASSES, TYPES } from '../../inversify.types'; import { TestConstants } from '../../TestConstants'; import { By } from 'selenium-webdriver'; import 'reflect-metadata'; import { Dashboard } from './Dashboard'; import { Workspaces } from './Workspaces'; import { WorkspaceDetails } from './workspace-details/WorkspaceDetails'; -import { TestWorkspaceUtil, Ide, WorkspaceStatus } from '../..'; +import { ITestWorkspaceUtil, Ide, WorkspaceStatus } from '../..'; @injectable() @@ -36,7 +36,7 @@ export class NewWorkspace { constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper, @inject(CLASSES.Dashboard) private readonly dashboard: Dashboard, @inject(CLASSES.Workspaces) private readonly workspaces: Workspaces, - @inject(CLASSES.TestWorkspaceUtil) private readonly testWorkspaceUtil: TestWorkspaceUtil, + @inject(TYPES.WorkspaceUtil) private readonly testWorkspaceUtil: ITestWorkspaceUtil, @inject(CLASSES.WorkspaceDetails) private readonly workspaceDetails: WorkspaceDetails) { } async createAndRunWorkspace(namespace: string, workspaceName: string, dataStackId: string) { diff --git a/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts b/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts index 676821d78a..8c0ab2b1ed 100644 --- a/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +++ b/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts @@ -9,12 +9,13 @@ **********************************************************************/ import { DriverHelper } from '../../../utils/DriverHelper'; import { injectable, inject } from 'inversify'; -import { CLASSES } from '../../../inversify.types'; +import { CLASSES, TYPES } from '../../../inversify.types'; import 'reflect-metadata'; import { TestConstants } from '../../../TestConstants'; import { By } from 'selenium-webdriver'; import { Ide } from '../../ide/Ide'; -import { TestWorkspaceUtil, WorkspaceStatus } from '../../../utils/workspace/TestWorkspaceUtil'; +import { ITestWorkspaceUtil } from '../../../utils/workspace/ITestWorkspaceUtil'; +import { WorkspaceStatus } from '../../../utils/workspace/WorkspaceStatus'; @injectable() @@ -26,7 +27,7 @@ export class WorkspaceDetails { private static readonly WORKSPACE_DETAILS_LOADER_CSS: string = 'workspace-details-overview md-progress-linear'; constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper, - @inject(CLASSES.TestWorkspaceUtil) private readonly testWorkspaceUtil: TestWorkspaceUtil) { } + @inject(TYPES.WorkspaceUtil) private readonly testWorkspaceUtil: ITestWorkspaceUtil) { } async waitLoaderDisappearance(attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS, polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING) { await this.driverHelper.waitDisappearance(By.css(WorkspaceDetails.WORKSPACE_DETAILS_LOADER_CSS), attempts, polling); diff --git a/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.ts b/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.ts index 518b1e4dc8..ebfbdc427a 100644 --- a/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.ts +++ b/e2e/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.ts @@ -10,18 +10,19 @@ import { DriverHelper } from '../../../utils/DriverHelper'; import { injectable, inject } from 'inversify'; import 'reflect-metadata'; -import { CLASSES } from '../../../inversify.types'; +import { CLASSES, TYPES } from '../../../inversify.types'; import { TestConstants } from '../../../TestConstants'; import { By } from 'selenium-webdriver'; import { WorkspaceDetails } from './WorkspaceDetails'; -import { TestWorkspaceUtil, WorkspaceStatus } from '../../../utils/workspace/TestWorkspaceUtil'; +import { ITestWorkspaceUtil } from '../../../utils/workspace/ITestWorkspaceUtil'; +import { WorkspaceStatus } from '../../../utils/workspace/WorkspaceStatus'; @injectable() export class WorkspaceDetailsPlugins { constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper, @inject(CLASSES.WorkspaceDetails) private readonly workspaceDetails: WorkspaceDetails, - @inject(CLASSES.TestWorkspaceUtil) private readonly testWorkspaceUtil: TestWorkspaceUtil) { } + @inject(TYPES.WorkspaceUtil) private readonly testWorkspaceUtil: ITestWorkspaceUtil) { } async waitPluginListItem(pluginName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) { const pluginListItemLocator: By = By.css(this.getPluginListItemCssLocator(pluginName)); diff --git a/e2e/pageobjects/ide/Ide.ts b/e2e/pageobjects/ide/Ide.ts index 8e904d1959..7d1e9e052f 100644 --- a/e2e/pageobjects/ide/Ide.ts +++ b/e2e/pageobjects/ide/Ide.ts @@ -10,10 +10,11 @@ import axios from 'axios'; import { DriverHelper } from '../../utils/DriverHelper'; import { injectable, inject } from 'inversify'; -import { CLASSES } from '../../inversify.types'; +import { CLASSES, TYPES } from '../../inversify.types'; import { TestConstants } from '../../TestConstants'; import { By, WebElement, error } from 'selenium-webdriver'; -import { TestWorkspaceUtil, WorkspaceStatus } from '../../utils/workspace/TestWorkspaceUtil'; +import { ITestWorkspaceUtil } from '../../utils/workspace/ITestWorkspaceUtil'; +import { WorkspaceStatus } from '../../utils/workspace/WorkspaceStatus'; export enum RightToolbarButton { Explorer = 'Explorer', @@ -34,7 +35,7 @@ export class Ide { constructor( @inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper, - @inject(CLASSES.TestWorkspaceUtil) private readonly testWorkspaceUtil: TestWorkspaceUtil) { } + @inject(TYPES.WorkspaceUtil) private readonly testWorkspaceUtil: ITestWorkspaceUtil) { } async waitAndSwitchToIdeFrame(timeout: number = TestConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT) { await this.driverHelper.waitAndSwitchToFrame(By.css(Ide.IDE_IFRAME_CSS), timeout); diff --git a/e2e/tslint.json b/e2e/tslint.json index ac8744f793..b75b55b98e 100644 --- a/e2e/tslint.json +++ b/e2e/tslint.json @@ -67,7 +67,7 @@ "no-unused-variable": true, "no-unreachable": true, "no-use-before-declare": true, - "no-var-requires": true, + "no-var-requires": false, "one-line": [ true, "check-open-brace", diff --git a/e2e/utils/workspace/ITestWorkspaceUtil.ts b/e2e/utils/workspace/ITestWorkspaceUtil.ts new file mode 100644 index 0000000000..77a55ba637 --- /dev/null +++ b/e2e/utils/workspace/ITestWorkspaceUtil.ts @@ -0,0 +1,19 @@ +/********************************************************************* + * Copyright (c) 2019 Red Hat, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + **********************************************************************/ + +import { WorkspaceStatus } from './WorkspaceStatus'; + +export interface ITestWorkspaceUtil { + waitWorkspaceStatus(namespace: string, workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus) : void; + waitPluginAdding(namespace: string, workspaceName: string, pluginId: string) : void; + removeWorkspaceById(id: string) : void; + stopWorkspaceById(id: string) : void; + getIdOfRunningWorkspace(namespace: string): Promise; +} diff --git a/e2e/utils/workspace/TestWorkspaceUtil.ts b/e2e/utils/workspace/TestWorkspaceUtil.ts index 770402a892..dbf89bd8b2 100644 --- a/e2e/utils/workspace/TestWorkspaceUtil.ts +++ b/e2e/utils/workspace/TestWorkspaceUtil.ts @@ -15,15 +15,12 @@ import { CLASSES } from '../../inversify.types'; import 'reflect-metadata'; import * as rm from 'typed-rest-client/RestClient'; import { error } from 'selenium-webdriver'; - -export enum WorkspaceStatus { - RUNNING = 'RUNNING', - STOPPED = 'STOPPED', - STARTING = 'STARTING' -} +import { WorkspaceStatus } from './WorkspaceStatus'; +import { ITestWorkspaceUtil } from './ITestWorkspaceUtil'; @injectable() -export class TestWorkspaceUtil { +export class TestWorkspaceUtil implements ITestWorkspaceUtil { + constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper, private readonly rest: rm.RestClient = new rm.RestClient('rest-samples')) { } @@ -80,4 +77,15 @@ export class TestWorkspaceUtil { } } + public async getIdOfRunningWorkspace(namespace: string): Promise { + throw new Error("Method not implemented."); + } + + removeWorkspaceById(id: string): void { + throw new Error("Method not implemented."); + } + + stopWorkspaceById(id: string): void { + throw new Error("Method not implemented."); + } } diff --git a/e2e/utils/workspace/WorkspaceStatus.ts b/e2e/utils/workspace/WorkspaceStatus.ts new file mode 100644 index 0000000000..3505b40ca0 --- /dev/null +++ b/e2e/utils/workspace/WorkspaceStatus.ts @@ -0,0 +1,15 @@ +/********************************************************************* + * Copyright (c) 2019 Red Hat, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + **********************************************************************/ + + export enum WorkspaceStatus { + RUNNING = 'RUNNING', + STOPPED = 'STOPPED', + STARTING = 'STARTING' +}