@eclipse-che/che-e2e
Advanced tools
Comparing version 7.46.1-dev-deca6d7 to 7.46.1-dev-e59785f
@@ -48,3 +48,3 @@ "use strict"; | ||
let deleteScreencast = true; | ||
let testWorkspaceUtil = e2eContainer.get(__2.TYPES.WorkspaceUtil); | ||
let testWorkspaceUtil = e2eContainer.get(__2.CLASSES.WorkspaceUtil); | ||
// let preferencesHandler: PreferencesHandler = e2eContainer.get(CLASSES.PreferencesHandler); | ||
@@ -51,0 +51,0 @@ class CheReporter extends mocha.reporters.Spec { |
@@ -47,3 +47,4 @@ "use strict"; | ||
__exportStar(require("./utils/VCS/github/GitHubUtil"), exports); | ||
__exportStar(require("./utils/workspace/ITestWorkspaceUtil"), exports); | ||
__exportStar(require("./utils/workspace/ApiUrlResolver"), exports); | ||
__exportStar(require("./utils/workspace/IApiUrlResolver"), exports); | ||
__exportStar(require("./utils/WorkspaceNameHandler"), exports); | ||
@@ -50,0 +51,0 @@ __exportStar(require("./utils/workspace/TestWorkspaceUtil"), exports); |
@@ -69,6 +69,6 @@ "use strict"; | ||
const NavigationBar_1 = require("./pageobjects/ide/NavigationBar"); | ||
const ApiUrlResolver_1 = require("./utils/workspace/ApiUrlResolver"); | ||
const e2eContainer = new inversify_1.Container({ defaultScope: 'Transient' }); | ||
exports.e2eContainer = e2eContainer; | ||
e2eContainer.bind(inversify_types_1.TYPES.Driver).to(ChromeDriver_1.ChromeDriver).inSingletonScope(); | ||
e2eContainer.bind(inversify_types_1.TYPES.WorkspaceUtil).to(TestWorkspaceUtil_1.TestWorkspaceUtil); | ||
e2eContainer.bind(inversify_types_1.TYPES.OcpLogin).to(OcpUserLoginPage_1.OcpUserLoginPage); | ||
@@ -129,2 +129,4 @@ e2eContainer.bind(inversify_types_1.TYPES.IAuthorizationHeaderHandler).to(CheMultiuserAuthorizationHeaderHandler_1.CheMultiuserAuthorizationHeaderHandler); | ||
e2eContainer.bind(inversify_types_1.CLASSES.NavigationBar).to(NavigationBar_1.NavigationBar); | ||
e2eContainer.bind(inversify_types_1.CLASSES.ApiUrlResolver).to(ApiUrlResolver_1.ApiUrlResolver); | ||
e2eContainer.bind(inversify_types_1.CLASSES.WorkspaceUtil).to(TestWorkspaceUtil_1.TestWorkspaceUtil); | ||
//# sourceMappingURL=inversify.config.js.map |
@@ -17,8 +17,9 @@ "use strict"; | ||
OcpLogin: Symbol.for('OcpLogin'), | ||
WorkspaceUtil: Symbol.for('WorkspaceUtil'), | ||
IAuthorizationHeaderHandler: Symbol.for('IAuthorizationHeaderHandler'), | ||
ITokenHandler: Symbol.for('ITokenHandler') | ||
ITokenHandler: Symbol.for('ITokenHandler'), | ||
IApiUrlResolver: Symbol.for('IApiUrlResolver') | ||
}; | ||
exports.TYPES = TYPES; | ||
const CLASSES = { | ||
WorkspaceUtil: 'WorkspaceUtil', | ||
DriverHelper: 'DriverHelper', | ||
@@ -71,5 +72,6 @@ Dashboard: 'Dashboard', | ||
Sanitizer: 'Sanitizer', | ||
NavigationBar: 'NavigationBar' | ||
NavigationBar: 'NavigationBar', | ||
ApiUrlResolver: 'ApiUrlResolver' | ||
}; | ||
exports.CLASSES = CLASSES; | ||
//# sourceMappingURL=inversify.types.js.map |
@@ -35,6 +35,8 @@ "use strict"; | ||
const Logger_1 = require("../../utils/Logger"); | ||
const BrowserTabsUtil_1 = require("../../utils/BrowserTabsUtil"); | ||
let Dashboard = Dashboard_1 = class Dashboard { | ||
constructor(driverHelper, workspaces) { | ||
constructor(driverHelper, workspaces, browserTabsUtil) { | ||
this.driverHelper = driverHelper; | ||
this.workspaces = workspaces; | ||
this.browserTabsUtil = browserTabsUtil; | ||
} | ||
@@ -65,7 +67,32 @@ async stopWorkspaceByUI(workspaceName) { | ||
} | ||
async stopAndRemoveWorkspaceWithSelectingTab(workspaceName) { | ||
Logger_1.Logger.debug(`Dashboard.stopAndRemoveWorkspaceWithSelectingTab "${workspaceName}"`); | ||
await this.switchToDashboardTab(); | ||
await this.stopWorkspaceByUI(workspaceName); | ||
await this.workspaces.deleteWorkspaceByActionsButton(workspaceName); | ||
await this.workspaces.waitWorkspaceListItemAbcence(workspaceName); | ||
} | ||
async openDashboard() { | ||
Logger_1.Logger.debug('Dashboard.openDashboard'); | ||
// sometimes we can have opened files. In this case we get Alert dialog. We should perform it. | ||
await this.driverHelper.getDriver().navigate().to(TestConstants_1.TestConstants.TS_SELENIUM_BASE_URL); | ||
try { | ||
await this.waitPage(); | ||
} | ||
catch (err) { | ||
if (err instanceof selenium_webdriver_1.error.UnexpectedAlertOpenError) { | ||
this.driverHelper.getDriver().switchTo().alert().accept(); | ||
} | ||
else { | ||
throw err; | ||
} | ||
} | ||
await this.waitPage(); | ||
} | ||
// click on the Browser tab which has been registered in the WorkspaceHandlingTests class | ||
async switchToDashboardTab() { | ||
Logger_1.Logger.debug('Dashboard.openDashboardTab'); | ||
await this.findAndClickDashboardTab(); | ||
await this.waitPage(); | ||
} | ||
async waitPage(timeout = TimeoutConstants_1.TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT) { | ||
@@ -104,2 +131,22 @@ Logger_1.Logger.debug('Dashboard.waitPage'); | ||
} | ||
async findAndClickDashboardTab(timeout = TimeoutConstants_1.TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { | ||
Logger_1.Logger.debug('Dashboard.findAndClickDashboardTab'); | ||
await this.driverHelper.waitUntilTrue(async () => { | ||
const windowHandles = await this.browserTabsUtil.getAllWindowHandles(); | ||
return windowHandles.length > 1; | ||
}, timeout); | ||
const windowHandles = await this.browserTabsUtil.getAllWindowHandles(); | ||
windowHandles.forEach(async (windowHandle) => { | ||
await this.browserTabsUtil.switchToWindow(windowHandle); | ||
try { | ||
this.driverHelper.waitVisibility(selenium_webdriver_1.By.xpath(Dashboard_1.CREATE_WORKSPACE_BUTTON_XPATH)); | ||
Logger_1.Logger.info('Dashboard tab has been selected'); | ||
return; | ||
} | ||
catch (_a) { | ||
Logger_1.Logger.warn('The Dashboard Tab is not found in the window: ' + this.browserTabsUtil.getCurrentWindowHandle()); | ||
} | ||
}); | ||
Logger_1.Logger.warn('The Dashboard Tab is not opened'); | ||
} | ||
}; | ||
@@ -114,6 +161,8 @@ Dashboard.WORKSPACES_BUTTON_XPATH = `//div[@id='page-sidebar']//a[contains(text(), 'Workspaces (')]`; | ||
__param(1, inversify_1.inject(inversify_types_1.CLASSES.Workspaces)), | ||
__param(2, inversify_1.inject(inversify_types_1.CLASSES.BrowserTabsUtil)), | ||
__metadata("design:paramtypes", [DriverHelper_1.DriverHelper, | ||
Workspaces_1.Workspaces]) | ||
Workspaces_1.Workspaces, | ||
BrowserTabsUtil_1.BrowserTabsUtil]) | ||
], Dashboard); | ||
exports.Dashboard = Dashboard; | ||
//# sourceMappingURL=Dashboard.js.map |
@@ -33,2 +33,3 @@ "use strict"; | ||
const Ide_1 = require("../../ide/Ide"); | ||
const TestWorkspaceUtil_1 = require("../../../utils/workspace/TestWorkspaceUtil"); | ||
const WorkspaceStatus_1 = require("../../../utils/workspace/WorkspaceStatus"); | ||
@@ -135,6 +136,7 @@ const Logger_1 = require("../../../utils/Logger"); | ||
__param(0, inversify_1.inject(inversify_types_1.CLASSES.DriverHelper)), | ||
__param(1, inversify_1.inject(inversify_types_1.TYPES.WorkspaceUtil)), | ||
__metadata("design:paramtypes", [DriverHelper_1.DriverHelper, Object]) | ||
__param(1, inversify_1.inject(inversify_types_1.CLASSES.WorkspaceUtil)), | ||
__metadata("design:paramtypes", [DriverHelper_1.DriverHelper, | ||
TestWorkspaceUtil_1.TestWorkspaceUtil]) | ||
], WorkspaceDetails); | ||
exports.WorkspaceDetails = WorkspaceDetails; | ||
//# sourceMappingURL=WorkspaceDetails.js.map |
@@ -31,2 +31,3 @@ "use strict"; | ||
const WorkspaceDetails_1 = require("./WorkspaceDetails"); | ||
const TestWorkspaceUtil_1 = require("../../../utils/workspace/TestWorkspaceUtil"); | ||
const WorkspaceStatus_1 = require("../../../utils/workspace/WorkspaceStatus"); | ||
@@ -93,7 +94,8 @@ const Logger_1 = require("../../../utils/Logger"); | ||
__param(1, inversify_1.inject(inversify_types_1.CLASSES.WorkspaceDetails)), | ||
__param(2, inversify_1.inject(inversify_types_1.TYPES.WorkspaceUtil)), | ||
__param(2, inversify_1.inject(inversify_types_1.CLASSES.WorkspaceUtil)), | ||
__metadata("design:paramtypes", [DriverHelper_1.DriverHelper, | ||
WorkspaceDetails_1.WorkspaceDetails, Object]) | ||
WorkspaceDetails_1.WorkspaceDetails, | ||
TestWorkspaceUtil_1.TestWorkspaceUtil]) | ||
], WorkspaceDetailsPlugins); | ||
exports.WorkspaceDetailsPlugins = WorkspaceDetailsPlugins; | ||
//# sourceMappingURL=WorkspaceDetailsPlugins.js.map |
@@ -18,3 +18,3 @@ "use strict"; | ||
const browserTabsUtil = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.BrowserTabsUtil); | ||
const testWorkspaceUtils = inversify_config_1.e2eContainer.get(inversify_types_1.TYPES.WorkspaceUtil); | ||
const testWorkspaceUtils = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.WorkspaceUtil); | ||
const workspaceHandlingTests = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.WorkspaceHandlingTests); | ||
@@ -21,0 +21,0 @@ const factoryUrl = `${TestConstants_1.TestConstants.TS_SELENIUM_BASE_URL}/f?url=https://raw.githubusercontent.com/eclipse/che-devfile-registry/master/devfiles/java-maven/devfile.yaml`; |
@@ -26,3 +26,3 @@ "use strict"; | ||
const gitPlugin = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.GitPlugin); | ||
const testWorkspaceUtils = inversify_config_1.e2eContainer.get(inversify_types_1.TYPES.WorkspaceUtil); | ||
const testWorkspaceUtils = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.WorkspaceUtil); | ||
const workspaceNameHandler = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.WorkspaceNameHandler); | ||
@@ -29,0 +29,0 @@ const workspacePrefixUrl = `${TestConstants_1.TestConstants.TS_SELENIUM_BASE_URL}/dashboard/#/ide/${TestConstants_1.TestConstants.TS_SELENIUM_USERNAME}/`; |
@@ -25,3 +25,3 @@ "use strict"; | ||
const gitPlugin = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.GitPlugin); | ||
const testWorkspaceUtils = inversify_config_1.e2eContainer.get(inversify_types_1.TYPES.WorkspaceUtil); | ||
const testWorkspaceUtils = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.WorkspaceUtil); | ||
const dashboard = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.Dashboard); | ||
@@ -28,0 +28,0 @@ const browserTabsUtil = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.BrowserTabsUtil); |
@@ -28,3 +28,3 @@ "use strict"; | ||
const gitPlugin = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.GitPlugin); | ||
const testWorkspaceUtils = inversify_config_1.e2eContainer.get(inversify_types_1.TYPES.WorkspaceUtil); | ||
const testWorkspaceUtils = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.WorkspaceUtil); | ||
const dashboard = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.Dashboard); | ||
@@ -31,0 +31,0 @@ const browserTabsUtil = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.BrowserTabsUtil); |
@@ -24,3 +24,3 @@ "use strict"; | ||
const loginPage = inversify_config_1.e2eContainer.get(inversify_types_1.TYPES.CheLogin); | ||
const testWorkspaceUtils = inversify_config_1.e2eContainer.get(inversify_types_1.TYPES.WorkspaceUtil); | ||
const testWorkspaceUtils = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.WorkspaceUtil); | ||
const openshiftPlugin = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.OpenshiftPlugin); | ||
@@ -27,0 +27,0 @@ const dashboard = inversify_config_1.e2eContainer.get(inversify_types_1.CLASSES.Dashboard); |
@@ -41,4 +41,4 @@ "use strict"; | ||
const QuickOpenContainer_1 = require("../pageobjects/ide/QuickOpenContainer"); | ||
const BrowserTabsUtil_1 = require("../utils/BrowserTabsUtil"); | ||
const WorkspaceHandlingTests_1 = require("./WorkspaceHandlingTests"); | ||
const BrowserTabsUtil_1 = require("../utils/BrowserTabsUtil"); | ||
let CodeExecutionTests = CodeExecutionTests_1 = class CodeExecutionTests { | ||
@@ -80,3 +80,2 @@ constructor(terminal, topMenu, ide, dialogWindow, driverHelper, quickOpenContainer, browserTabsUtil, workspaceHandlingTests) { | ||
await this.runTaskUsingQuickOpenContainer(taskName); | ||
this.workspaceHandlingTests.setWindowHandle(await this.browserTabsUtil.getCurrentWindowHandle()); | ||
await this.dialogWindow.waitDialogAndOpenLink(expectedDialogText, timeout); | ||
@@ -124,4 +123,8 @@ }); | ||
await this.ide.waitNotification(notificationText, timeout); | ||
this.workspaceHandlingTests.setWindowHandle(await this.browserTabsUtil.getCurrentWindowHandle()); | ||
// the application can have delay before running. Sometimes it consume about sec. | ||
// todo improve the check of avalibility test application | ||
await this.driverHelper.wait(10000); | ||
await this.ide.clickOnNotificationButton(notificationText, buttonText); | ||
// delay for openning an app. window | ||
// todo may be improved. | ||
await this.driverHelper.wait(5000); | ||
@@ -139,3 +142,8 @@ CodeExecutionTests_1.lastApplicationUrl = await this.driverHelper.getDriver().getCurrentUrl(); | ||
this.workspaceHandlingTests.setWindowHandle(await this.browserTabsUtil.getCurrentWindowHandle()); | ||
// the application can have delay before running. Sometimes it consume about sec. | ||
// todo improve the check of avalibility test application | ||
await this.driverHelper.wait(10000); | ||
await this.ide.clickOnNotificationButton(notificationText, 'Open In Preview'); | ||
// delay for openning an app. window | ||
// todo may be improved. | ||
await this.driverHelper.wait(5000); | ||
@@ -149,3 +157,2 @@ CodeExecutionTests_1.lastApplicationUrl = await this.driverHelper.getDriver().getCurrentUrl(); | ||
await this.ide.waitNotificationAndConfirm(notificationText, timeout); | ||
this.workspaceHandlingTests.setWindowHandle(await this.browserTabsUtil.getCurrentWindowHandle()); | ||
await this.ide.waitNotificationAndOpenLink(portOpenText, timeout); | ||
@@ -152,0 +159,0 @@ await this.driverHelper.wait(5000); |
@@ -113,2 +113,5 @@ "use strict"; | ||
} | ||
async patch(relativeUrl, patchParams) { | ||
return await axios_1.default.patch(this.assembleUrl(relativeUrl), patchParams, await this.headerHandler.get()); | ||
} | ||
assembleUrl(relativeUrl) { | ||
@@ -115,0 +118,0 @@ return `${TestConstants_1.TestConstants.TS_SELENIUM_BASE_URL}/${relativeUrl}`; |
@@ -23,2 +23,5 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var TestWorkspaceUtil_1; | ||
@@ -30,3 +33,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
const DriverHelper_1 = require("../DriverHelper"); | ||
const ApiUrlResolver_1 = require("./ApiUrlResolver"); | ||
require("reflect-metadata"); | ||
const WorkspaceStatus_1 = require("./WorkspaceStatus"); | ||
const selenium_webdriver_1 = require("selenium-webdriver"); | ||
@@ -36,27 +41,123 @@ const CheApiRequestHandler_1 = require("../requestHandlers/CheApiRequestHandler"); | ||
const Logger_1 = require("../Logger"); | ||
const axios_1 = __importDefault(require("axios")); | ||
let TestWorkspaceUtil = TestWorkspaceUtil_1 = class TestWorkspaceUtil { | ||
constructor(driverHelper, processRequestHandler) { | ||
constructor(driverHelper, processRequestHandler, apiUrlResolver) { | ||
this.driverHelper = driverHelper; | ||
this.processRequestHandler = processRequestHandler; | ||
this.apiUrlResolver = apiUrlResolver; | ||
this.attempts = TestConstants_1.TestConstants.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS; | ||
this.polling = TestConstants_1.TestConstants.TS_SELENIUM_WORKSPACE_STATUS_POLLING; | ||
} | ||
async waitWorkspaceStatus(namespace, workspaceName, expectedWorkspaceStatus) { | ||
Logger_1.Logger.debug('TestWorkspaceUtil.waitWorkspaceStatus'); | ||
const workspaceStatusApiUrl = `${TestWorkspaceUtil_1.WORKSPACE_API_URL}/${namespace}:${workspaceName}`; | ||
const attempts = TestConstants_1.TestConstants.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS; | ||
const polling = TestConstants_1.TestConstants.TS_SELENIUM_WORKSPACE_STATUS_POLLING; | ||
let workspaceStatus = ''; | ||
for (let i = 0; i < attempts; i++) { | ||
const response = await this.processRequestHandler.get(workspaceStatusApiUrl); | ||
let expectedStatus = false; | ||
for (let i = 0; i < this.attempts; i++) { | ||
const response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspaceApiUrl(namespace, workspaceName)); | ||
if (response.status !== 200) { | ||
await this.driverHelper.wait(polling); | ||
continue; | ||
throw new Error(`Can not get status of a workspace. Code: ${response.status} Data: ${response.data}`); | ||
} | ||
workspaceStatus = await response.data.status; | ||
workspaceStatus = await response.data.status.phase; | ||
if (workspaceStatus === expectedWorkspaceStatus) { | ||
return; | ||
expectedStatus = true; | ||
break; | ||
} | ||
await this.driverHelper.wait(polling); | ||
await this.driverHelper.wait(this.polling); | ||
} | ||
throw new selenium_webdriver_1.error.TimeoutError(`Exceeded the maximum number of checking attempts, workspace status is: '${workspaceStatus}' different to '${expectedWorkspaceStatus}'`); | ||
if (!expectedStatus) { | ||
let waitTime = this.attempts * this.polling; | ||
throw new selenium_webdriver_1.error.TimeoutError(`The workspace was not stopped in ${waitTime} ms. Currnet status is: ${workspaceStatus}`); | ||
} | ||
} | ||
async stopWorkspaceByName(namespace, workspaceName) { | ||
Logger_1.Logger.debug('TestWorkspaceUtil.stopWorkspaceByName'); | ||
const stopWorkspaceApiUrl = this.apiUrlResolver.getWorkspaceApiUrl(namespace, workspaceName); | ||
let stopWorkspaceResponse; | ||
try { | ||
stopWorkspaceResponse = await this.processRequestHandler.patch(stopWorkspaceApiUrl, [{ 'op': 'replace', 'path': '/spec/started', 'value': false }]); | ||
} | ||
catch (err) { | ||
console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}`); | ||
throw err; | ||
} | ||
if (stopWorkspaceResponse.status !== 200) { | ||
throw new Error(`Cannot stop workspace. Code: ${stopWorkspaceResponse.status} Data: ${stopWorkspaceResponse.data}`); | ||
} | ||
await this.waitWorkspaceStatus(namespace, workspaceName, WorkspaceStatus_1.WorkspaceStatus.STOPPED); | ||
} | ||
// delete a worksapce without stopping phase (similar with force deleting) | ||
async deleteWorkspaceByName(namespace, workspaceName) { | ||
var _a, _b; | ||
Logger_1.Logger.debug(`TestWorkspaceUtil.deleteWorkspaceByName ${workspaceName}`); | ||
const deleteWorkspaceApiUrl = this.apiUrlResolver.getWorkspaceApiUrl(namespace, workspaceName); | ||
let deleteWorkspaceResponse; | ||
let deleteWorkspaceStatus = false; | ||
try { | ||
deleteWorkspaceResponse = await this.processRequestHandler.delete(deleteWorkspaceApiUrl); | ||
} | ||
catch (error) { | ||
if (axios_1.default.isAxiosError(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) { | ||
Logger_1.Logger.error(`The workspace :${workspaceName} not found`); | ||
throw error; | ||
} | ||
Logger_1.Logger.error(`Delete workspace call failed. URL used: ${deleteWorkspaceStatus}`); | ||
throw error; | ||
} | ||
if (deleteWorkspaceResponse.status !== 204) { | ||
throw new Error(`Can not delete workspace. Code: ${deleteWorkspaceResponse.status} Data: ${deleteWorkspaceResponse.data}`); | ||
} | ||
for (let i = 0; i < this.attempts; i++) { | ||
try { | ||
deleteWorkspaceResponse = await this.processRequestHandler.get(deleteWorkspaceApiUrl); | ||
} | ||
catch (error) { | ||
if (axios_1.default.isAxiosError(error) && ((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 404) { | ||
deleteWorkspaceStatus = true; | ||
break; | ||
} | ||
} | ||
} | ||
if (!deleteWorkspaceStatus) { | ||
let waitTime = this.attempts * this.polling; | ||
throw new selenium_webdriver_1.error.TimeoutError(`The workspace was not stopped in ${waitTime} ms.`); | ||
} | ||
} | ||
// stop workspace before deleting with checking stopping phase | ||
async stopAndDeleteWorkspaceByName(namespace, workspaceName) { | ||
Logger_1.Logger.debug('TestWorkspaceUtil.stopAndDeleteWorkspaceByName'); | ||
await this.stopWorkspaceByName(namespace, workspaceName); | ||
await this.deleteWorkspaceByName(namespace, workspaceName); | ||
} | ||
// stop all run workspaces in the namespace | ||
async stopAllRunningWorkspaces(namespace) { | ||
Logger_1.Logger.debug('TestWorkspaceUtil.stopAllRunProjects'); | ||
let response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspacesApiUrl(namespace)); | ||
for (let i = 0; i < response.data.items.length; i++) { | ||
Logger_1.Logger.info('The project is being stopped: ' + response.data.items[i].metadata.name); | ||
await this.stopWorkspaceByName(namespace, response.data.items[i].metadata.name); | ||
} | ||
} | ||
// stop all run workspaces, check statused and remove the workspaces | ||
async stopAndDeleteAllRunningWorkspaces(namespace) { | ||
Logger_1.Logger.debug('TestWorkspaceUtil.stopAndDeleteAllRunProjects'); | ||
let response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspacesApiUrl(namespace)); | ||
await this.stopAllRunningWorkspaces(namespace); | ||
for (let i = 0; i < response.data.items.length; i++) { | ||
Logger_1.Logger.info('The project is being deleted: ' + response.data.items[i].metadata.name); | ||
await this.deleteWorkspaceByName(namespace, response.data.items[i].metadata.name); | ||
} | ||
} | ||
// stop all run workspaces without stopping and waiting for of 'Stopped' phase | ||
// similar with 'force' deleting | ||
async deleteAllWorkspaces(namespace) { | ||
Logger_1.Logger.debug('TestWorkspaceUtil.deleteAllRunProjects'); | ||
let response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspacesApiUrl(namespace)); | ||
for (let i = 0; i < response.data.items.length; i++) { | ||
Logger_1.Logger.info('The project is being deleted .......: ' + response.data.items[i].metadata.name); | ||
await this.deleteWorkspaceByName(namespace, response.data.items[i].metadata.name); | ||
} | ||
} | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async waitPluginAdding(namespace, workspaceName, pluginName) { | ||
@@ -84,2 +185,5 @@ Logger_1.Logger.debug('TestWorkspaceUtil.waitPluginAdding'); | ||
} | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async getListOfWorkspaceId() { | ||
@@ -96,2 +200,5 @@ Logger_1.Logger.debug('TestWorkspaceUtil.getListOfWorkspaceId'); | ||
} | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async getIdOfRunningWorkspace(wsName) { | ||
@@ -102,2 +209,5 @@ Logger_1.Logger.debug('TestWorkspaceUtil.getIdOfRunningWorkspace'); | ||
} | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async getIdOfRunningWorkspaces() { | ||
@@ -122,2 +232,5 @@ Logger_1.Logger.debug('TestWorkspaceUtil.getIdOfRunningWorkspaces'); | ||
} | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async removeWorkspaceById(id) { | ||
@@ -128,3 +241,2 @@ Logger_1.Logger.debug('TestWorkspaceUtil.removeWorkspaceById'); | ||
const deleteWorkspaceResponse = await this.processRequestHandler.delete(workspaceIdUrl); | ||
// response code 204: "No Content" expected | ||
if (deleteWorkspaceResponse.status !== 204) { | ||
@@ -139,2 +251,5 @@ throw new Error(`Can not remove workspace. Code: ${deleteWorkspaceResponse.status} Data: ${deleteWorkspaceResponse.data}`); | ||
} | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async stopWorkspaceById(id) { | ||
@@ -145,15 +260,9 @@ Logger_1.Logger.debug('TestWorkspaceUtil.stopWorkspaceById'); | ||
try { | ||
stopWorkspaceResponse = await this.processRequestHandler.delete(`${stopWorkspaceApiUrl}/runtime`); | ||
stopWorkspaceResponse = await this.processRequestHandler.delete(`${stopWorkspaceApiUrl}`); | ||
} | ||
catch (err) { | ||
console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}/runtime`); | ||
console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}`); | ||
throw err; | ||
} | ||
// if workspace is already stopped, it will return 409: "Conflict" | ||
if (stopWorkspaceResponse.status === 409) { | ||
Logger_1.Logger.warn(`TestWorkspaceUtil.stopWorkspaceById Workspace {${id}} is already STOPPED`); | ||
return; | ||
} | ||
// response code 204: "No Content" expected | ||
if (stopWorkspaceResponse.status !== 204) { | ||
if (stopWorkspaceResponse.status !== 200) { | ||
throw new Error(`Can not stop workspace. Code: ${stopWorkspaceResponse.status} Data: ${stopWorkspaceResponse.data}`); | ||
@@ -165,3 +274,3 @@ } | ||
wsStatus = await this.processRequestHandler.get(stopWorkspaceApiUrl); | ||
if (wsStatus.data.status === 'STOPPED') { | ||
if (wsStatus.data.status === WorkspaceStatus_1.WorkspaceStatus.STOPPED) { | ||
stopped = true; | ||
@@ -177,2 +286,5 @@ break; | ||
} | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async cleanUpAllWorkspaces() { | ||
@@ -189,2 +301,5 @@ Logger_1.Logger.debug('TestWorkspaceUtil.cleanUpAllWorkspaces'); | ||
} | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async cleanUpRunningWorkspace(workspaceName) { | ||
@@ -206,2 +321,5 @@ if (workspaceName === undefined || workspaceName.length === 0) { | ||
} | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async createWsFromDevFile(customTemplate) { | ||
@@ -217,2 +335,5 @@ Logger_1.Logger.debug('TestWorkspaceUtil.createWsFromDevFile'); | ||
} | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async getBaseDevfile() { | ||
@@ -228,2 +349,5 @@ Logger_1.Logger.debug('TestWorkspaceUtil.getBaseDevfile'); | ||
} | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async startWorkspace(workspaceId) { | ||
@@ -240,3 +364,3 @@ Logger_1.Logger.debug('TestWorkspaceUtil.startWorkspace'); | ||
}; | ||
TestWorkspaceUtil.WORKSPACE_API_URL = 'api/workspace'; | ||
TestWorkspaceUtil.WORKSPACE_API_URL = 'dashboard/api/namespace'; | ||
TestWorkspaceUtil = TestWorkspaceUtil_1 = __decorate([ | ||
@@ -246,6 +370,8 @@ inversify_1.injectable(), | ||
__param(1, inversify_1.inject(inversify_types_1.CLASSES.CheApiRequestHandler)), | ||
__param(2, inversify_1.inject(inversify_types_1.CLASSES.ApiUrlResolver)), | ||
__metadata("design:paramtypes", [DriverHelper_1.DriverHelper, | ||
CheApiRequestHandler_1.CheApiRequestHandler]) | ||
CheApiRequestHandler_1.CheApiRequestHandler, | ||
ApiUrlResolver_1.ApiUrlResolver]) | ||
], TestWorkspaceUtil); | ||
exports.TestWorkspaceUtil = TestWorkspaceUtil; | ||
//# sourceMappingURL=TestWorkspaceUtil.js.map |
@@ -15,6 +15,6 @@ "use strict"; | ||
(function (WorkspaceStatus) { | ||
WorkspaceStatus["RUNNING"] = "RUNNING"; | ||
WorkspaceStatus["STOPPED"] = "STOPPED"; | ||
WorkspaceStatus["STARTING"] = "STARTING"; | ||
WorkspaceStatus["RUNNING"] = "Running"; | ||
WorkspaceStatus["STOPPED"] = "Stopped"; | ||
WorkspaceStatus["STARTING"] = "Starting"; | ||
})(WorkspaceStatus = exports.WorkspaceStatus || (exports.WorkspaceStatus = {})); | ||
//# sourceMappingURL=WorkspaceStatus.js.map |
@@ -20,3 +20,3 @@ /********************************************************************* | ||
import { ScreenCatcher } from '../utils/ScreenCatcher'; | ||
import { ITestWorkspaceUtil } from '../utils/workspace/ITestWorkspaceUtil'; | ||
import { TestWorkspaceUtil } from '../utils/workspace/TestWorkspaceUtil'; | ||
// import { PreferencesHandler } from '../utils/PreferencesHandler'; | ||
@@ -36,3 +36,3 @@ import { CheApiRequestHandler } from '../utils/requestHandlers/CheApiRequestHandler'; | ||
let deleteScreencast: boolean = true; | ||
let testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); | ||
let testWorkspaceUtil: TestWorkspaceUtil = e2eContainer.get(CLASSES.WorkspaceUtil); | ||
// let preferencesHandler: PreferencesHandler = e2eContainer.get(CLASSES.PreferencesHandler); | ||
@@ -39,0 +39,0 @@ |
@@ -23,3 +23,4 @@ import * as inversifyConfig from './inversify.config'; | ||
export * from './utils/VCS/github/GitHubUtil'; | ||
export * from './utils/workspace/ITestWorkspaceUtil'; | ||
export * from './utils/workspace/ApiUrlResolver'; | ||
export * from './utils/workspace/IApiUrlResolver'; | ||
export * from './utils/WorkspaceNameHandler'; | ||
@@ -26,0 +27,0 @@ export * from './utils/workspace/TestWorkspaceUtil'; |
@@ -15,3 +15,2 @@ /********************************************************************* | ||
import { TYPES, CLASSES } from './inversify.types'; | ||
import { ITestWorkspaceUtil } from './utils/workspace/ITestWorkspaceUtil'; | ||
import { TestWorkspaceUtil } from './utils/workspace/TestWorkspaceUtil'; | ||
@@ -74,9 +73,10 @@ import { IOcpLoginPage } from './pageobjects/login/IOcpLoginPage'; | ||
import { NavigationBar } from './pageobjects/ide/NavigationBar'; | ||
import { ApiUrlResolver } from './utils/workspace/ApiUrlResolver'; | ||
import { IApiUrlResolver } from './utils/workspace/IApiUrlResolver'; | ||
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); | ||
@@ -137,3 +137,4 @@ e2eContainer.bind<ITokenHandler>(TYPES.ITokenHandler).to(CheMultiuserTokenHandler); | ||
e2eContainer.bind<NavigationBar>(CLASSES.NavigationBar).to(NavigationBar); | ||
e2eContainer.bind<IApiUrlResolver>(CLASSES.ApiUrlResolver).to(ApiUrlResolver); | ||
e2eContainer.bind<TestWorkspaceUtil>(CLASSES.WorkspaceUtil).to(TestWorkspaceUtil); | ||
export { e2eContainer }; |
@@ -16,8 +16,9 @@ | ||
OcpLogin: Symbol.for('OcpLogin'), | ||
WorkspaceUtil: Symbol.for('WorkspaceUtil'), | ||
IAuthorizationHeaderHandler: Symbol.for('IAuthorizationHeaderHandler'), | ||
ITokenHandler: Symbol.for('ITokenHandler') | ||
ITokenHandler: Symbol.for('ITokenHandler'), | ||
IApiUrlResolver: Symbol.for('IApiUrlResolver') | ||
}; | ||
const CLASSES = { | ||
WorkspaceUtil: 'WorkspaceUtil', | ||
DriverHelper: 'DriverHelper', | ||
@@ -70,5 +71,6 @@ Dashboard: 'Dashboard', | ||
Sanitizer: 'Sanitizer', | ||
NavigationBar: 'NavigationBar' | ||
NavigationBar: 'NavigationBar', | ||
ApiUrlResolver: 'ApiUrlResolver' | ||
}; | ||
export { TYPES, CLASSES }; |
{ | ||
"name": "@eclipse-che/che-e2e", | ||
"version": "7.46.1-dev-deca6d7", | ||
"version": "7.46.1-dev-e59785f", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -13,3 +13,3 @@ /********************************************************************* | ||
import { CLASSES } from '../../inversify.types'; | ||
import { By } from 'selenium-webdriver'; | ||
import { By, error } from 'selenium-webdriver'; | ||
import { DriverHelper } from '../../utils/DriverHelper'; | ||
@@ -20,2 +20,3 @@ import { TestConstants } from '../../TestConstants'; | ||
import { Logger } from '../../utils/Logger'; | ||
import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil'; | ||
@@ -30,3 +31,5 @@ @injectable() | ||
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper, | ||
@inject(CLASSES.Workspaces) private readonly workspaces: Workspaces) { } | ||
@inject(CLASSES.Workspaces) private readonly workspaces: Workspaces, | ||
@inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil | ||
) { } | ||
@@ -64,7 +67,34 @@ async stopWorkspaceByUI(workspaceName: string) { | ||
async stopAndRemoveWorkspaceWithSelectingTab(workspaceName: string) { | ||
Logger.debug(`Dashboard.stopAndRemoveWorkspaceWithSelectingTab "${workspaceName}"`); | ||
await this.switchToDashboardTab(); | ||
await this.stopWorkspaceByUI(workspaceName); | ||
await this.workspaces.deleteWorkspaceByActionsButton(workspaceName); | ||
await this.workspaces.waitWorkspaceListItemAbcence(workspaceName); | ||
} | ||
async openDashboard() { | ||
Logger.debug('Dashboard.openDashboard'); | ||
// sometimes we can have opened files. In this case we get Alert dialog. We should perform it. | ||
await this.driverHelper.getDriver().navigate().to(TestConstants.TS_SELENIUM_BASE_URL); | ||
try { | ||
await this.waitPage(); | ||
} catch (err) { | ||
if (err instanceof error.UnexpectedAlertOpenError) { | ||
this.driverHelper.getDriver().switchTo().alert().accept(); | ||
} else { | ||
throw err; | ||
} | ||
} | ||
await this.waitPage(); | ||
} | ||
// click on the Browser tab which has been registered in the WorkspaceHandlingTests class | ||
async switchToDashboardTab() { | ||
Logger.debug('Dashboard.openDashboardTab'); | ||
await this.findAndClickDashboardTab(); | ||
await this.waitPage(); | ||
} | ||
@@ -121,2 +151,26 @@ | ||
async findAndClickDashboardTab(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT) { | ||
Logger.debug('Dashboard.findAndClickDashboardTab'); | ||
await this.driverHelper.waitUntilTrue(async () => { | ||
const windowHandles: string[] = await this.browserTabsUtil.getAllWindowHandles(); | ||
return windowHandles.length > 1; | ||
}, timeout); | ||
const windowHandles: string[] = await this.browserTabsUtil.getAllWindowHandles(); | ||
windowHandles.forEach(async windowHandle => { | ||
await this.browserTabsUtil.switchToWindow(windowHandle); | ||
try { | ||
this.driverHelper.waitVisibility(By.xpath(Dashboard.CREATE_WORKSPACE_BUTTON_XPATH)); | ||
Logger.info('Dashboard tab has been selected'); | ||
return; | ||
} catch { | ||
Logger.warn('The Dashboard Tab is not found in the window: ' + this.browserTabsUtil.getCurrentWindowHandle()); | ||
} | ||
}); | ||
Logger.warn('The Dashboard Tab is not opened'); | ||
} | ||
} |
@@ -12,3 +12,3 @@ /********************************************************************* | ||
import { injectable, inject } from 'inversify'; | ||
import { CLASSES, TYPES } from '../../../inversify.types'; | ||
import { CLASSES } from '../../../inversify.types'; | ||
import 'reflect-metadata'; | ||
@@ -18,3 +18,3 @@ import { TestConstants } from '../../../TestConstants'; | ||
import { Ide } from '../../ide/Ide'; | ||
import { ITestWorkspaceUtil } from '../../../utils/workspace/ITestWorkspaceUtil'; | ||
import { TestWorkspaceUtil } from '../../../utils/workspace/TestWorkspaceUtil'; | ||
import { WorkspaceStatus } from '../../../utils/workspace/WorkspaceStatus'; | ||
@@ -34,3 +34,3 @@ import { Logger } from '../../../utils/Logger'; | ||
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper, | ||
@inject(TYPES.WorkspaceUtil) private readonly testWorkspaceUtil: ITestWorkspaceUtil) { } | ||
@inject(CLASSES.WorkspaceUtil) private readonly testWorkspaceUtil: TestWorkspaceUtil) { } | ||
@@ -37,0 +37,0 @@ async waitLoaderDisappearance(attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS, polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING) { |
@@ -13,6 +13,6 @@ /********************************************************************* | ||
import 'reflect-metadata'; | ||
import { CLASSES, TYPES } from '../../../inversify.types'; | ||
import { CLASSES } from '../../../inversify.types'; | ||
import { By } from 'selenium-webdriver'; | ||
import { WorkspaceDetails } from './WorkspaceDetails'; | ||
import { ITestWorkspaceUtil } from '../../../utils/workspace/ITestWorkspaceUtil'; | ||
import { TestWorkspaceUtil } from '../../../utils/workspace/TestWorkspaceUtil'; | ||
import { WorkspaceStatus } from '../../../utils/workspace/WorkspaceStatus'; | ||
@@ -27,3 +27,3 @@ import { Logger } from '../../../utils/Logger'; | ||
@inject(CLASSES.WorkspaceDetails) private readonly workspaceDetails: WorkspaceDetails, | ||
@inject(TYPES.WorkspaceUtil) private readonly testWorkspaceUtil: ITestWorkspaceUtil) { } | ||
@inject(CLASSES.WorkspaceUtil) private readonly testWorkspaceUtil: TestWorkspaceUtil) { } | ||
@@ -30,0 +30,0 @@ async waitPluginListItem(pluginName: string) { |
@@ -12,3 +12,3 @@ // /********************************************************************* | ||
import { e2eContainer } from '../../inversify.config'; | ||
import { CLASSES, TYPES } from '../../inversify.types'; | ||
import { CLASSES } from '../../inversify.types'; | ||
import { TestConstants } from '../../TestConstants'; | ||
@@ -22,3 +22,3 @@ import { ProjectAndFileTests } from '../../testsLibrary/ProjectAndFileTests'; | ||
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil); | ||
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(TYPES.WorkspaceUtil); | ||
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(CLASSES.WorkspaceUtil); | ||
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get<WorkspaceHandlingTests>(CLASSES.WorkspaceHandlingTests); | ||
@@ -25,0 +25,0 @@ |
@@ -37,3 +37,3 @@ /********************************************************************* | ||
const gitPlugin: GitPlugin = e2eContainer.get(CLASSES.GitPlugin); | ||
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(TYPES.WorkspaceUtil); | ||
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(CLASSES.WorkspaceUtil); | ||
const workspaceNameHandler: WorkspaceNameHandler = e2eContainer.get(CLASSES.WorkspaceNameHandler); | ||
@@ -40,0 +40,0 @@ |
@@ -28,14 +28,14 @@ /********************************************************************* | ||
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); | ||
const ide: Ide = e2eContainer.get(CLASSES.Ide); | ||
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); | ||
const quickOpenContainer: QuickOpenContainer = e2eContainer.get(CLASSES.QuickOpenContainer); | ||
const topMenu: TopMenu = e2eContainer.get(CLASSES.TopMenu); | ||
const loginPage: ICheLoginPage = e2eContainer.get<ICheLoginPage>(TYPES.CheLogin); | ||
const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree); | ||
const gitPlugin: GitPlugin = e2eContainer.get(CLASSES.GitPlugin); | ||
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(TYPES.WorkspaceUtil); | ||
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); | ||
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil); | ||
const editor: Editor = e2eContainer.get(CLASSES.Editor); | ||
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); | ||
const ide: Ide = e2eContainer.get(CLASSES.Ide); | ||
const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper); | ||
const quickOpenContainer: QuickOpenContainer = e2eContainer.get(CLASSES.QuickOpenContainer); | ||
const topMenu: TopMenu = e2eContainer.get(CLASSES.TopMenu); | ||
const loginPage: ICheLoginPage = e2eContainer.get<ICheLoginPage>(TYPES.CheLogin); | ||
const projectTree: ProjectTree = e2eContainer.get(CLASSES.ProjectTree); | ||
const gitPlugin: GitPlugin = e2eContainer.get(CLASSES.GitPlugin); | ||
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(CLASSES.WorkspaceUtil); | ||
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); | ||
const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil); | ||
const editor: Editor = e2eContainer.get(CLASSES.Editor); | ||
@@ -42,0 +42,0 @@ const workspaceName = 'gitSelfSignCert'; |
@@ -42,3 +42,3 @@ /********************************************************************* | ||
const gitPlugin: GitPlugin = e2eContainer.get(CLASSES.GitPlugin); | ||
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(TYPES.WorkspaceUtil); | ||
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(CLASSES.WorkspaceUtil); | ||
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); | ||
@@ -45,0 +45,0 @@ const browserTabsUtil: BrowserTabsUtil = e2eContainer.get(CLASSES.BrowserTabsUtil); |
@@ -34,3 +34,3 @@ /********************************************************************* | ||
const loginPage: ICheLoginPage = e2eContainer.get<ICheLoginPage>(TYPES.CheLogin); | ||
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(TYPES.WorkspaceUtil); | ||
const testWorkspaceUtils: TestWorkspaceUtil = e2eContainer.get<TestWorkspaceUtil>(CLASSES.WorkspaceUtil); | ||
const openshiftPlugin: OpenshiftPlugin = e2eContainer.get(CLASSES.OpenshiftPlugin); | ||
@@ -37,0 +37,0 @@ const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); |
@@ -45,1 +45,3 @@ /********************************************************************* | ||
}); | ||
@@ -23,4 +23,4 @@ /********************************************************************* | ||
import { QuickOpenContainer } from '../pageobjects/ide/QuickOpenContainer'; | ||
import { BrowserTabsUtil } from '../utils/BrowserTabsUtil'; | ||
import { WorkspaceHandlingTests } from './WorkspaceHandlingTests'; | ||
import { BrowserTabsUtil } from '../utils/BrowserTabsUtil'; | ||
@@ -40,4 +40,6 @@ @injectable() | ||
@inject(CLASSES.BrowserTabsUtil) private readonly browserTabsUtil: BrowserTabsUtil, | ||
@inject(CLASSES.WorkspaceHandlingTests) private readonly workspaceHandlingTests: WorkspaceHandlingTests) {} | ||
@inject(CLASSES.WorkspaceHandlingTests) private readonly workspaceHandlingTests: WorkspaceHandlingTests | ||
) {} | ||
public runTask(taskName: string, timeout: number) { | ||
@@ -71,3 +73,2 @@ test(`Run command '${taskName}'`, async () => { | ||
await this.runTaskUsingQuickOpenContainer(taskName); | ||
this.workspaceHandlingTests.setWindowHandle(await this.browserTabsUtil.getCurrentWindowHandle()); | ||
await this.dialogWindow.waitDialogAndOpenLink(expectedDialogText, timeout); | ||
@@ -114,4 +115,8 @@ }); | ||
await this.ide.waitNotification(notificationText, timeout); | ||
this.workspaceHandlingTests.setWindowHandle(await this.browserTabsUtil.getCurrentWindowHandle()); | ||
// the application can have delay before running. Sometimes it consume about sec. | ||
// todo improve the check of avalibility test application | ||
await this.driverHelper.wait(10_000); | ||
await this.ide.clickOnNotificationButton(notificationText, buttonText); | ||
// delay for openning an app. window | ||
// todo may be improved. | ||
await this.driverHelper.wait(5_000); | ||
@@ -130,3 +135,8 @@ CodeExecutionTests.lastApplicationUrl = await this.driverHelper.getDriver().getCurrentUrl(); | ||
this.workspaceHandlingTests.setWindowHandle(await this.browserTabsUtil.getCurrentWindowHandle()); | ||
// the application can have delay before running. Sometimes it consume about sec. | ||
// todo improve the check of avalibility test application | ||
await this.driverHelper.wait(10_000); | ||
await this.ide.clickOnNotificationButton(notificationText, 'Open In Preview'); | ||
// delay for openning an app. window | ||
// todo may be improved. | ||
await this.driverHelper.wait(5_000); | ||
@@ -141,3 +151,2 @@ CodeExecutionTests.lastApplicationUrl = await this.driverHelper.getDriver().getCurrentUrl(); | ||
await this.ide.waitNotificationAndConfirm(notificationText, timeout); | ||
this.workspaceHandlingTests.setWindowHandle(await this.browserTabsUtil.getCurrentWindowHandle()); | ||
await this.ide.waitNotificationAndOpenLink(portOpenText, timeout); | ||
@@ -144,0 +153,0 @@ await this.driverHelper.wait(5_000); |
@@ -102,2 +102,6 @@ /********************************************************************* | ||
async patch(relativeUrl: string, patchParams: object): Promise<AxiosResponse> { | ||
return await axios.patch(this.assembleUrl(relativeUrl), patchParams, await this.headerHandler.get()); | ||
} | ||
private assembleUrl(relativeUrl: string): string { | ||
@@ -104,0 +108,0 @@ return `${TestConstants.TS_SELENIUM_BASE_URL}/${relativeUrl}`; |
@@ -15,5 +15,5 @@ /********************************************************************* | ||
import { DriverHelper } from '../DriverHelper'; | ||
import { ApiUrlResolver } from './ApiUrlResolver'; | ||
import 'reflect-metadata'; | ||
import { WorkspaceStatus } from './WorkspaceStatus'; | ||
import { ITestWorkspaceUtil } from './ITestWorkspaceUtil'; | ||
import { error } from 'selenium-webdriver'; | ||
@@ -23,11 +23,14 @@ import { CheApiRequestHandler } from '../requestHandlers/CheApiRequestHandler'; | ||
import { Logger } from '../Logger'; | ||
import axios from 'axios'; | ||
@injectable() | ||
export class TestWorkspaceUtil implements ITestWorkspaceUtil { | ||
export class TestWorkspaceUtil { | ||
static readonly WORKSPACE_API_URL: string = 'api/workspace'; | ||
static readonly WORKSPACE_API_URL: string = 'dashboard/api/namespace'; | ||
readonly attempts: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS; | ||
readonly polling: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_POLLING; | ||
constructor( | ||
@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper, | ||
@inject(CLASSES.CheApiRequestHandler) private readonly processRequestHandler: CheApiRequestHandler | ||
@inject(CLASSES.CheApiRequestHandler) private readonly processRequestHandler: CheApiRequestHandler, | ||
@inject(CLASSES.ApiUrlResolver) private readonly apiUrlResolver: ApiUrlResolver | ||
) { } | ||
@@ -38,27 +41,130 @@ | ||
const workspaceStatusApiUrl: string = `${TestWorkspaceUtil.WORKSPACE_API_URL}/${namespace}:${workspaceName}`; | ||
const attempts: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS; | ||
const polling: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_POLLING; | ||
let workspaceStatus: string = ''; | ||
let expectedStatus: boolean = false; | ||
for (let i = 0; i < this.attempts; i++) { | ||
const response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspaceApiUrl(namespace, workspaceName)); | ||
for (let i = 0; i < attempts; i++) { | ||
const response = await this.processRequestHandler.get(workspaceStatusApiUrl); | ||
if (response.status !== 200) { | ||
await this.driverHelper.wait(polling); | ||
continue; | ||
throw new Error(`Can not get status of a workspace. Code: ${response.status} Data: ${response.data}`); | ||
} | ||
workspaceStatus = await response.data.status; | ||
workspaceStatus = await response.data.status.phase; | ||
if (workspaceStatus === expectedWorkspaceStatus) { | ||
return; | ||
expectedStatus = true; | ||
break; | ||
} | ||
await this.driverHelper.wait(polling); | ||
await this.driverHelper.wait(this.polling); | ||
} | ||
throw new error.TimeoutError(`Exceeded the maximum number of checking attempts, workspace status is: '${workspaceStatus}' different to '${expectedWorkspaceStatus}'`); | ||
if (!expectedStatus) { | ||
let waitTime = this.attempts * this.polling; | ||
throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms. Currnet status is: ${workspaceStatus}`); | ||
} | ||
} | ||
public async stopWorkspaceByName(namespace: string, workspaceName: string) { | ||
Logger.debug('TestWorkspaceUtil.stopWorkspaceByName'); | ||
const stopWorkspaceApiUrl: string = this.apiUrlResolver.getWorkspaceApiUrl(namespace, workspaceName); | ||
let stopWorkspaceResponse; | ||
try { | ||
stopWorkspaceResponse = await this.processRequestHandler.patch(stopWorkspaceApiUrl, [{'op': 'replace', 'path': '/spec/started', 'value': false}]); | ||
} catch (err) { | ||
console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}`); | ||
throw err; | ||
} | ||
if (stopWorkspaceResponse.status !== 200) { | ||
throw new Error(`Cannot stop workspace. Code: ${stopWorkspaceResponse.status} Data: ${stopWorkspaceResponse.data}`); | ||
} | ||
await this.waitWorkspaceStatus(namespace, workspaceName, WorkspaceStatus.STOPPED); | ||
} | ||
// delete a worksapce without stopping phase (similar with force deleting) | ||
public async deleteWorkspaceByName(namespace: string, workspaceName: string) { | ||
Logger.debug(`TestWorkspaceUtil.deleteWorkspaceByName ${workspaceName}` ); | ||
const deleteWorkspaceApiUrl: string = this.apiUrlResolver.getWorkspaceApiUrl(namespace, workspaceName); | ||
let deleteWorkspaceResponse; | ||
let deleteWorkspaceStatus: boolean = false; | ||
try { | ||
deleteWorkspaceResponse = await this.processRequestHandler.delete(deleteWorkspaceApiUrl); | ||
} catch (error) { | ||
if (axios.isAxiosError(error) && error.response?.status === 404) { | ||
Logger.error(`The workspace :${workspaceName} not found`); | ||
throw error; | ||
} | ||
Logger.error(`Delete workspace call failed. URL used: ${deleteWorkspaceStatus}`); | ||
throw error; | ||
} | ||
if (deleteWorkspaceResponse.status !== 204) { | ||
throw new Error(`Can not delete workspace. Code: ${deleteWorkspaceResponse.status} Data: ${deleteWorkspaceResponse.data}`); | ||
} | ||
for (let i = 0; i < this.attempts; i++) { | ||
try { | ||
deleteWorkspaceResponse = await this.processRequestHandler.get(deleteWorkspaceApiUrl); | ||
} catch (error) { | ||
if (axios.isAxiosError(error) && error.response?.status === 404) { | ||
deleteWorkspaceStatus = true; | ||
break; | ||
} | ||
} | ||
} | ||
if (!deleteWorkspaceStatus) { | ||
let waitTime = this.attempts * this.polling; | ||
throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms.`); | ||
} | ||
} | ||
// stop workspace before deleting with checking stopping phase | ||
public async stopAndDeleteWorkspaceByName(namespace: string, workspaceName: string) { | ||
Logger.debug('TestWorkspaceUtil.stopAndDeleteWorkspaceByName'); | ||
await this.stopWorkspaceByName(namespace, workspaceName); | ||
await this.deleteWorkspaceByName(namespace, workspaceName); | ||
} | ||
// stop all run workspaces in the namespace | ||
public async stopAllRunningWorkspaces(namespace: string) { | ||
Logger.debug('TestWorkspaceUtil.stopAllRunProjects'); | ||
let response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspacesApiUrl(namespace)); | ||
for (let i = 0; i < response.data.items.length; i++) { | ||
Logger.info('The project is being stopped: ' + response.data.items[i].metadata.name); | ||
await this.stopWorkspaceByName(namespace, response.data.items[i].metadata.name); | ||
} | ||
} | ||
// stop all run workspaces, check statused and remove the workspaces | ||
public async stopAndDeleteAllRunningWorkspaces(namespace: string) { | ||
Logger.debug('TestWorkspaceUtil.stopAndDeleteAllRunProjects'); | ||
let response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspacesApiUrl(namespace)); | ||
await this.stopAllRunningWorkspaces(namespace); | ||
for (let i = 0; i < response.data.items.length; i++) { | ||
Logger.info('The project is being deleted: ' + response.data.items[i].metadata.name); | ||
await this.deleteWorkspaceByName(namespace, response.data.items[i].metadata.name); | ||
} | ||
} | ||
// stop all run workspaces without stopping and waiting for of 'Stopped' phase | ||
// similar with 'force' deleting | ||
public async deleteAllWorkspaces(namespace: string) { | ||
Logger.debug('TestWorkspaceUtil.deleteAllRunProjects'); | ||
let response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspacesApiUrl(namespace)); | ||
for (let i = 0; i < response.data.items.length; i++) { | ||
Logger.info('The project is being deleted .......: ' + response.data.items[i].metadata.name); | ||
await this.deleteWorkspaceByName(namespace, response.data.items[i].metadata.name); | ||
} | ||
} | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
public async waitPluginAdding(namespace: string, workspaceName: string, pluginName: string) { | ||
@@ -94,2 +200,5 @@ Logger.debug('TestWorkspaceUtil.waitPluginAdding'); | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
public async getListOfWorkspaceId(): Promise<string[]> { | ||
@@ -116,2 +225,5 @@ Logger.debug('TestWorkspaceUtil.getListOfWorkspaceId'); | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
public async getIdOfRunningWorkspace(wsName: string): Promise<string> { | ||
@@ -125,2 +237,5 @@ Logger.debug('TestWorkspaceUtil.getIdOfRunningWorkspace'); | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
public async getIdOfRunningWorkspaces(): Promise<Array<string>> { | ||
@@ -153,2 +268,5 @@ Logger.debug('TestWorkspaceUtil.getIdOfRunningWorkspaces'); | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
public async removeWorkspaceById(id: string) { | ||
@@ -160,3 +278,2 @@ Logger.debug('TestWorkspaceUtil.removeWorkspaceById'); | ||
const deleteWorkspaceResponse = await this.processRequestHandler.delete(workspaceIdUrl); | ||
// response code 204: "No Content" expected | ||
if (deleteWorkspaceResponse.status !== 204) { | ||
@@ -171,2 +288,5 @@ throw new Error(`Can not remove workspace. Code: ${deleteWorkspaceResponse.status} Data: ${deleteWorkspaceResponse.data}`); | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
public async stopWorkspaceById(id: string) { | ||
@@ -179,16 +299,9 @@ Logger.debug('TestWorkspaceUtil.stopWorkspaceById'); | ||
try { | ||
stopWorkspaceResponse = await this.processRequestHandler.delete(`${stopWorkspaceApiUrl}/runtime`); | ||
stopWorkspaceResponse = await this.processRequestHandler.delete(`${stopWorkspaceApiUrl}`); | ||
} catch (err) { | ||
console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}/runtime`); | ||
console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}`); | ||
throw err; | ||
} | ||
// if workspace is already stopped, it will return 409: "Conflict" | ||
if (stopWorkspaceResponse.status === 409) { | ||
Logger.warn(`TestWorkspaceUtil.stopWorkspaceById Workspace {${id}} is already STOPPED`); | ||
return; | ||
} | ||
// response code 204: "No Content" expected | ||
if (stopWorkspaceResponse.status !== 204) { | ||
if (stopWorkspaceResponse.status !== 200) { | ||
throw new Error(`Can not stop workspace. Code: ${stopWorkspaceResponse.status} Data: ${stopWorkspaceResponse.data}`); | ||
@@ -201,3 +314,3 @@ } | ||
wsStatus = await this.processRequestHandler.get(stopWorkspaceApiUrl); | ||
if (wsStatus.data.status === 'STOPPED') { | ||
if (wsStatus.data.status === WorkspaceStatus.STOPPED) { | ||
stopped = true; | ||
@@ -215,2 +328,5 @@ break; | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
public async cleanUpAllWorkspaces() { | ||
@@ -232,2 +348,5 @@ Logger.debug('TestWorkspaceUtil.cleanUpAllWorkspaces'); | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
public async cleanUpRunningWorkspace(workspaceName: string) { | ||
@@ -253,2 +372,5 @@ if (workspaceName === undefined || workspaceName.length === 0) { | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async createWsFromDevFile(customTemplate: che.workspace.devfile.Devfile) { | ||
@@ -265,2 +387,5 @@ Logger.debug('TestWorkspaceUtil.createWsFromDevFile'); | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async getBaseDevfile(): Promise<che.workspace.devfile.Devfile> { | ||
@@ -279,2 +404,5 @@ Logger.debug('TestWorkspaceUtil.getBaseDevfile'); | ||
/** | ||
* @deprecated Method deprecated. Works with CHE server only | ||
*/ | ||
async startWorkspace(workspaceId: string) { | ||
@@ -281,0 +409,0 @@ Logger.debug('TestWorkspaceUtil.startWorkspace'); |
@@ -12,5 +12,5 @@ /********************************************************************* | ||
export enum WorkspaceStatus { | ||
RUNNING = 'RUNNING', | ||
STOPPED = 'STOPPED', | ||
STARTING = 'STARTING' | ||
RUNNING = 'Running', | ||
STOPPED = 'Stopped', | ||
STARTING = 'Starting' | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 7 instances in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 7 instances in 1 package
1543522
362
20870