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
  • Loading branch information
Maryna Dolhalova committed Mar 27, 2023
1 parent 176fabb commit ba34736
Show file tree
Hide file tree
Showing 59 changed files with 1,578 additions and 1,684 deletions.
43 changes: 9 additions & 34 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 @@ -21,13 +21,14 @@ Note: If there is any modifications in package.json, manually execute the `npm i
- Provide connection credentials to Che:
- ```export TS_SELENIUM_USERNAME=<username>```
- ```export TS_SELENIUM_PASSWORD=<password>```
- ```npm test```
- ```npm run test-regression```

## 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>``` and run script ```npm run test-userstory```
- To test all specification in folder ```export MOCHA_DIRECTORY=<directory-name>``` and run script ```npm run test-suite```

## Docker launch

Expand Down Expand Up @@ -58,35 +59,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 +72,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```
22 changes: 7 additions & 15 deletions tests/e2e/configs/inversify.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,30 @@ 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);
Expand All @@ -67,22 +60,21 @@ 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 };
35 changes: 3 additions & 32 deletions tests/e2e/configs/inversify.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,21 @@ 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 };
4 changes: 3 additions & 1 deletion tests/e2e/configs/mocharc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ module.exports = {
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`,
: process.env.USERSTORY ?
`dist/specs/**/${process.env.USERSTORY}.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,
};
111 changes: 55 additions & 56 deletions tests/e2e/constants/TestConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ function getBaseUrl(): string {
return baseUrl.replace(/\/$/, '');
}

export enum GitProviderType {
GITHUB = 'github',
GITLAB = 'gitlab',
BITBUCKET = 'bitbucket'
}

export enum EditorType {
THEIA = 'theia',
CHE_CODE = 'che-code'
Expand Down Expand Up @@ -98,14 +104,14 @@ export const TestConstants = {
TS_SELENIUM_WORKSPACE_STATUS_POLLING: Number(process.env.TS_SELENIUM_WORKSPACE_STATUS_POLLING) || 10000,

/**
* Amount of tries for checking plugin precence.
* Amount of tries for checking plugin presence.
*/
TS_SELENIUM_PLUGIN_PRECENCE_ATTEMPTS: Number(process.env.TS_SELENIUM_PLUGIN_PRECENCE_ATTEMPTS) || 20,
TS_SELENIUM_PLUGIN_PRESENCE_ATTEMPTS: Number(process.env.TS_SELENIUM_PLUGIN_PRECENCE_ATTEMPTS) || 20,

/**
* Name of workspace created for 'Happy Path' scenario validation.
*/
TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME: process.env.TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME || 'petclinic-dev-environment',
TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME: process.env.TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME || 'EmptyWorkspace',

/**
* Using 'single-host' strategy, "false" by default.
Expand Down Expand Up @@ -211,86 +217,79 @@ export const TestConstants = {
/**
* Running test suite - possible variants can be found in package.json scripts part.
*/
TEST_SUITE: process.env.TEST_SUITE || 'test-happy-path',
TEST_SUITE: process.env.TEST_SUITE || 'userstory',

/**
* The repo (with README.md in root) and access token are needed for to run test-git-ssh
* Print all timeout variables when tests launch, defaulte to false
*/
TS_GITHUB_TEST_REPO: process.env.TS_GITHUB_TEST_REPO || '',
TS_SELENIUM_PRINT_TIMEOUT_VARIABLES: process.env.TS_SELENIUM_PRINT_TIMEOUT_VARIABLES || false,

/**
* Token for a github repository with permissions which allow add the ssh keys
* URL of the workspace created by devworkspace-controller
*/
TS_GITHUB_TEST_REPO_ACCESS_TOKEN: process.env.TS_GITHUB_TEST_REPO_ACCESS_TOKEN || '',
TS_SELENIUM_DEVWORKSPACE_URL: process.env.TS_SELENIUM_DEVWORKSPACE_URL,

/**
* Username of the github account
* This variable specifies that run test is used for load testing and that all artifacts will be sent to ftp client.
*/
TS_GITHUB_USERNAME: process.env.TS_GITHUB_USERNAME || '',
TS_LOAD_TESTS: process.env.TS_LOAD_TESTS || 'false',

/**
* Password of the github account
* Constant, which prolong timeout constants for local debug.
*/
TS_GITHUB_PASSWORD: process.env.TS_GITHUB_PASSWORD || '',
TS_DEBUG_MODE: process.env.TS_DEBUG_MODE === 'true',

/**
* Login for a user whom has been created in the test Openshift cluster. Need for Openshift connector test
* Path to the folder with upstream "Che"
*/
TS_TEST_OPENSHIFT_PLUGIN_USERNAME: process.env.TS_TEST_OPENSHIFT_PLUGIN_USERNAME || '',
E2E_PATH_TO_UPSTREAM_PACKAGE: process.env.E2E_PATH_TO_UPSTREAM || '/tmp/che/tests/e2e',

/**
* Password for a user whom has been created in the test Openshift cluster. Need for Openshift connector test
*/
TS_TEST_OPENSHIFT_PLUGIN_PASSWORD: process.env.TS_TEST_OPENSHIFT_PLUGIN_PASSWORD || '',
E2E_OCP_CLUSTER_VERSION: process.env.E2E_OCP_CLUSTER_VERSION || '4.x',

/**
* The name of project in the Openshift plugin tree
*/
TS_TEST_OPENSHIFT_PLUGIN_PROJECT: process.env.TS_TEST_OPENSHIFT_PLUGIN_PROJECT || '',
E2E_OCP_CLUSTER_API_URL: process.env.E2E_OCP_CLUSTER_API_URL || '',

/**
* The name of the Openshift connector plugin component type
*/
TS_TEST_OPENSHIFT_PLUGIN_COMPONENT_TYPE: process.env.TS_TEST_OPENSHIFT_PLUGIN_COMPONENT_TYPE || 'nodejs (s2i)',
E2E_OPENSHIFT_TOKEN: process.env.E2E_OPENSHIFT_TOKEN || '',

E2E_ANOTHER_WINDOW_TIMEOUT: Number(process.env.E2E_ANOTHER_WINDOW_TIMEOUT) || 60000,

/**
* The name of the Openshift connector plugin component version
*/
TS_TEST_OPENSHIFT_PLUGIN_COMPONENT_VERSION: process.env.TS_TEST_OPENSHIFT_PLUGIN_COMPONENT_VERSION || 'latest',
TS_SELENIUM_VALUE_TLS_SUPPORT: process.env.TS_SELENIUM_VALUE_TLS_SUPPORT || 'true',

/**
* Print all timeout variables when tests launch, defaulte to false
* Timeout for dialog window, "120 000" by default
*/
TS_SELENIUM_PRINT_TIMEOUT_VARIABLES: process.env.TS_SELENIUM_PRINT_TIMEOUT_VARIABLES || false,
TS_DIALOG_WINDOW_TIMEOUT: Number(process.env.TS_DIALOG_WINDOW_TIMEOUT) || 120_000,

/**
* URL of the workspace created by devworkspace-controller
*/
TS_SELENIUM_DEVWORKSPACE_URL: process.env.TS_SELENIUM_DEVWORKSPACE_URL,
/* -------------------------------------------
| The factory tests related constants
----------------------------------------------*/
TS_SELENIUM_FACTORY_GIT_PROVIDER: process.env.TS_SELENIUM_FACTORY_GIT_PROVIDER || GitProviderType.GITHUB,

/**
* This variable specifies that run test is used for load testing and that all artifacts will be sent to ftp client.
*/
TS_LOAD_TESTS: process.env.TS_LOAD_TESTS || 'false',
TS_SELENIUM_FACTORY_GIT_REPO_URL: process.env.TS_SELENIUM_FACTORY_GIT_REPO_URL || '',

/**
* This variable determines whether to delete the workspace after the test or leave the workspace running.
*/
TS_DELETE_PLUGINS_TEST_WORKSPACE: process.env.TS_DELETE_PLUGINS_TEST_WORKSPACE || 'true',
TS_SELENIUM_IS_PRIVATE_FACTORY_GIT_REPO: true,

/**
* URL of Gogs self-hosted Git server.
*/
TS_SELF_HOSTED_GIT_SERVER_URL: process.env.TS_SELF_HOSTED_GIT_SERVER_URL || '10.0.104.86:10080',
TS_SELENIUM_FACTORY_GIT_REPO_BRANCH: process.env.TS_SELENIUM_FACTORY_GIT_REPO_BRANCH || 'master',

/**
* URL of workspace devfile test repository.
*/
TS_TEST_WORKSPACE_DEVFILE_REPO: process.env.TS_TEST_WORKSPACE_DEVFILE_REPO || '',
TS_SELENIUM_FACTORY_URL() {
return process.env.TS_SELENIUM_FACTORY_URL || TestConstants.TS_SELENIUM_BASE_URL + '/dashboard/#/' + this.TS_SELENIUM_FACTORY_GIT_REPO_URL;
},

/**
* Constant, which prolong timeout constants for local debug.
*/
TS_DEBUG_MODE: process.env.TS_DEBUG_MODE || false
TS_SELENIUM_GIT_PROVIDER_USERNAME: process.env.TS_SELENIUM_GIT_PROVIDER_USERNAME || '',

TS_SELENIUM_GIT_PROVIDER_PASSWORD: process.env.TS_SELENIUM_GIT_PROVIDER_PASSWORD || '',

TS_SELENIUM_GIT_PROVIDER_IS_LDAP_LOGIN: process.env.TS_SELENIUM_GIT_PROVIDER_IS_LDAP_LOGIN || false,

TS_SELENIUM_GIT_PROVIDER_OAUTH: process.env.TS_SELENIUM_GIT_PROVIDER_OAUTH || false,

TS_SELENIUM_PROJECT_ROOT_FILE_NAME: process.env.TS_SELENIUM_PROJECT_ROOT_FILE_NAME || 'devfile.yaml',

/* -------------------------------------------
| The airgap mode related constants
----------------------------------------------*/
TS_SELENIUM_TYPESCRIPT_DEBUG_IMAGE: process.env.TS_SELENIUM_TYPESCRIPT_DEBUG_IMAGE || 'quay.io/eclipse/che-nodejs10-ubi:7.35.2',

TS_SELENIUM_PHP_DEBUG_IMAGE: process.env.TS_SELENIUM_PHP_DEBUG_IMAGE || 'registry.redhat.io/codeready-workspaces/stacks-php-rhel8:latest',

TS_SELENIUM_PROJECT_TYPE: process.env.TS_SELENIUM_PROJECT_TYPE || 'zip'
};
11 changes: 0 additions & 11 deletions tests/e2e/files/devfiles/plugins/GitHubPullRequestPlugin.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions tests/e2e/files/devfiles/plugins/InstallPluginUsingUI.yaml

This file was deleted.

Loading

0 comments on commit ba34736

Please sign in to comment.