Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ TS-SELENIUM ] Investigating new typescript related test framework #13200

Merged
merged 63 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
d706904
Install basic tools
Ohrimenko1988 Apr 11, 2019
e4afc5b
Add 'Driver' definition
Ohrimenko1988 Apr 11, 2019
3cb248e
Add first pageobject
Ohrimenko1988 Apr 11, 2019
ca8b301
Intermediate 'Selenium' + 'Mocha' + 'Chai' working version
Ohrimenko1988 Apr 12, 2019
e307ce4
Intermediate 'Selenium' + 'Mocha' + 'Chai' working version
Ohrimenko1988 Apr 12, 2019
8c2f2f5
Intermediate 'Selenium' + 'Mocha' + 'Chai' working version
Ohrimenko1988 Apr 12, 2019
13b64e3
Intermediate 'Selenium' + 'Mocha' + 'Chai' working version
Ohrimenko1988 Apr 15, 2019
269617f
Intermediate 'Selenium' + 'Mocha' + 'Chai' working version
Ohrimenko1988 Apr 15, 2019
79b5a09
Intermediate 'Selenium' + 'Mocha' + 'Chai' working version
Ohrimenko1988 Apr 16, 2019
aa98cff
Intermediate 'Selenium' + 'Mocha' + 'Chai' working version
Ohrimenko1988 Apr 17, 2019
bd596ca
Merge branch 'master' of https://github.com/eclipse/che into typescri…
Ohrimenko1988 Apr 17, 2019
15853ec
Intermediate 'Selenium' + 'Mocha' + 'Chai' working version
Ohrimenko1988 Apr 17, 2019
2dbc438
Intermediate 'Selenium' + 'Mocha' + 'Chai' working version
Ohrimenko1988 Apr 17, 2019
10f011f
Intermediate 'Selenium' + 'Mocha' + 'Chai' working version
Ohrimenko1988 Apr 18, 2019
e9fa3ff
Add launch customization possibility by environment variables set
Ohrimenko1988 Apr 18, 2019
6f24843
Add tests folder and create pattern for launch it
Ohrimenko1988 Apr 19, 2019
cc8beca
Do base URL configurable
Ohrimenko1988 Apr 19, 2019
124e0cb
Update the 'DriverHelper' class
Ohrimenko1988 Apr 19, 2019
cbffa2f
Add 'mocha.opts' supporting
Ohrimenko1988 Apr 22, 2019
6830399
Add 'headless' mode supporting
Ohrimenko1988 Apr 22, 2019
3473987
Add licence headers
Ohrimenko1988 Apr 22, 2019
292d32e
Remove 'mocha.opts' config file
Ohrimenko1988 Apr 22, 2019
103fb74
Intermediate screenshot version
Ohrimenko1988 Apr 23, 2019
508831e
Intermediate reporter version
Ohrimenko1988 Apr 23, 2019
6c9fdcf
Intermediate reporter version
Ohrimenko1988 Apr 23, 2019
3297b1f
Intermediate reporter version
Ohrimenko1988 Apr 23, 2019
0e414fc
Intermediate reporter version
Ohrimenko1988 Apr 23, 2019
edeff86
Intermediate reporter version
Ohrimenko1988 Apr 23, 2019
f52e833
Intermediate reporter version
Ohrimenko1988 Apr 23, 2019
2de6d1f
Refactor 'types.ts'
Ohrimenko1988 Apr 23, 2019
acfd277
Delete unit tests for 'DriverHelper' class
Ohrimenko1988 Apr 23, 2019
fd8573c
Enable skipped tests execution
Ohrimenko1988 Apr 23, 2019
571ee36
Remove redundant npm command
Ohrimenko1988 Apr 23, 2019
61d58bd
Add 'README' description
Ohrimenko1988 Apr 23, 2019
1d2673e
Do changes according to review
Ohrimenko1988 Apr 23, 2019
5aab39a
Do changes according to review
Ohrimenko1988 Apr 23, 2019
8bacf5e
Do changes according to review
Ohrimenko1988 Apr 23, 2019
5902195
Merge branch 'master' of https://github.com/eclipse/che into typescri…
Ohrimenko1988 Apr 23, 2019
37e4726
Do changes according to 'Codacy/PR Quality Review' result
Ohrimenko1988 Apr 24, 2019
150145c
Add editor methods
Ohrimenko1988 Apr 25, 2019
db6ba5f
Add methods to the 'Editor' pageobject
Ohrimenko1988 Apr 25, 2019
be1d841
Add switching to frame during project import wait
Ohrimenko1988 Apr 25, 2019
29d9856
Do changes according to review
Ohrimenko1988 Apr 25, 2019
fbcd9af
Merge branch 'master' of https://github.com/eclipse/che into typescri…
Ohrimenko1988 Apr 25, 2019
65d45e6
Do changes according to review
Ohrimenko1988 Apr 25, 2019
2042f73
Do changes according to review
Ohrimenko1988 Apr 25, 2019
dcf5a00
Do changes according to review
Ohrimenko1988 Apr 26, 2019
a9cd9e8
Do changes according to review
Ohrimenko1988 Apr 26, 2019
8a78567
Do changes according to review
Ohrimenko1988 Apr 26, 2019
d261298
Do changes according to review
Ohrimenko1988 Apr 26, 2019
3a4ae9e
Do changes according to review
Ohrimenko1988 Apr 26, 2019
48d5d0f
Do changes according to review
Ohrimenko1988 Apr 26, 2019
fa58f3c
Do changes according to review
Ohrimenko1988 Apr 26, 2019
b77621f
Merge branch 'master' of https://github.com/eclipse/che into typescri…
Ohrimenko1988 Apr 26, 2019
19e0434
Do changes according to review
Ohrimenko1988 May 2, 2019
708dde9
Merge branch 'master' of https://github.com/eclipse/che into typescri…
Ohrimenko1988 May 2, 2019
b4ce619
Do changes according to review
Ohrimenko1988 May 2, 2019
1302bdc
Do changes according to changed java plugin id
Ohrimenko1988 May 3, 2019
659d2e5
Add new methods to the 'Editor' pageobject
Ohrimenko1988 May 6, 2019
3e0223c
Rewert changesrelated to cypress module
Ohrimenko1988 May 6, 2019
b25c53f
Merge branch 'master' of https://github.com/eclipse/che into typescri…
Ohrimenko1988 May 6, 2019
b3128c1
Do changes according to review
Ohrimenko1988 May 6, 2019
f4e5ca5
Rename 'typescript-selenium' module to 'e2e' module
Ohrimenko1988 May 6, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ docs/assets/imgs
plugins/plugin-terminal-ui/node_modules/
plugins/plugin-terminal-ui/build/
requirements.lock
typescript-selenium/dist/
typescript-selenium/node_modules/
typescript-selenium/report/

