Skip to content

Commit

Permalink
Move Dev Spaces typescript functional tests, clean up outdated code
Browse files Browse the repository at this point in the history
Signed-off-by: mdolhalo <mdolhalo@redhat.com>
  • Loading branch information
Maryna Dolhalova committed Mar 29, 2023
1 parent 176fabb commit e20d5f1
Show file tree
Hide file tree
Showing 64 changed files with 1,568 additions and 1,923 deletions.
48 changes: 11 additions & 37 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

## Requirements

- node 8.x
- "Chrome" browser 69.x or later
- node 16.x
- "Chrome" browser 111.x or later
- deployed Che 7 with accessible URL

## Before launch
Expand All @@ -18,16 +18,16 @@ Note: If there is any modifications in package.json, manually execute the `npm i

## Default launch

- Provide connection credentials to Che:
- ```export TS_SELENIUM_USERNAME=<username>```
- ```export TS_SELENIUM_PASSWORD=<password>```
- ```npm test```
- Provide connection credentials:
- ```export TS_SELENIUM_OCP_USERNAME=<username>```
- ```export TS_SELENIUM_OCP_PASSWORD=<password>```
- ```npm run test```

## Custom launch

- Use environment variables which described in the **```'TestConstants.ts'```** file
- Use environment variables for setting timeouts if needed. You can see the list in **```'TimeoutConstants.ts'```**. You can see the list of those variables and their value if you set the ```'TS_SELENIUM_PRINT_TIMEOUT_VARIABLES = true'```
- Check for available scripts in package.json which are prefixed by `test-`. Then, perform command ```npm run test-<suffixNameOfScript>```
- To test one specification export file name as ```export USERSTORY=<spec-file-name-without-extension> && npm run test``` (example: ```-e USERSTORY=Quarkus```)

## Docker launch

Expand Down Expand Up @@ -58,35 +58,8 @@ For running tests without docker, please perform next steps:**
- link to devfile ( **```For successfull test passing, exactly provided devfile should be used```** )
<https://gist.githubusercontent.com/Ohrimenko1988/93f5426f4ebc1705c55feb8ff0396a49/raw/cbea89ad145ba33ed34a151a12c50f045f9f3b78/yaml-ls-bug.yaml>
- Provide the **```'TS_SELENIUM_BASE_URL'```** environment variable as described above
- perform command **```'npm run test-happy-path'```**

## Plugins tests launching for the Che without oauth authentication

**Setup next environment variables:**

- export TS_SELENIUM_BASE_URL=\<Che-URL\>
- export USERSTORY=\<Test you want to run \>
- (skip if login is "admin") export TS_SELENIUM_USERNAME=\<Login\>
- (skip if password is "admin") export TS_SELENIUM_PASSWORD=\<Password\>

**Run command:**

- npm run test-plugin

## Plugins tests launching for the Che with oauth authentication

**Setup next environment variables:**

- export TS_SELENIUM_BASE_URL=\<Che-URL\>
- export USERSTORY=\<test-you-want-to-run\>
- export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH="true"
- export TS_SELENIUM_OCP_USERNAME=\<cluster-username\>
- export TS_SELENIUM_OCP_PASSWORD=\<cluster-password\>

**Run command:**

- npm run test-plugin

- export TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME=EmptyWorkspace (default value, see TestConstants.ts)
- perform command **```export USERSTORY=$TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME && npm run test-all-devfiles```**

## Launching the DevWorkspaceHappyPath spec file using Che with oauth authentication

Expand All @@ -98,6 +71,7 @@ For running tests without docker, please perform next steps:**
- export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH="true"
- export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=\<login-provide-title\>
- export TS_SELENIUM_DEVWORKSPACE_URL=\<devworkspace-url\>
- export TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME=EmptyWorkspace (default value, see TestConstants.ts)

**Execute the npm command:**
- npm run test-devworkspace-happy-path
- perform command ```export USERSTORY=$TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME && npm run test-all-devfiles```
27 changes: 7 additions & 20 deletions tests/e2e/configs/inversify.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,70 +19,57 @@ import { OcpUserLoginPage } from '../pageobjects/login/OcpUserLoginPage';
import { TestConstants } from '../constants/TestConstants';
import { ICheLoginPage } from '../pageobjects/login/ICheLoginPage';
import { RegularUserOcpCheLoginPage } from '../pageobjects/login/RegularUserOcpCheLoginPage';
import { MultiUserLoginPage } from '../pageobjects/login/MultiUserLoginPage';
import { DriverHelper } from '../utils/DriverHelper';
import { Dashboard } from '../pageobjects/dashboard/Dashboard';
import { Workspaces } from '../pageobjects/dashboard/Workspaces';
import { WorkspaceDetails } from '../pageobjects/dashboard/workspace-details/WorkspaceDetails';
import { WorkspaceDetailsPlugins } from '../pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins';
import { ScreenCatcher } from '../utils/ScreenCatcher';
import { OcpLoginPage } from '../pageobjects/openshift/OcpLoginPage';
import { CheLoginPage } from '../pageobjects/openshift/CheLoginPage';
import { IAuthorizationHeaderHandler } from '../utils/request-handlers/headers/IAuthorizationHeaderHandler';
import { CheMultiuserAuthorizationHeaderHandler } from '../utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler';
import { CheMultiuserTokenHandler } from '../utils/request-handlers/tokens/CheMultiuserTokenHandler';
import { ITokenHandler } from '../utils/request-handlers/tokens/ITokenHandler';
import { CheApiRequestHandler } from '../utils/request-handlers/CheApiRequestHandler';
import { CheGitApi } from '../utils/vsc/CheGitApi';
import { GitHubUtil } from '../utils/vsc/github/GitHubUtil';
import { CreateWorkspace } from '../pageobjects/dashboard/CreateWorkspace';
import { UpdateAccountInformationPage } from '../pageobjects/login/UpdateAccountInformationPage';
import { BrowserTabsUtil } from '../utils/BrowserTabsUtil';
import { WorkspaceHandlingTests } from '../tests-library/WorkspaceHandlingTests';
import { GitLoginPage } from '../pageobjects/third-parties/GitLoginPage';
import { GitOauthAppsSettings } from '../pageobjects/third-parties/GitOauthAppsSettings';
import { WorkspaceNameHandler } from '../utils/WorkspaceNameHandler';
import { Sanitizer } from '../utils/Sanitizer';
import { ApiUrlResolver } from '../utils/workspace/ApiUrlResolver';
import { ITestWorkspaceUtil } from '../utils/workspace/ITestWorkspaceUtil';
import { ProjectAndFileTests } from '../tests-library/ProjectAndFileTests';
import { LoginTests } from '../tests-library/LoginTests';
import { RedHatLoginPage } from '../pageobjects/login/RedHatLoginPage';
import { OcpRedHatLoginPage } from '../pageobjects/login/OcpRedHatLoginPage';

const e2eContainer: Container = new Container({ defaultScope: 'Transient' });

e2eContainer.bind<IDriver>(TYPES.Driver).to(ChromeDriver).inSingletonScope();
e2eContainer.bind<ITestWorkspaceUtil>(TYPES.WorkspaceUtil).to(TestWorkspaceUtil);
e2eContainer.bind<IOcpLoginPage>(TYPES.OcpLogin).to(OcpUserLoginPage);
e2eContainer.bind<IAuthorizationHeaderHandler>(TYPES.IAuthorizationHeaderHandler).to(CheMultiuserAuthorizationHeaderHandler);
e2eContainer.bind<ITokenHandler>(TYPES.ITokenHandler).to(CheMultiuserTokenHandler);

if (JSON.parse(TestConstants.TS_SELENIUM_VALUE_OPENSHIFT_OAUTH)) {
e2eContainer.bind<ICheLoginPage>(TYPES.CheLogin).to(RegularUserOcpCheLoginPage);
} else {
e2eContainer.bind<ICheLoginPage>(TYPES.CheLogin).to(MultiUserLoginPage);
}

e2eContainer.bind<BrowserTabsUtil>(CLASSES.BrowserTabsUtil).to(BrowserTabsUtil);
e2eContainer.bind<DriverHelper>(CLASSES.DriverHelper).to(DriverHelper);
e2eContainer.bind<Dashboard>(CLASSES.Dashboard).to(Dashboard);
e2eContainer.bind<Workspaces>(CLASSES.Workspaces).to(Workspaces);
e2eContainer.bind<WorkspaceDetails>(CLASSES.WorkspaceDetails).to(WorkspaceDetails);
e2eContainer.bind<WorkspaceDetailsPlugins>(CLASSES.WorkspaceDetailsPlugins).to(WorkspaceDetailsPlugins);
e2eContainer.bind<ScreenCatcher>(CLASSES.ScreenCatcher).to(ScreenCatcher);
e2eContainer.bind<OcpLoginPage>(CLASSES.OcpLoginPage).to(OcpLoginPage);
e2eContainer.bind<CheLoginPage>(CLASSES.CheLoginPage).to(CheLoginPage);
e2eContainer.bind<CheApiRequestHandler>(CLASSES.CheApiRequestHandler).to(CheApiRequestHandler);
e2eContainer.bind<CheGitApi>(CLASSES.CheGitApi).to(CheGitApi);
e2eContainer.bind<GitHubUtil>(CLASSES.GitHubUtil).to(GitHubUtil);
e2eContainer.bind<CreateWorkspace>(CLASSES.CreateWorkspace).to(CreateWorkspace);
e2eContainer.bind<UpdateAccountInformationPage>(CLASSES.UpdateAccountInformationPage).to(UpdateAccountInformationPage);
e2eContainer.bind<ProjectAndFileTests>(CLASSES.ProjectAndFileTests).to(ProjectAndFileTests);
e2eContainer.bind<LoginTests>(CLASSES.LoginTests).to(LoginTests);
e2eContainer.bind<WorkspaceNameHandler>(CLASSES.WorkspaceNameHandler).to(WorkspaceNameHandler);
e2eContainer.bind<GitLoginPage>(CLASSES.GitLoginPage).to(GitLoginPage);
e2eContainer.bind<GitOauthAppsSettings>(CLASSES.GitOauthAppsSettings).to(GitOauthAppsSettings);
e2eContainer.bind<Sanitizer>(CLASSES.Sanitizer).to(Sanitizer);
e2eContainer.bind<ApiUrlResolver>(CLASSES.ApiUrlResolver).to(ApiUrlResolver);
e2eContainer.bind<WorkspaceHandlingTests>(CLASSES.WorkspaceHandlingTests).to(WorkspaceHandlingTests);

if (TestConstants.TS_OCP_LOGIN_PAGE_PROVIDER_TITLE === 'DevSandbox') {
e2eContainer.bind<RedHatLoginPage>(CLASSES.RedHatLoginPage).to(RedHatLoginPage);
e2eContainer.rebind<ICheLoginPage>(TYPES.CheLogin).to(OcpRedHatLoginPage);
}

export { e2eContainer };
36 changes: 3 additions & 33 deletions tests/e2e/configs/inversify.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,20 @@ const CLASSES = {
DriverHelper: 'DriverHelper',
Dashboard: 'Dashboard',
Workspaces: 'Workspaces',
NewWorkspace: 'NewWorkspace',
WorkspaceDetails: 'WorkspaceDetails',
WorkspaceDetailsPlugins: 'WorkspaceDetailsPlugins',
Ide: 'Ide',
ProjectTree: 'ProjectTree',
OpenEditors: 'OpenEditors',
Editor: 'Editor',
TopMenu: 'TopMenu',
QuickOpenContainer: 'QuickOpenContainer',
PreviewWidget: 'PreviewWidget',
GitHubPlugin: 'GitHubPlugin',
RightToolBar: 'RightToolBar',
LeftToolBar: 'LeftToolBar',
Terminal: 'Terminal',
DebugView: 'DebugView',
DialogWindow: 'DialogWindow',
ScreenCatcher: 'ScreenCatcher',
OpenshiftPlugin: 'OpenshiftPlugin',
OcpLoginPage: 'OcpLoginPage',
OpenWorkspaceWidget: 'OpenWorkspaceWidget',
ContextMenu: 'ContextMenu',
CheLoginPage: 'CheLoginPage',
GitHubUtil: 'GitHubUtil',
CheGitApi: 'CheGitApi',
GitPlugin: 'GitPlugin',
NotificationCenter: 'NotificationCenter',
CheApiRequestHandler: 'CheApiRequestHandler',
CreateWorkspace: 'CreateWorkspace',
OpenDialogWidget: 'OpenDialogWidget',
UpdateAccountInformationPage: 'UpdateAccountInformationPage',
KubernetesPlugin: 'KubernetesPlugin',
BrowserTabsUtil: 'BrowserTabsUtil',
PluginsView: 'PluginsView',
ProjectAndFileTests: 'ProjectAndFileTests',
WorkspaceNameHandler: 'WorkspaceNameHandler',
GitHubPullRequestPlugin: 'GitHubPullRequestPlugin',
GitLoginPage: 'GitLoginPage',
GitOauthAppsSettings: 'GitOauthAppsSettings',
AnimationChecker: 'AnimationChecker',
Sanitizer: 'Sanitizer',
NavigationBar: 'NavigationBar',
ApiUrlResolver: 'ApiUrlResolver',
LoginTests: 'LoginTests',
WorkspaceHandlingTests: 'WorkspaceHandlingTests'
WorkspaceHandlingTests: 'WorkspaceHandlingTests',
RedHatLoginPage: 'RedHatLoginPage',
OcpRedHatLoginPage: 'OcpRedHatLoginPage',
};

export { TYPES, CLASSES };
12 changes: 9 additions & 3 deletions tests/e2e/configs/mocharc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

import { TestConstants } from '../constants/TestConstants';

module.exports = {
timeout: 1200000,
reporter: './dist/utils/CheReporter.js',
Expand All @@ -11,11 +13,15 @@ module.exports = {
bail: true,
'full-trace': true,
spec:
// variable MOCHA_DIRECTORY uses in command "test-all-devfiles" and sets up automatically.
// you can set it up to run files from specific directory with export environmental variable.
process.env.MOCHA_DIRECTORY ?
// to run one file (name without extension). uses in "test", "test-all-devfiles".
process.env.USERSTORY ?
`dist/specs/${process.env.MOCHA_DIRECTORY}/${process.env.USERSTORY}.spec.js`
: `dist/specs/${process.env.MOCHA_DIRECTORY}/**.spec.js`
: `dist/specs/**/**.spec.js`,
grep: process.env.MOCHA_SUITE ? process.env.MOCHA_SUITE : '',
retries: process.env.MOCHA_RETRIES ? process.env.MOCHA_RETRIES : 3,
: process.env.USERSTORY ?
`dist/specs/**/${process.env.USERSTORY}.spec.js`
: `dist/specs/**/**.spec.js`,
retries: TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
};
4 changes: 0 additions & 4 deletions tests/e2e/configs/sh-scripts/initDefaultValues.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
export TS_SELENIUM_VALUE_TLS_SUPPORT=${TS_SELENIUM_VALUE_TLS_SUPPORT:-"true"}
export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=${TS_SELENIUM_VALUE_OPENSHIFT_OAUTH:-"false"}
export E2E_OCP_CLUSTER_VERSION=${E2E_OCP_CLUSTER_VERSION:-"4.x"}
export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=${TS_OCP_LOGIN_PAGE_PROVIDER_TITLE:-"htpasswd"}
export TS_SELENIUM_LOG_LEVEL=${TS_SELENIUM_LOG_LEVEL:-"DEBUG"}
export TS_SELENIUM_USERNAME=${TS_SELENIUM_USERNAME:-"admin"}
export TS_SELENIUM_PASSWORD=${TS_SELENIUM_PASSWORD:-"admin"}
export TS_SELENIUM_MULTIUSER=${TS_SELENIUM_MULTIUSER:-"true"}
export TS_SELENIUM_W3C_CHROME_OPTION=${TS_SELENIUM_W3C_CHROME_OPTION:-"true"}
export NODE_TLS_REJECT_UNAUTHORIZED=${NODE_TLS_REJECT_UNAUTHORIZED:-0}
export TS_SELENIUM_EDITOR=${TS_SELENIUM_EDITOR:-"che-code"}
Expand Down
Loading

0 comments on commit e20d5f1

Please sign in to comment.