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

Implement CheCode Editor POC test #21684

Merged
23 changes: 23 additions & 0 deletions tests/e2e/TestConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ function getBaseUrl(): string {
return baseUrl.replace(/\/$/, '');
}

export enum EditorType {
THEIA = 'theia',
CHE_CODE = 'che-code'
}

export const TestConstants = {
/**
* Base URL of the application which should be checked
Expand Down Expand Up @@ -54,6 +59,24 @@ export const TestConstants = {
*/
TS_SELENIUM_RESOLUTION_HEIGHT: Number(process.env.TS_SELENIUM_RESOLUTION_HEIGHT) || 1080,

/**
* Editor the tests are running against, "code" by default.
* Possible values: "che-code", "theia"
*/
TS_SELENIUM_EDITOR: process.env.TS_SELENIUM_EDITOR || EditorType.CHE_CODE,

/**
* Base version of VSCode editor for monaco-page-objects, "1.37.0" by default.
*/
TS_SELENIUM_MONACO_PAGE_OBJECTS_BASE_VERSION: process.env.TS_SELENIUM_MONACO_PAGE_OBJECTS_BASE_VERSION || '1.37.0',

/**
* Latest compatible version to be used, based on versions available in
* https://github.com/redhat-developer/vscode-extension-tester/tree/master/locators/lib ,
* "1.73.0" by default.
*/
TS_SELENIUM_MONACO_PAGE_OBJECTS_USE_VERSION: process.env.TS_SELENIUM_MONACO_PAGE_OBJECTS_USE_VERSION || '1.73.0',

/**
* Default ammount of tries, "5" by default.
*/
Expand Down
21 changes: 16 additions & 5 deletions tests/e2e/driver/CheReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ import { inversifyConfig } from '..';
import { TYPES, CLASSES } from '..';
import * as fs from 'fs';
import * as rm from 'rimraf';
import { TestConstants } from '../TestConstants';
import { EditorType, TestConstants } from '../TestConstants';
import { logging } from 'selenium-webdriver';
import { DriverHelper } from '../utils/DriverHelper';
import { ScreenCatcher } from '../utils/ScreenCatcher';
import { ITestWorkspaceUtil } from '../utils/workspace/ITestWorkspaceUtil';
// import { PreferencesHandler } from '../utils/PreferencesHandler';
import { AskForConfirmationTypeTheia, PreferencesHandlerTheia, TerminalRendererTypeTheia } from '../utils/theia/PreferencesHandlerTheia';
import { CheApiRequestHandler } from '../utils/requestHandlers/CheApiRequestHandler';
import { TimeoutConstants } from '../TimeoutConstants';
import { Logger } from '../utils/Logger';
import { Sanitizer } from '../utils/Sanitizer';
import * as monacoPageObjects from 'monaco-page-objects';
import * as vscodeExtensionTesterLocators from 'vscode-extension-tester-locators';

const e2eContainer = inversifyConfig.e2eContainer;
const driver: IDriver = e2eContainer.get(TYPES.Driver);
Expand All @@ -32,7 +34,6 @@ const sanitizer: Sanitizer = e2eContainer.get(CLASSES.Sanitizer);
let methodIndex: number = 0;
let deleteScreencast: boolean = true;
let testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
// let preferencesHandler: PreferencesHandler = e2eContainer.get(CLASSES.PreferencesHandler);

class CheReporter extends mocha.reporters.Spec {

Expand All @@ -56,6 +57,8 @@ class CheReporter extends mocha.reporters.Spec {
TS_SELENIUM_USERNAME: ${TestConstants.TS_SELENIUM_USERNAME}
TS_SELENIUM_PASSWORD: ${TestConstants.TS_SELENIUM_PASSWORD}

TS_SELENIUM_EDITOR: ${TestConstants.TS_SELENIUM_EDITOR}

TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME: ${TestConstants.TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME}
TS_SELENIUM_DELAY_BETWEEN_SCREENSHOTS: ${TestConstants.TS_SELENIUM_DELAY_BETWEEN_SCREENSHOTS}
TS_SELENIUM_REPORT_FOLDER: ${TestConstants.TS_SELENIUM_REPORT_FOLDER}
Expand Down Expand Up @@ -86,8 +89,16 @@ class CheReporter extends mocha.reporters.Spec {
if (TestConstants.TS_SELENIUM_RESPONSE_INTERCEPTOR) {
CheApiRequestHandler.enableResponseInterceptor();
}
// await preferencesHandler.setConfirmExit(AskForConfirmationType.never);
// await preferencesHandler.setTerminalType(TerminalRendererType.dom);

if (TestConstants.TS_SELENIUM_EDITOR === EditorType.THEIA) {
let preferencesHandler: PreferencesHandlerTheia = e2eContainer.get(CLASSES.PreferencesHandlerTheia);
await preferencesHandler.setConfirmExit(AskForConfirmationTypeTheia.never);
await preferencesHandler.setTerminalType(TerminalRendererTypeTheia.dom);
} else if (TestConstants.TS_SELENIUM_EDITOR === EditorType.CHE_CODE) {
// 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(), driver.get(), 'google-chrome');
}

});

runner.on('test', async function (test: mocha.Test) {
Expand Down
12 changes: 7 additions & 5 deletions tests/e2e/driver/ChromeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ export class ChromeDriver implements IDriver {
constructor() {
const options: Options = this.getDriverOptions();
this.driver = this.getDriverBuilder(options).build();

this.driver
.manage()
.window()
.setSize(TestConstants.TS_SELENIUM_RESOLUTION_WIDTH, TestConstants.TS_SELENIUM_RESOLUTION_HEIGHT);
}

get(): ThenableWebDriver {
return this.driver;
}

async setWindowSize() {
await this.driver
.manage()
.window()
.setSize(TestConstants.TS_SELENIUM_RESOLUTION_WIDTH, TestConstants.TS_SELENIUM_RESOLUTION_HEIGHT);
}

private getDriverOptions(): Options {
let options: Options = new Options()
.addArguments('--no-sandbox')
Expand Down
52 changes: 26 additions & 26 deletions tests/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export * from './utils/AnimationChecker';
export * from './utils/BrowserTabsUtil';
export * from './utils/DriverHelper';
export * from './utils/Logger';
export * from './utils/PreferencesHandler';
export * from './utils/theia/PreferencesHandlerTheia';
export * from './utils/requestHandlers/CheApiRequestHandler';
export * from './utils/requestHandlers/headers/CheMultiuserAuthorizationHeaderHandler';
export * from './utils/requestHandlers/headers/IAuthorizationHeaderHandler';
Expand All @@ -30,28 +30,28 @@ export * from './pageobjects/dashboard/Dashboard';
export * from './pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins';
export * from './pageobjects/dashboard/workspace-details/WorkspaceDetails';
export * from './pageobjects/dashboard/Workspaces';
export * from './pageobjects/ide/ContextMenu';
export * from './pageobjects/ide/DebugView';
export * from './pageobjects/ide/DialogWindow';
export * from './pageobjects/ide/Editor';
export * from './pageobjects/ide/Ide';
export * from './pageobjects/ide/LeftToolBar';
export * from './pageobjects/ide/NavigationBar';
export * from './pageobjects/ide/NotificationCenter';
export * from './pageobjects/ide/OpenDialogWidget';
export * from './pageobjects/ide/OpenEditors';
export * from './pageobjects/ide/OpenWorkspaceWidget';
export * from './pageobjects/ide/plugins/GitHubPullRequestPlugin';
export * from './pageobjects/ide/plugins/GitPlugin';
export * from './pageobjects/ide/plugins/KubernetesPlugin';
export * from './pageobjects/ide/plugins/OpenshiftPlugin';
export * from './pageobjects/ide/plugins/PluginsView';
export * from './pageobjects/ide/PreviewWidget';
export * from './pageobjects/ide/ProjectTree';
export * from './pageobjects/ide/QuickOpenContainer';
export * from './pageobjects/ide/RightToolBar';
export * from './pageobjects/ide/Terminal';
export * from './pageobjects/ide/TopMenu';
export * from './pageobjects/ide/theia/ContextMenu';
export * from './pageobjects/ide/theia/DebugView';
export * from './pageobjects/ide/theia/DialogWindow';
export * from './pageobjects/ide/theia/Editor';
export * from './pageobjects/ide/theia/Ide';
export * from './pageobjects/ide/theia/LeftToolBar';
export * from './pageobjects/ide/theia/NavigationBar';
export * from './pageobjects/ide/theia/NotificationCenter';
export * from './pageobjects/ide/theia/OpenDialogWidget';
export * from './pageobjects/ide/theia/OpenEditors';
export * from './pageobjects/ide/theia/OpenWorkspaceWidget';
export * from './pageobjects/ide/theia/plugins/GitHubPullRequestPlugin';
export * from './pageobjects/ide/theia/plugins/GitPlugin';
export * from './pageobjects/ide/theia/plugins/KubernetesPlugin';
export * from './pageobjects/ide/theia/plugins/OpenshiftPlugin';
export * from './pageobjects/ide/theia/plugins/PluginsView';
export * from './pageobjects/ide/theia/PreviewWidget';
export * from './pageobjects/ide/theia/ProjectTree';
export * from './pageobjects/ide/theia/QuickOpenContainer';
export * from './pageobjects/ide/theia/RightToolBar';
export * from './pageobjects/ide/theia/Terminal';
export * from './pageobjects/ide/theia/TopMenu';
export * from './pageobjects/login/ICheLoginPage';
export * from './pageobjects/login/IOcpLoginPage';
export * from './pageobjects/login/MultiUserLoginPage';
Expand All @@ -62,7 +62,7 @@ export * from './pageobjects/openshift/CheLoginPage';
export * from './pageobjects/openshift/OcpLoginPage';
export * from './pageobjects/third-parties/GitLoginPage';
export * from './pageobjects/third-parties/GitOauthAppsSettings';
export * from './testsLibrary/CodeExecutionTests';
export * from './testsLibrary/LanguageServerTests';
export * from './testsLibrary/ProjectAndFileTests';
export * from './testsLibrary/theia/CodeExecutionTestsTheia';
export * from './testsLibrary/theia/LanguageServerTestsTheia';
export * from './testsLibrary/theia/ProjectAndFileTestsTheia';
export * from './testsLibrary/WorkspaceHandlingTests';
2 changes: 2 additions & 0 deletions tests/e2e/initDefaultValues.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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"}

if [ "$E2E_OCP_CLUSTER_VERSION" = "3.x" ] ; then
unset TS_OCP_LOGIN_PAGE_PROVIDER_TITLE
Expand All @@ -25,3 +26,4 @@ echo "TS_SELENIUM_PASSWORD = ${TS_SELENIUM_PASSWORD}"
echo "TS_SELENIUM_MULTIUSER = ${TS_SELENIUM_MULTIUSER}"
echo "TS_SELENIUM_W3C_CHROME_OPTION = ${TS_SELENIUM_W3C_CHROME_OPTION}"
echo "NODE_TLS_REJECT_UNAUTHORIZED = ${NODE_TLS_REJECT_UNAUTHORIZED}"
echo "TS_SELENIUM_EDITOR = ${TS_SELENIUM_EDITOR}"
6 changes: 3 additions & 3 deletions tests/e2e/initDevfileTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ launchAllUserstories(){
echo "Launching all userstories";
echo ""

npm run lint && npm run tsc && mocha --config mocha-all-devfiles.json ;
npm run lint && npm run tsc && mocha --config mocha-all-devfiles-${TS_SELENIUM_EDITOR}.json ;
}

launchSingleUserstory(){
echo ""
echo "Launching the \"${USERSTORY}\" userstory";
echo ""

tsc && mocha --config mocha-single-devfile.json --spec dist/tests/login/Login.spec.js --spec dist/tests/devfiles/${USERSTORY}.spec.js ;
tsc && mocha --config mocha-single-devfile.json --spec dist/tests/login/Login.spec.js --spec dist/tests/devfiles/${TS_SELENIUM_EDITOR}/${USERSTORY}.spec.js ;
}

checkUserstoryName(){
local checkedName="$(ls tests/devfiles | grep ${USERSTORY}.spec.ts)";
local checkedName="$(ls tests/devfiles/${TS_SELENIUM_EDITOR} | grep ${USERSTORY}.spec.ts)";

if [ -z "$checkedName" ]; then
echo ""
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/initPluginTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ echo ""
echo "Launching the \"${USERSTORY}\" userstory";
echo ""

npm run init-mocha-opts -- --spec dist/tests/plugins/${USERSTORY}.spec.js
npm run init-mocha-opts -- --spec dist/tests/plugins/${TS_SELENIUM_EDITOR}/${USERSTORY}.spec.js
60 changes: 30 additions & 30 deletions tests/e2e/inversify.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@ import { TestConstants } from './TestConstants';
import { ICheLoginPage } from './pageobjects/login/ICheLoginPage';
import { RegularUserOcpCheLoginPage } from './pageobjects/login/RegularUserOcpCheLoginPage';
import { MultiUserLoginPage } from './pageobjects/login/MultiUserLoginPage';
import { ContextMenu } from './pageobjects/ide/ContextMenu';
import { ContextMenu } from './pageobjects/ide/theia/ContextMenu';
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 { Ide } from './pageobjects/ide/Ide';
import { ProjectTree } from './pageobjects/ide/ProjectTree';
import { OpenEditors } from './pageobjects/ide/OpenEditors';
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 { GitPlugin } from './pageobjects/ide/plugins/GitPlugin';
import { RightToolBar } from './pageobjects/ide/RightToolBar';
import { Terminal } from './pageobjects/ide/Terminal';
import { DebugView } from './pageobjects/ide/DebugView';
import { DialogWindow } from './pageobjects/ide/DialogWindow';
import { Ide } from './pageobjects/ide/theia/Ide';
import { ProjectTree } from './pageobjects/ide/theia/ProjectTree';
import { OpenEditors } from './pageobjects/ide/theia/OpenEditors';
import { Editor } from './pageobjects/ide/theia/Editor';
import { TopMenu } from './pageobjects/ide/theia/TopMenu';
import { QuickOpenContainer } from './pageobjects/ide/theia/QuickOpenContainer';
import { PreviewWidget } from './pageobjects/ide/theia/PreviewWidget';
import { GitPlugin } from './pageobjects/ide/theia/plugins/GitPlugin';
import { RightToolBar } from './pageobjects/ide/theia/RightToolBar';
import { Terminal } from './pageobjects/ide/theia/Terminal';
import { DebugView } from './pageobjects/ide/theia/DebugView';
import { DialogWindow } from './pageobjects/ide/theia/DialogWindow';
import { ScreenCatcher } from './utils/ScreenCatcher';
import { OcpLoginPage } from './pageobjects/openshift/OcpLoginPage';
import { OpenWorkspaceWidget } from './pageobjects/ide/OpenWorkspaceWidget';
import { OpenWorkspaceWidget } from './pageobjects/ide/theia/OpenWorkspaceWidget';
import { CheLoginPage } from './pageobjects/openshift/CheLoginPage';
import { NotificationCenter } from './pageobjects/ide/NotificationCenter';
import { PreferencesHandler } from './utils/PreferencesHandler';
import { NotificationCenter } from './pageobjects/ide/theia/NotificationCenter';
import { PreferencesHandlerTheia } from './utils/theia/PreferencesHandlerTheia';
import { IAuthorizationHeaderHandler } from './utils/requestHandlers/headers/IAuthorizationHeaderHandler';
import { CheMultiuserAuthorizationHeaderHandler } from './utils/requestHandlers/headers/CheMultiuserAuthorizationHeaderHandler';
import { CheMultiuserTokenHandler } from './utils/requestHandlers/tokens/CheMultiuserTokenHandler';
Expand All @@ -51,24 +51,24 @@ import { CheApiRequestHandler } from './utils/requestHandlers/CheApiRequestHandl
import { CheGitApi } from './utils/VCS/CheGitApi';
import { GitHubUtil } from './utils/VCS/github/GitHubUtil';
import { CreateWorkspace } from './pageobjects/dashboard/CreateWorkspace';
import { OpenshiftPlugin } from './pageobjects/ide/plugins/OpenshiftPlugin';
import { OpenDialogWidget } from './pageobjects/ide/OpenDialogWidget';
import { OpenshiftPlugin } from './pageobjects/ide/theia/plugins/OpenshiftPlugin';
import { OpenDialogWidget } from './pageobjects/ide/theia/OpenDialogWidget';
import { UpdateAccountInformationPage } from './pageobjects/login/UpdateAccountInformationPage';
import { LeftToolBar } from './pageobjects/ide/LeftToolBar';
import { KubernetesPlugin } from './pageobjects/ide/plugins/KubernetesPlugin';
import { LeftToolBar } from './pageobjects/ide/theia/LeftToolBar';
import { KubernetesPlugin } from './pageobjects/ide/theia/plugins/KubernetesPlugin';
import { BrowserTabsUtil } from './utils/BrowserTabsUtil';
import { PluginsView } from './pageobjects/ide/plugins/PluginsView';
import { LanguageServerTests } from './testsLibrary/LanguageServerTests';
import { CodeExecutionTests } from './testsLibrary/CodeExecutionTests';
import { ProjectAndFileTests } from './testsLibrary/ProjectAndFileTests';
import { PluginsView } from './pageobjects/ide/theia/plugins/PluginsView';
import { LanguageServerTestsTheia } from './testsLibrary/theia/LanguageServerTestsTheia';
import { CodeExecutionTestsTheia } from './testsLibrary/theia/CodeExecutionTestsTheia';
import { ProjectAndFileTestsTheia } from './testsLibrary/theia/ProjectAndFileTestsTheia';
import { WorkspaceHandlingTests } from './testsLibrary/WorkspaceHandlingTests';
import { GitHubPullRequestPlugin } from './pageobjects/ide/plugins/GitHubPullRequestPlugin';
import { GitHubPullRequestPlugin } from './pageobjects/ide/theia/plugins/GitHubPullRequestPlugin';
import { GitLoginPage } from './pageobjects/third-parties/GitLoginPage';
import { GitOauthAppsSettings } from './pageobjects/third-parties/GitOauthAppsSettings';
import { AnimationChecker } from './utils/AnimationChecker';
import { WorkspaceNameHandler } from './utils/WorkspaceNameHandler';
import { Sanitizer } from './utils/Sanitizer';
import { NavigationBar } from './pageobjects/ide/NavigationBar';
import { NavigationBar } from './pageobjects/ide/theia/NavigationBar';
import { ApiUrlResolver } from './utils/workspace/ApiUrlResolver';
import { ITestWorkspaceUtil } from './utils/workspace/ITestWorkspaceUtil';

Expand Down Expand Up @@ -112,7 +112,7 @@ e2eContainer.bind<OcpLoginPage>(CLASSES.OcpLoginPage).to(OcpLoginPage);
e2eContainer.bind<OpenWorkspaceWidget>(CLASSES.OpenWorkspaceWidget).to(OpenWorkspaceWidget);
e2eContainer.bind<CheLoginPage>(CLASSES.CheLoginPage).to(CheLoginPage);
e2eContainer.bind<NotificationCenter>(CLASSES.NotificationCenter).to(NotificationCenter);
e2eContainer.bind<PreferencesHandler>(CLASSES.PreferencesHandler).to(PreferencesHandler);
e2eContainer.bind<PreferencesHandlerTheia>(CLASSES.PreferencesHandlerTheia).to(PreferencesHandlerTheia);
e2eContainer.bind<CheApiRequestHandler>(CLASSES.CheApiRequestHandler).to(CheApiRequestHandler);
e2eContainer.bind<CheGitApi>(CLASSES.CheGitApi).to(CheGitApi);
e2eContainer.bind<GitHubUtil>(CLASSES.GitHubUtil).to(GitHubUtil);
Expand All @@ -122,9 +122,9 @@ e2eContainer.bind<OpenDialogWidget>(CLASSES.OpenDialogWidget).to(OpenDialogWidge
e2eContainer.bind<UpdateAccountInformationPage>(CLASSES.UpdateAccountInformationPage).to(UpdateAccountInformationPage);
e2eContainer.bind<KubernetesPlugin>(CLASSES.KubernetesPlugin).to(KubernetesPlugin);
e2eContainer.bind<PluginsView>(CLASSES.PluginsView).to(PluginsView);
e2eContainer.bind<LanguageServerTests>(CLASSES.LanguageServerTests).to(LanguageServerTests);
e2eContainer.bind<CodeExecutionTests>(CLASSES.CodeExecutionTests).to(CodeExecutionTests);
e2eContainer.bind<ProjectAndFileTests>(CLASSES.ProjectAndFileTests).to(ProjectAndFileTests);
e2eContainer.bind<LanguageServerTestsTheia>(CLASSES.LanguageServerTestsTheia).to(LanguageServerTestsTheia);
e2eContainer.bind<CodeExecutionTestsTheia>(CLASSES.CodeExecutionTestsTheia).to(CodeExecutionTestsTheia);
e2eContainer.bind<ProjectAndFileTestsTheia>(CLASSES.ProjectAndFileTestsTheia).to(ProjectAndFileTestsTheia);
e2eContainer.bind<WorkspaceHandlingTests>(CLASSES.WorkspaceHandlingTests).to(WorkspaceHandlingTests);
e2eContainer.bind<WorkspaceNameHandler>(CLASSES.WorkspaceNameHandler).to(WorkspaceNameHandler);
e2eContainer.bind<GitHubPullRequestPlugin>(CLASSES.GitHubPullRequestPlugin).to(GitHubPullRequestPlugin);
Expand Down
Loading