# Cypress modules #
##################
###################
*/cypress/screenshots
*/cypress/videos
*/node_modules
Expand Down
16 changes: 8 additions & 8 deletions cypress-tests/cypress/pageobjects/ide/ProjectTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ export class ProjectTree {
return `${this.getExpandIconLocator(itemPath)}:not(.theia-mod-collapsed)`;
}

private getExpandIconLocator(itemPath: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this change related to this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ohrimenko1988 are you going to address this?

return `div[data-node-id='/projects:/projects${itemPath}']`;
}

private getTreeItemLocator(itemPath: string) {
return `.theia-TreeNode[title='/projects${itemPath}']`
}

openProjectTreeContainer() {
cy.get(Ide.EXPLORER_BUTTON)
.should('be.visible')
Expand Down Expand Up @@ -92,14 +100,6 @@ export class ProjectTree {
cy.get(selectedItemLocator).should('be.visible');
}

private getExpandIconLocator(itemPath: string) {
return `div[data-node-id='/projects:/projects${itemPath}']`;
}

private getTreeItemLocator(itemPath: string) {
return `.theia-TreeNode[title='/projects${itemPath}']`
}

expandItem(itemPath: string) {
let expandIconLocator: string = this.getExpandIconLocator(itemPath);
let treeItemLocator: string = this.getTreeItemLocator(itemPath);
Expand Down
9 changes: 9 additions & 0 deletions typescript-selenium/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Requirements
- node 8.x
- "Chrome" browser 69.x or later

## Default launch
- npm install && npm test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dashboard uses yarn instead of npm. Since both projects live in one git repo, it would be nice to unify it.


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two commands are not enough. I miss information about how to run the app (maybe link to a different readme would be enough).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the responsibility of this module to deploy Che. It just goes to the provided link and performs tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely agree with you. This is the reason why I suggested to just provide the link to the instructions.

## Custom launch
- Use environment variables which described in the **```'TestConstants.ts'```** file
72 changes: 72 additions & 0 deletions typescript-selenium/TestConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*********************************************************************
* 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 const TestConstants = {
/**
* Base URL of the application which should be checked
*/
TS_SELENIUM_BASE_URL: process.env.TS_SELENIUM_BASE_URL || "http://che-che.192.168.99.100.nip.io",

/**
* Run browser in "Headless" (hiden) mode, "false" by default.
*/
TS_SELENIUM_HEADLESS: process.env.TS_SELENIUM_HEADLESS === 'true',

/**
* Browser width resolution, "1920" by default.
*/
TS_SELENIUM_RESOLUTION_WIDTH: Number(process.env.TS_SELENIUM_BASE_URL) || 1920,

Copy link
Contributor

@mmorhun mmorhun Apr 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and in most other cases 2 or 3 blank lines are unnecessary and looks weird!

/**
* Browser height resolution, "1080" by default.
*/
TS_SELENIUM_RESOLUTION_HEIGHT: Number(process.env.TS_SELENIUM_BASE_URL) || 1080,

/**
* Timeout in milliseconds waiting for workspace start, "240 000" by default.
*/
TS_SELENIUM_START_WORKSPACE_TIMEOUT: Number(process.env.TS_SELENIUM_START_WORKSPACE_TIMEOUT) || 240000,

/**
* Timeout in milliseconds waiting for page load, "120 000" by default.
*/
TS_SELENIUM_LOAD_PAGE_TIMEOUT: Number(process.env.TS_SELENIUM_LOAD_PAGE_TIMEOUT) || 120000,

/**
* Timeout in milliseconds waiting for language server initialization, "180 000" by default.
*/
TS_SELENIUM_LANGUAGE_SERVER_START_TIMEOUT: Number(process.env.TS_SELENIUM_LANGUAGE_SERVER_START_TIMEOUT) || 180000,

/**
* Default timeout for most of the waitings, "20 000" by default.
*/
TS_SELENIUM_DEFAULT_TIMEOUT: Number(process.env.TS_SELENIUM_DEFAULT_TIMEOUT) || 20000,

/**
* Default ammount of tries, "5" by default.
*/
TS_SELENIUM_DEFAULT_ATTEMPTS: Number(process.env.TS_SELENIUM_DEFAULT_ATTEMPTS) || 5,

/**
* Default delay in milliseconds between tries, "1000" by default.
*/
TS_SELENIUM_DEFAULT_POLLING: Number(process.env.TS_SELENIUM_DEFAULT_POLLING) || 1000,

/**
* Amount of tries for checking workspace status.
*/
TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS: Number(process.env.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS) || 90,

/**
* Delay in milliseconds between checking workspace status tries.
*/
TS_SELENIUM_WORKSPACE_STATUS_POLLING: Number(process.env.TS_SELENIUM_WORKSPACE_STATUS_POLLING) || 10000

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://che-che.192.168.99.100.nip.io still looks strange...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is default value which valid for minikube Che. For customization may be used the "TS_SELENIUM_BASE_URL" environment variable

Copy link
Contributor

@musienko-maxim musienko-maxim Apr 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure it that 192.168.99.100 default minikube value and nip.io suffix also can be changed it may be has many values for customizing. It may be a bit confuse our contributors. I guess something like localhost will be more clearer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of variants, I just put one of them

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we make that parameter as "mandatory", as we can agree there is not right "default" value?

102 changes: 102 additions & 0 deletions typescript-selenium/driver/CheReporter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*********************************************************************
* 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 * as mocha from 'mocha';
import { Driver } from './Driver';
import { e2eContainer } from '../inversify.config';
import { TYPES } from '../inversify.types';
import * as fs from 'fs';
import { TestConstants } from '../TestConstants';

const driver: Driver = e2eContainer.get(TYPES.Driver);

class CheReporter extends mocha.reporters.Spec {

constructor(runner: mocha.Runner, options: mocha.MochaOptions) {
super(runner, options);

runner.on('start', async (test: mocha.Test) => {
const launchInformation: string =
`################## Launch Information ##################

TS_SELENIUM_BASE_URL: ${TestConstants.TS_SELENIUM_BASE_URL}
TS_SELENIUM_HEADLESS: ${TestConstants.TS_SELENIUM_HEADLESS}

TS_SELENIUM_DEFAULT_ATTEMPTS: ${TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS}
TS_SELENIUM_DEFAULT_POLLING: ${TestConstants.TS_SELENIUM_DEFAULT_POLLING}
TS_SELENIUM_DEFAULT_TIMEOUT: ${TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT}

TS_SELENIUM_LANGUAGE_SERVER_START_TIMEOUT: ${TestConstants.TS_SELENIUM_LANGUAGE_SERVER_START_TIMEOUT}
TS_SELENIUM_LOAD_PAGE_TIMEOUT: ${TestConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT}
TS_SELENIUM_START_WORKSPACE_TIMEOUT: ${TestConstants.TS_SELENIUM_START_WORKSPACE_TIMEOUT}
TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS: ${TestConstants.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS}
TS_SELENIUM_WORKSPACE_STATUS_POLLING: ${TestConstants.TS_SELENIUM_WORKSPACE_STATUS_POLLING}

########################################################
`
console.log(launchInformation)
})

runner.on('end', async function (test: mocha.Test) {
// ensure that fired events done
await driver.get().sleep(5000)

// close driver
await driver.get().quit()
})

runner.on('fail', async function (test: mocha.Test) {

const reportDirPath: string = './report'
const testFullTitle: string = test.fullTitle().replace(/\s/g, '_')
const testTitle: string = test.title.replace(/\s/g, '_')

const testReportDirPath: string = `${reportDirPath}/${testFullTitle}`
const screenshotFileName: string = `${testReportDirPath}/screenshot-${testTitle}.png`
const pageSourceFileName: string = `${testReportDirPath}/pagesource-${testTitle}.html`

// create reporter dir if not exist
await fs.exists(reportDirPath, async isDirExist => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid, you have a race here. await will wait until fs.exists finishes and resume execution, where as callback is async, so we do not know which one will be executed first: callback or next await, which submits another async...
You may use fs.existsSync(path) instead and analyze return value.
Also fs.exists is deprecated: https://nodejs.org/api/fs.html#fs_fs_exists_path_callback

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is still valid, right @Ohrimenko1988 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Node.js v10.12 you can use recursive version of mkdir which IMHO doesn't do anything if the directory already exists. Isn't fs.exists() call unnecessary? BTW v10 is now active LTS release so I suggest to use it.

if (!isDirExist) {
await fs.mkdir(reportDirPath, err => {
if (err) {
throw err
}
})
}
})

// create dir for collected data if not exist
await fs.exists(testReportDirPath, async isDirExist => {
if (!isDirExist) {
await fs.mkdir(testReportDirPath, err => {
if (err) {
throw err
}
})
}
})

// take screenshot and write to file
const screenshot: string = await driver.get().takeScreenshot();
const screenshotStream = fs.createWriteStream(screenshotFileName)
screenshotStream.write(new Buffer(screenshot, 'base64'))
screenshotStream.end()

// take pagesource and write to file
const pageSource: string = await driver.get().getPageSource()
const pageSourceStream = fs.createWriteStream(pageSourceFileName)
pageSourceStream.write(new Buffer(pageSource))
pageSourceStream.end()

})
}
}

export = CheReporter;
45 changes: 45 additions & 0 deletions typescript-selenium/driver/ChromeDriver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*********************************************************************
* 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 'chromedriver';
import 'reflect-metadata';
import { injectable, inject } from "inversify";
import { ThenableWebDriver, Builder } from "selenium-webdriver";
import { Driver } from './Driver';
import { Options } from 'selenium-webdriver/chrome';
import { TestConstants } from '../TestConstants';

@injectable()
export class ChromeDriver implements Driver {
private readonly driver: ThenableWebDriver;

constructor() {
const isHeadless: boolean = TestConstants.TS_SELENIUM_HEADLESS;
let options: Options = new Options().addArguments('--no-sandbox')

if (isHeadless) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe less code:

let options = new Options().addArguments('--no-sandbox');
if (isHeadless) {
  options = options.addArguments('headless'))
}
this.driver = new Builder()
                .forBrowser('chrome')
                .setChromeOptions(options)
                .build();

options = options.addArguments('headless')
}

this.driver = new Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();

this.driver
.manage()
.window()
.setSize(TestConstants.TS_SELENIUM_RESOLUTION_WIDTH, TestConstants.TS_SELENIUM_RESOLUTION_HEIGHT)
}
rhopp marked this conversation as resolved.
Show resolved Hide resolved

get(): ThenableWebDriver {
return this.driver
}

}
14 changes: 14 additions & 0 deletions typescript-selenium/driver/Driver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*********************************************************************
* 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 { ThenableWebDriver } from "selenium-webdriver";

