Skip to content

Commit

Permalink
Parametrizing VSCode versions for monaco-page-objects initialization
Browse files Browse the repository at this point in the history
Signed-off-by: Tibor Dancs <[email protected]>
  • Loading branch information
ScrewTSW committed Nov 25, 2022
1 parent 9b9a003 commit d730113
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 32 deletions.
21 changes: 19 additions & 2 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 @@ -56,9 +61,21 @@ export const TestConstants = {

/**
* Editor the tests are running against, "code" by default.
* Possible values: "code", "theia"
* 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_EDITOR: process.env.TS_SELENIUM_EDITOR || 'code',
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
11 changes: 7 additions & 4 deletions tests/e2e/driver/CheReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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';
Expand Down Expand Up @@ -57,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 @@ -88,12 +90,13 @@ class CheReporter extends mocha.reporters.Spec {
CheApiRequestHandler.enableResponseInterceptor();
}

if (TestConstants.TS_SELENIUM_EDITOR === 'theia') {
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 === 'code') {
monacoPageObjects.initPageObjects('1.71.0', '1.37.0', vscodeExtensionTesterLocators.getLocatorsPath(), driver.get(), 'google-chrome');
} 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');
}

});
Expand Down
14 changes: 2 additions & 12 deletions tests/e2e/initDevfileTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,11 @@ launchSingleUserstory(){
echo "Launching the \"${USERSTORY}\" userstory";
echo ""

if [ "${TS_SELENIUM_EDITOR}" == "theia" ]; then
tsc && mocha --config mocha-single-devfile.json --spec dist/tests/login/Login.spec.js --spec dist/tests/devfiles/theia/${USERSTORY}.spec.js ;
elif [ "${TS_SELENIUM_EDITOR}" == "code" ]; then
tsc && mocha --config mocha-single-devfile.json --spec dist/tests/login/Login.spec.js --spec dist/tests/devfiles/code/${USERSTORY}.spec.js ;
fi

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;
if [ "${TS_SELENIUM_EDITOR}" == "theia" ]; then
checkedName="$(ls tests/devfiles/theia | grep ${USERSTORY}.spec.ts)";
elif [ "${TS_SELENIUM_EDITOR}" == "code" ]; then
checkedName="$(ls tests/devfiles/code | grep ${USERSTORY}.spec.ts)";
fi
local checkedName="$(ls tests/devfiles/${TS_SELENIUM_EDITOR} | grep ${USERSTORY}.spec.ts)";

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

if [ "${TS_SELENIUM_EDITOR}" == "theia" ]; then
npm run init-mocha-opts -- --spec dist/tests/plugins/theia/${USERSTORY}.spec.js
elif [ "${TS_SELENIUM_EDITOR}" == "code" ]; then
npm run init-mocha-opts -- --spec dist/tests/plugins/code/${USERSTORY}.spec.js
fi
npm run init-mocha-opts -- --spec dist/tests/plugins/${TS_SELENIUM_EDITOR}/${USERSTORY}.spec.js
2 changes: 1 addition & 1 deletion tests/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"load-test-theia": "./generateIndex.sh && npm run lint && npm run tsc && mocha --config mocha-load-theia.json",
"test-happy-path-theia": "./generateIndex.sh && npm run lint && npm run tsc && mocha --config mocha-happy-path-theia.json",
"test-devworkspace-happy-path-theia": "./generateIndex.sh && npm run lint && npm run tsc && mocha --config mocha-devworkspace-happy-path-theia.json",
"test-wkspc-creation-and-ls-theia": "./generateIndex.sh && npm run lint && npm run tsc && mocha --config mocha-wkspc-creation-and-ls-theia.json",
"test-ws-creation-and-ls-theia": "./generateIndex.sh && npm run lint && npm run tsc && mocha --config mocha-ws-creation-and-ls-theia.json",
"test-java-vertx-theia": "./generateIndex.sh && npm run lint && npm run tsc && mocha --config mocha-java-vertx-theia.json",
"test-java-springboot-theia": "./generateIndex.sh && npm run lint && npm run tsc && mocha --config mocha-java-springboot-theia.json",
"test-git-ssh-theia": "./generateIndex.sh && npm run lint && npm run tsc && mocha --config mocha-git-ssh-theia.json",
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/pageobjects/ide/theia/ContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'reflect-metadata';
import { injectable, inject } from 'inversify';
import { DriverHelper } from '../../../utils/DriverHelper';
import { CLASSES } from '../../../inversify.types';
import { By, Key } from 'selenium-webdriver';
import { By, Key, WebElement } from 'selenium-webdriver';
import { Logger } from '../../../utils/Logger';
import { TimeoutConstants } from '../../../TimeoutConstants';

Expand All @@ -26,8 +26,8 @@ export class ContextMenu {
async invokeContextMenuOnTheElementWithMouse(elementLocator: By) {
Logger.debug(`ContextMenu.invokeContextMenuOnTheElementWithMouse ${elementLocator}`);

// const webElement: WebElement = await this.driverHelper.waitVisibility(elementLocator, TimeoutConstants.TS_CONTEXT_MENU_TIMEOUT);
// await this.driverHelper.getAction().click(webElement, Button.RIGHT).perform();
const webElement: WebElement = await this.driverHelper.waitVisibility(elementLocator, TimeoutConstants.TS_CONTEXT_MENU_TIMEOUT);
await this.driverHelper.getAction().contextClick(webElement).perform();
this.waitContextMenu();
}

Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/tests/devfiles/code/JavaSpringBoot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ suite(`${stack} test`, async () => {
await dashboard.clickCreateWorkspaceButton();
await createWorkspace.waitPage();
workspaceHandlingTests.setWindowHandle(await browserTabsUtil.getCurrentWindowHandle());
await createWorkspace.startWorkspaceUsingFactory(`https://github.com/devspaces-samples/rest-http-example/tree/devspaces-3-rhel-8?che-editor=che-incubator/che-code/insiders&storageType=persistent`);
await createWorkspace.startWorkspaceUsingFactory(`https://github.com/che-samples/web-java-spring-boot/tree/master?che-editor=che-incubator/che-code/insiders&storageType=persistent`);
await browserTabsUtil.waitAndSwitchToAnotherWindow(workspaceHandlingTests.getWindowHandle(), TimeoutConstants.TS_IDE_LOAD_TIMEOUT);
});
workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
Expand All @@ -61,8 +61,6 @@ suite(`${stack} test`, async () => {
let workbench = new Workbench();
let activityBar = workbench.getActivityBar();
let activityBarControls = await activityBar.getViewControls();
// let sidebarContent = activityBar.getViewControl();
// let sidebarViewSections = await sidebarContent.getSections();
Logger.debug(`Editor sections:`);
activityBarControls.forEach(async control => {
Logger.debug(`${await control.getTitle()}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ const SpringAppLocators = {
suite('Workspace creation via factory url', async () => {
let factoryUrl : string = `${TestConstants.TS_SELENIUM_DEVWORKSPACE_URL}`;

// const workspaceRootFolderName: string = 'src';

suite('Open factory URL', async () => {
// this is DevWorkspace test specific - we create the test ws. using factory instead of chectl
test(`Navigating to factory URL`, async () => {
Expand Down

0 comments on commit d730113

Please sign in to comment.