export interface Driver {
get(): ThenableWebDriver
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to return Thenable here?
What about returning the driver object itself and await for it in appropriate driver implementation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ohrimenko1988 Is there a reason for this?

}
45 changes: 45 additions & 0 deletions typescript-selenium/inversify.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*********************************************************************
* 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 { Driver } from "./driver/Driver";
import { TYPES, CLASSES } from "./inversify.types";
import { ChromeDriver } from "./driver/ChromeDriver";
import { DriverHelper } from "./utils/DriverHelper";
import { LoginPage } from "./pageobjects/login/LoginPage";
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";

const e2eContainer = new Container();

e2eContainer.bind<Driver>(TYPES.Driver).to(ChromeDriver).inSingletonScope();
e2eContainer.bind<LoginPage>(TYPES.LoginPage).to(SingleUserLoginPage).inSingletonScope();

e2eContainer.bind<DriverHelper>(CLASSES.DriverHelper).to(DriverHelper).inSingletonScope();
e2eContainer.bind<Dashboard>(CLASSES.Dashboard).to(Dashboard).inSingletonScope();
e2eContainer.bind<Workspaces>(CLASSES.Workspaces).to(Workspaces).inSingletonScope();
e2eContainer.bind<NewWorkspace>(CLASSES.NewWorkspace).to(NewWorkspace).inSingletonScope();
e2eContainer.bind<WorkspaceDetails>(CLASSES.WorkspaceDetails).to(WorkspaceDetails).inSingletonScope();
e2eContainer.bind<WorkspaceDetailsPlugins>(CLASSES.WorkspaceDetailsPlugins).to(WorkspaceDetailsPlugins).inSingletonScope();
e2eContainer.bind<Ide>(CLASSES.Ide).to(Ide).inSingletonScope();
e2eContainer.bind<TestWorkspaceUtil>(CLASSES.TestWorkspaceUtil).to(TestWorkspaceUtil).inSingletonScope();
e2eContainer.bind<ProjectTree>(CLASSES.ProjectTree).to(ProjectTree).inSingletonScope();
e2eContainer.bind<Editor>(CLASSES.Editor).to(Editor).inSingletonScope();



export { e2eContainer }
29 changes: 29 additions & 0 deletions typescript-selenium/inversify.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*********************************************************************
* 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
**********************************************************************/

const TYPES = {
Driver: Symbol.for("Driver"),
LoginPage: Symbol.for("LoginPage")
}

const CLASSES = {
DriverHelper: "DriverHelper",
Dashboard: "Dashboard",
Workspaces: "Workspaces",
NewWorkspace: "NewWorkspace",
WorkspaceDetails: "WorkspaceDetails",
WorkspaceDetailsPlugins: "WorkspaceDetailsPlugins",
Ide: "Ide",
TestWorkspaceUtil: "TestWorkspaceUtil",
ProjectTree: "ProjectTree",
Editor: "Editor",
}

export { TYPES, CLASSES };
6 changes: 6 additions & 0 deletions typescript-selenium/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--require ts-node/register
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly suggest to avoid this magic and call TypeScript compiler (tsc) explicitly. Now, when you make a syntax error, you will see ERROR: Unknown "reporter": driver/CheReporter.ts which is not very helpful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I have seen this problem when trying to consume this project on our side. So I'm running it in this way:

"scripts": {
    "test": "tsc -p . && mocha --opts mocha.opts"
  }

and this is mocha.opts

--timeout 1200000
--reporter 'dist/driver/CheReporter.js'
-u tdd 
--bail
--spec dist/tests/*.spec.js

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Katka92 We're going to merge this one as it is right now and we can do this change inm the future, if needed.

--timeout 1200000
--reporter 'driver/CheReporter.ts'
-u tdd
--bail
--spec tests/*.spec.ts
rhopp marked this conversation as resolved.
Show resolved Hide resolved
Loading