@eclipse-che/che-e2e 7.48.2-dev-b683f50 → 7.50.0-dev-25a3c8c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/TestConstants.js +216 -0
  2. package/dist/TestConstants.js.map +1 -0
  3. package/dist/TimeoutConstants.js +184 -0
  4. package/dist/TimeoutConstants.js.map +1 -0
  5. package/dist/driver/CheReporter.js +180 -0
  6. package/dist/driver/CheReporter.js.map +1 -0
  7. package/dist/driver/ChromeDriver.js +75 -0
  8. package/dist/driver/ChromeDriver.js.map +1 -0
  9. package/dist/driver/IDriver.js +3 -0
  10. package/dist/driver/IDriver.js.map +1 -0
  11. package/dist/index.js +93 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/inversify.config.js +130 -0
  14. package/dist/inversify.config.js.map +1 -0
  15. package/dist/inversify.types.js +75 -0
  16. package/dist/inversify.types.js.map +1 -0
  17. package/dist/pageobjects/dashboard/CreateWorkspace.js +65 -0
  18. package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -0
  19. package/dist/pageobjects/dashboard/Dashboard.js +115 -0
  20. package/dist/pageobjects/dashboard/Dashboard.js.map +1 -0
  21. package/dist/pageobjects/dashboard/Workspaces.js +157 -0
  22. package/dist/pageobjects/dashboard/Workspaces.js.map +1 -0
  23. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +140 -0
  24. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -0
  25. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js +99 -0
  26. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.js.map +1 -0
  27. package/dist/pageobjects/ide/ContextMenu.js +66 -0
  28. package/dist/pageobjects/ide/ContextMenu.js.map +1 -0
  29. package/dist/pageobjects/ide/DebugView.js +98 -0
  30. package/dist/pageobjects/ide/DebugView.js.map +1 -0
  31. package/dist/pageobjects/ide/DialogWindow.js +102 -0
  32. package/dist/pageobjects/ide/DialogWindow.js.map +1 -0
  33. package/dist/pageobjects/ide/Editor.js +464 -0
  34. package/dist/pageobjects/ide/Editor.js.map +1 -0
  35. package/dist/pageobjects/ide/Ide.js +336 -0
  36. package/dist/pageobjects/ide/Ide.js.map +1 -0
  37. package/dist/pageobjects/ide/LeftToolBar.js +81 -0
  38. package/dist/pageobjects/ide/LeftToolBar.js.map +1 -0
  39. package/dist/pageobjects/ide/NavigationBar.js +57 -0
  40. package/dist/pageobjects/ide/NavigationBar.js.map +1 -0
  41. package/dist/pageobjects/ide/NotificationCenter.js +76 -0
  42. package/dist/pageobjects/ide/NotificationCenter.js.map +1 -0
  43. package/dist/pageobjects/ide/OpenDialogWidget.js +100 -0
  44. package/dist/pageobjects/ide/OpenDialogWidget.js.map +1 -0
  45. package/dist/pageobjects/ide/OpenEditors.js +73 -0
  46. package/dist/pageobjects/ide/OpenEditors.js.map +1 -0
  47. package/dist/pageobjects/ide/OpenWorkspaceWidget.js +62 -0
  48. package/dist/pageobjects/ide/OpenWorkspaceWidget.js.map +1 -0
  49. package/dist/pageobjects/ide/PreviewWidget.js +134 -0
  50. package/dist/pageobjects/ide/PreviewWidget.js.map +1 -0
  51. package/dist/pageobjects/ide/ProjectTree.js +276 -0
  52. package/dist/pageobjects/ide/ProjectTree.js.map +1 -0
  53. package/dist/pageobjects/ide/QuickOpenContainer.js +70 -0
  54. package/dist/pageobjects/ide/QuickOpenContainer.js.map +1 -0
  55. package/dist/pageobjects/ide/RightToolBar.js +51 -0
  56. package/dist/pageobjects/ide/RightToolBar.js.map +1 -0
  57. package/dist/pageobjects/ide/Terminal.js +184 -0
  58. package/dist/pageobjects/ide/Terminal.js.map +1 -0
  59. package/dist/pageobjects/ide/TopMenu.js +109 -0
  60. package/dist/pageobjects/ide/TopMenu.js.map +1 -0
  61. package/dist/pageobjects/ide/plugins/GitHubPullRequestPlugin.js +128 -0
  62. package/dist/pageobjects/ide/plugins/GitHubPullRequestPlugin.js.map +1 -0
  63. package/dist/pageobjects/ide/plugins/GitPlugin.js +120 -0
  64. package/dist/pageobjects/ide/plugins/GitPlugin.js.map +1 -0
  65. package/dist/pageobjects/ide/plugins/KubernetesPlugin.js +107 -0
  66. package/dist/pageobjects/ide/plugins/KubernetesPlugin.js.map +1 -0
  67. package/dist/pageobjects/ide/plugins/OpenshiftPlugin.js +99 -0
  68. package/dist/pageobjects/ide/plugins/OpenshiftPlugin.js.map +1 -0
  69. package/dist/pageobjects/ide/plugins/PluginsView.js +166 -0
  70. package/dist/pageobjects/ide/plugins/PluginsView.js.map +1 -0
  71. package/dist/pageobjects/login/ICheLoginPage.js +12 -0
  72. package/dist/pageobjects/login/ICheLoginPage.js.map +1 -0
  73. package/dist/pageobjects/login/IOcpLoginPage.js +12 -0
  74. package/dist/pageobjects/login/IOcpLoginPage.js.map +1 -0
  75. package/dist/pageobjects/login/MultiUserLoginPage.js +49 -0
  76. package/dist/pageobjects/login/MultiUserLoginPage.js.map +1 -0
  77. package/dist/pageobjects/login/OcpUserLoginPage.js +53 -0
  78. package/dist/pageobjects/login/OcpUserLoginPage.js.map +1 -0
  79. package/dist/pageobjects/login/RegularUserOcpCheLoginPage.js +86 -0
  80. package/dist/pageobjects/login/RegularUserOcpCheLoginPage.js.map +1 -0
  81. package/dist/pageobjects/login/UpdateAccountInformationPage.js +74 -0
  82. package/dist/pageobjects/login/UpdateAccountInformationPage.js.map +1 -0
  83. package/dist/pageobjects/openshift/CheLoginPage.js +88 -0
  84. package/dist/pageobjects/openshift/CheLoginPage.js.map +1 -0
  85. package/dist/pageobjects/openshift/OcpLoginPage.js +106 -0
  86. package/dist/pageobjects/openshift/OcpLoginPage.js.map +1 -0
  87. package/dist/pageobjects/third-parties/GitLoginPage.js +85 -0
  88. package/dist/pageobjects/third-parties/GitLoginPage.js.map +1 -0
  89. package/dist/pageobjects/third-parties/GitOauthAppsSettings.js +110 -0
  90. package/dist/pageobjects/third-parties/GitOauthAppsSettings.js.map +1 -0
  91. package/dist/tests/devfiles/CSlashCPlusPlus.spec.js +74 -0
  92. package/dist/tests/devfiles/CSlashCPlusPlus.spec.js.map +1 -0
  93. package/dist/tests/devfiles/DevfileSmoke.spec.js +48 -0
  94. package/dist/tests/devfiles/DevfileSmoke.spec.js.map +1 -0
  95. package/dist/tests/devfiles/DotNetCore.spec.js +82 -0
  96. package/dist/tests/devfiles/DotNetCore.spec.js.map +1 -0
  97. package/dist/tests/devfiles/Go.spec.js +73 -0
  98. package/dist/tests/devfiles/Go.spec.js.map +1 -0
  99. package/dist/tests/devfiles/JavaMaven.spec.js +61 -0
  100. package/dist/tests/devfiles/JavaMaven.spec.js.map +1 -0
  101. package/dist/tests/devfiles/JavaSpringBoot.spec.js +67 -0
  102. package/dist/tests/devfiles/JavaSpringBoot.spec.js.map +1 -0
  103. package/dist/tests/devfiles/JavaVertx.spec.js +61 -0
  104. package/dist/tests/devfiles/JavaVertx.spec.js.map +1 -0
  105. package/dist/tests/devfiles/NodeJS.spec.js +65 -0
  106. package/dist/tests/devfiles/NodeJS.spec.js.map +1 -0
  107. package/dist/tests/devfiles/PHPSimple.spec.js +75 -0
  108. package/dist/tests/devfiles/PHPSimple.spec.js.map +1 -0
  109. package/dist/tests/devfiles/Python.spec.js +59 -0
  110. package/dist/tests/devfiles/Python.spec.js.map +1 -0
  111. package/dist/tests/devfiles/PythonDjango.spec.js +62 -0
  112. package/dist/tests/devfiles/PythonDjango.spec.js.map +1 -0
  113. package/dist/tests/devfiles/Quarkus.spec.js +70 -0
  114. package/dist/tests/devfiles/Quarkus.spec.js.map +1 -0
  115. package/dist/tests/devfiles/Scala.spec.js +67 -0
  116. package/dist/tests/devfiles/Scala.spec.js.map +1 -0
  117. package/dist/tests/e2e/FactoryUrl.spec.js +45 -0
  118. package/dist/tests/e2e/FactoryUrl.spec.js.map +1 -0
  119. package/dist/tests/e2e/GitPublishBranch.spec.js +88 -0
  120. package/dist/tests/e2e/GitPublishBranch.spec.js.map +1 -0
  121. package/dist/tests/e2e/GitSelfSignCert.spec.js +83 -0
  122. package/dist/tests/e2e/GitSelfSignCert.spec.js.map +1 -0
  123. package/dist/tests/e2e/GitSsh.spec.js +117 -0
  124. package/dist/tests/e2e/GitSsh.spec.js.map +1 -0
  125. package/dist/tests/e2e/OpenshiftConnector.spec.js +122 -0
  126. package/dist/tests/e2e/OpenshiftConnector.spec.js.map +1 -0
  127. package/dist/tests/e2e/factories/DirectUrlFactoryWithKeepDirectoryTest.spec.js +54 -0
  128. package/dist/tests/e2e/factories/DirectUrlFactoryWithKeepDirectoryTest.spec.js.map +1 -0
  129. package/dist/tests/e2e/factories/DirectUrlFactoryWithRootFolderTest.spec.js +52 -0
  130. package/dist/tests/e2e/factories/DirectUrlFactoryWithRootFolderTest.spec.js.map +1 -0
  131. package/dist/tests/e2e/factories/DirectUrlFactoryWithSpecificBranchTest.spec.js +52 -0
  132. package/dist/tests/e2e/factories/DirectUrlFactoryWithSpecificBranchTest.spec.js.map +1 -0
  133. package/dist/tests/e2e_happy_path/DevWorkspaceHappyPath.spec.js +276 -0
  134. package/dist/tests/e2e_happy_path/DevWorkspaceHappyPath.spec.js.map +1 -0
  135. package/dist/tests/e2e_happy_path/HappyPath.spec.js +309 -0
  136. package/dist/tests/e2e_happy_path/HappyPath.spec.js.map +1 -0
  137. package/dist/tests/intelij/IntelijOpenWorkspace.spec.js +43 -0
  138. package/dist/tests/intelij/IntelijOpenWorkspace.spec.js.map +1 -0
  139. package/dist/tests/load_test/LoadTest.spec.js +44 -0
  140. package/dist/tests/load_test/LoadTest.spec.js.map +1 -0
  141. package/dist/tests/login/LinkCheAndOcpUsers.spec.js +39 -0
  142. package/dist/tests/login/LinkCheAndOcpUsers.spec.js.map +1 -0
  143. package/dist/tests/login/Login.spec.js +28 -0
  144. package/dist/tests/login/Login.spec.js.map +1 -0
  145. package/dist/tests/plugins/GitHubPullRequestPlugin.spec.js +123 -0
  146. package/dist/tests/plugins/GitHubPullRequestPlugin.spec.js.map +1 -0
  147. package/dist/tests/plugins/InstallPluginUsingUI.spec.js +69 -0
  148. package/dist/tests/plugins/InstallPluginUsingUI.spec.js.map +1 -0
  149. package/dist/tests/plugins/JavaPlugin.spec.js +86 -0
  150. package/dist/tests/plugins/JavaPlugin.spec.js.map +1 -0
  151. package/dist/tests/plugins/PhpPlugin.spec.js +94 -0
  152. package/dist/tests/plugins/PhpPlugin.spec.js.map +1 -0
  153. package/dist/tests/plugins/PythonPlugin.spec.js +76 -0
  154. package/dist/tests/plugins/PythonPlugin.spec.js.map +1 -0
  155. package/dist/tests/plugins/TypescriptPlugin.spec.js +139 -0
  156. package/dist/tests/plugins/TypescriptPlugin.spec.js.map +1 -0
  157. package/dist/tests/plugins/VscodeKubernetesPlugin.spec.js +76 -0
  158. package/dist/tests/plugins/VscodeKubernetesPlugin.spec.js.map +1 -0
  159. package/dist/tests/plugins/VscodeShellcheckPlugin.spec.js +89 -0
  160. package/dist/tests/plugins/VscodeShellcheckPlugin.spec.js.map +1 -0
  161. package/dist/tests/plugins/VscodeValePlugin.spec.js +77 -0
  162. package/dist/tests/plugins/VscodeValePlugin.spec.js.map +1 -0
  163. package/dist/tests/plugins/VscodeXmlPlugin.spec.js +90 -0
  164. package/dist/tests/plugins/VscodeXmlPlugin.spec.js.map +1 -0
  165. package/dist/tests/plugins/VscodeYamlPlugin.spec.js +87 -0
  166. package/dist/tests/plugins/VscodeYamlPlugin.spec.js.map +1 -0
  167. package/dist/testsLibrary/CodeExecutionTests.js +232 -0
  168. package/dist/testsLibrary/CodeExecutionTests.js.map +1 -0
  169. package/dist/testsLibrary/LanguageServerTests.js +230 -0
  170. package/dist/testsLibrary/LanguageServerTests.js.map +1 -0
  171. package/dist/testsLibrary/ProjectAndFileTests.js +105 -0
  172. package/dist/testsLibrary/ProjectAndFileTests.js.map +1 -0
  173. package/dist/testsLibrary/WorkspaceHandlingTests.js +91 -0
  174. package/dist/testsLibrary/WorkspaceHandlingTests.js.map +1 -0
  175. package/dist/utils/AnimationChecker.js +45 -0
  176. package/dist/utils/AnimationChecker.js.map +1 -0
  177. package/dist/utils/BrowserTabsUtil.js +115 -0
  178. package/dist/utils/BrowserTabsUtil.js.map +1 -0
  179. package/dist/utils/DriverHelper.js +616 -0
  180. package/dist/utils/DriverHelper.js.map +1 -0
  181. package/dist/utils/Logger.js +84 -0
  182. package/dist/utils/Logger.js.map +1 -0
  183. package/dist/utils/PreferencesHandler.js +142 -0
  184. package/dist/utils/PreferencesHandler.js.map +1 -0
  185. package/dist/utils/Sanitizer.js +29 -0
  186. package/dist/utils/Sanitizer.js.map +1 -0
  187. package/dist/utils/ScreenCatcher.js +107 -0
  188. package/dist/utils/ScreenCatcher.js.map +1 -0
  189. package/dist/utils/VCS/CheGitApi.js +42 -0
  190. package/dist/utils/VCS/CheGitApi.js.map +1 -0
  191. package/dist/utils/VCS/github/GitHubUtil.js +126 -0
  192. package/dist/utils/VCS/github/GitHubUtil.js.map +1 -0
  193. package/dist/utils/WorkspaceNameHandler.js +60 -0
  194. package/dist/utils/WorkspaceNameHandler.js.map +1 -0
  195. package/dist/utils/requestHandlers/CheApiRequestHandler.js +126 -0
  196. package/dist/utils/requestHandlers/CheApiRequestHandler.js.map +1 -0
  197. package/dist/utils/requestHandlers/headers/CheMultiuserAuthorizationHeaderHandler.js +34 -0
  198. package/dist/utils/requestHandlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -0
  199. package/dist/utils/requestHandlers/headers/IAuthorizationHeaderHandler.js +12 -0
  200. package/dist/utils/requestHandlers/headers/IAuthorizationHeaderHandler.js.map +1 -0
  201. package/dist/utils/requestHandlers/tokens/CheMultiuserTokenHandler.js +50 -0
  202. package/dist/utils/requestHandlers/tokens/CheMultiuserTokenHandler.js.map +1 -0
  203. package/dist/utils/requestHandlers/tokens/ITokenHandler.js +12 -0
  204. package/dist/utils/requestHandlers/tokens/ITokenHandler.js.map +1 -0
  205. package/dist/utils/workspace/ApiUrlResolver.js +35 -0
  206. package/dist/utils/workspace/ApiUrlResolver.js.map +1 -0
  207. package/dist/utils/workspace/IApiUrlResolver.js +12 -0
  208. package/dist/utils/workspace/IApiUrlResolver.js.map +1 -0
  209. package/dist/utils/workspace/TestWorkspaceUtil.js +359 -0
  210. package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -0
  211. package/dist/utils/workspace/WorkspaceStatus.js +19 -0
  212. package/dist/utils/workspace/WorkspaceStatus.js.map +1 -0
  213. package/driver/CheReporter.ts +2 -2
  214. package/index.ts +2 -1
  215. package/inversify.config.ts +5 -4
  216. package/inversify.types.ts +5 -3
  217. package/package.json +2 -2
  218. package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +3 -3
  219. package/pageobjects/dashboard/workspace-details/WorkspaceDetailsPlugins.ts +3 -3
  220. package/tests/e2e/FactoryUrl.spec.ts +2 -2
  221. package/tests/e2e/GitPublishBranch.spec.ts +1 -1
  222. package/tests/e2e/GitSelfSignCert.spec.ts +1 -1
  223. package/tests/e2e/GitSsh.spec.ts +1 -1
  224. package/tests/e2e/OpenshiftConnector.spec.ts +1 -1
  225. package/tests/load_test/LoadTest.spec.ts +1 -1
  226. package/utils/requestHandlers/CheApiRequestHandler.ts +6 -0
  227. package/utils/requestHandlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +6 -3
  228. package/utils/workspace/ApiUrlResolver.ts +27 -0
  229. package/utils/workspace/IApiUrlResolver.ts +15 -0
  230. package/utils/workspace/TestWorkspaceUtil.ts +157 -29
  231. package/utils/workspace/WorkspaceStatus.ts +3 -3
  232. package/utils/workspace/ITestWorkspaceUtil.ts +0 -26
@@ -35,6 +35,7 @@ export class CheApiRequestHandler {
35
35
  return request;
36
36
  }
37
37
  request_censored.headers.Authorization = 'CENSORED';
38
+ request_censored.headers.Cookie = 'CENSORED';
38
39
  Logger.info(`RequestHandler request:\n` + request_censored);
39
40
  } catch (err) {
40
41
  Logger.error(`RequestHandler request: Failed to deep clone AxiosRequestConfig:` + err);
@@ -69,6 +70,7 @@ export class CheApiRequestHandler {
69
70
  return response;
70
71
  }
71
72
  response_censored.config.headers.Authorization = 'CENSORED';
73
+ response_censored.config.headers.Cookie = 'CENSORED';
72
74
  if (response_censored.data.access_token != null) {
73
75
  response_censored.data.access_token = 'CENSORED';
74
76
  }
@@ -97,6 +99,10 @@ export class CheApiRequestHandler {
97
99
  return await axios.delete(this.assembleUrl(relativeUrl), await this.headerHandler.get());
98
100
  }
99
101
 
102
+ async patch(relativeUrl: string, patchParams: object): Promise<AxiosResponse> {
103
+ return await axios.patch(this.assembleUrl(relativeUrl), patchParams, await this.headerHandler.get());
104
+ }
105
+
100
106
  private assembleUrl(relativeUrl: string): string {
101
107
  return `${TestConstants.TS_SELENIUM_BASE_URL}/${relativeUrl}`;
102
108
  }
@@ -9,13 +9,16 @@
9
9
  **********************************************************************/
10
10
  import { AxiosRequestConfig } from 'axios';
11
11
  import { IAuthorizationHeaderHandler } from './IAuthorizationHeaderHandler';
12
- import { injectable } from 'inversify';
12
+ import { inject, injectable } from 'inversify';
13
+ import { DriverHelper } from '../../DriverHelper';
14
+ import { CLASSES } from '../../../inversify.types';
13
15
 
14
16
  @injectable()
15
17
  export class CheMultiuserAuthorizationHeaderHandler implements IAuthorizationHeaderHandler {
18
+ constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }
16
19
 
17
20
  async get(): Promise<AxiosRequestConfig> {
18
- // to-do : Fetch the cookies from user api and pass it here
19
- return { headers: { 'cookie': `` } };
21
+ let token = await this.driverHelper.getDriver().manage().getCookie('_oauth_proxy');
22
+ return { headers: { 'cookie': `_oauth_proxy=${token.value}` } };
20
23
  }
21
24
  }
@@ -0,0 +1,27 @@
1
+ import { IApiUrlResolver } from './IApiUrlResolver';
2
+
3
+ /*********************************************************************
4
+ * Copyright (c) 2019 Red Hat, Inc.
5
+ *
6
+ * This program and the accompanying materials are made
7
+ * available under the terms of the Eclipse Public License 2.0
8
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
9
+ *
10
+ * SPDX-License-Identifier: EPL-2.0
11
+ **********************************************************************/
12
+ import { injectable } from 'inversify';
13
+
14
+
15
+ @injectable()
16
+ export class ApiUrlResolver implements IApiUrlResolver {
17
+ private dashboardApiUrl: string = 'dashboard/api/namespace';
18
+
19
+ public getWorkspaceApiUrl(namespace: string, workspaceName: string) {
20
+ return `${this.getWorkspacesApiUrl(namespace)}/${workspaceName}`;
21
+ }
22
+
23
+ public getWorkspacesApiUrl(namespace: string) {
24
+ return `${this.dashboardApiUrl}/${namespace}-che/devworkspaces`;
25
+ }
26
+ }
27
+
@@ -0,0 +1,15 @@
1
+ /*********************************************************************
2
+ * Copyright (c) 2019 Red Hat, Inc.
3
+ *
4
+ * This program and the accompanying materials are made
5
+ * available under the terms of the Eclipse Public License 2.0
6
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
7
+ *
8
+ * SPDX-License-Identifier: EPL-2.0
9
+ **********************************************************************/
10
+
11
+ export interface IApiUrlResolver {
12
+ getWorkspaceApiUrl(namespace: string, workspacename: string): string;
13
+ getWorkspacesApiUrl(namespace: string): string;
14
+
15
+ }
@@ -12,52 +12,158 @@ import { che } from '@eclipse-che/api';
12
12
  import { TestConstants } from '../../TestConstants';
13
13
  import { injectable, inject } from 'inversify';
14
14
  import { DriverHelper } from '../DriverHelper';
15
+ import { ApiUrlResolver } from './ApiUrlResolver';
15
16
  import 'reflect-metadata';
16
17
  import { WorkspaceStatus } from './WorkspaceStatus';
17
- import { ITestWorkspaceUtil } from './ITestWorkspaceUtil';
18
18
  import { error } from 'selenium-webdriver';
19
19
  import { CheApiRequestHandler } from '../requestHandlers/CheApiRequestHandler';
20
20
  import { CLASSES } from '../../inversify.types';
21
21
  import { Logger } from '../Logger';
22
+ import axios from 'axios';
22
23
 
23
24
  @injectable()
24
- export class TestWorkspaceUtil implements ITestWorkspaceUtil {
25
-
26
- static readonly WORKSPACE_API_URL: string = 'api/workspace';
25
+ export class TestWorkspaceUtil {
27
26
 
27
+ static readonly WORKSPACE_API_URL: string = 'dashboard/api/namespace';
28
+ readonly attempts: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS;
29
+ readonly polling: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_POLLING;
28
30
  constructor(
29
31
  @inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
30
- @inject(CLASSES.CheApiRequestHandler) private readonly processRequestHandler: CheApiRequestHandler
32
+ @inject(CLASSES.CheApiRequestHandler) private readonly processRequestHandler: CheApiRequestHandler,
33
+ @inject(CLASSES.ApiUrlResolver) private readonly apiUrlResolver: ApiUrlResolver
31
34
  ) { }
32
35
 
33
36
  public async waitWorkspaceStatus(namespace: string, workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus) {
34
37
  Logger.debug('TestWorkspaceUtil.waitWorkspaceStatus');
35
38
 
36
- const workspaceStatusApiUrl: string = `${TestWorkspaceUtil.WORKSPACE_API_URL}/${namespace}:${workspaceName}`;
37
- const attempts: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_ATTEMPTS;
38
- const polling: number = TestConstants.TS_SELENIUM_WORKSPACE_STATUS_POLLING;
39
39
  let workspaceStatus: string = '';
40
-
41
- for (let i = 0; i < attempts; i++) {
42
- const response = await this.processRequestHandler.get(workspaceStatusApiUrl);
40
+ let expectedStatus: boolean = false;
41
+ for (let i = 0; i < this.attempts; i++) {
42
+ const response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspaceApiUrl(namespace, workspaceName));
43
43
 
44
44
  if (response.status !== 200) {
45
- await this.driverHelper.wait(polling);
46
- continue;
45
+ throw new Error(`Can not get status of a workspace. Code: ${response.status} Data: ${response.data}`);
47
46
  }
48
47
 
49
- workspaceStatus = await response.data.status;
48
+ workspaceStatus = await response.data.status.phase;
50
49
 
51
50
  if (workspaceStatus === expectedWorkspaceStatus) {
52
- return;
51
+ expectedStatus = true;
52
+ break;
53
53
  }
54
54
 
55
- await this.driverHelper.wait(polling);
55
+ await this.driverHelper.wait(this.polling);
56
56
  }
57
57
 
58
- throw new error.TimeoutError(`Exceeded the maximum number of checking attempts, workspace status is: '${workspaceStatus}' different to '${expectedWorkspaceStatus}'`);
58
+ if (!expectedStatus) {
59
+ let waitTime = this.attempts * this.polling;
60
+ throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms. Currnet status is: ${workspaceStatus}`);
61
+ }
59
62
  }
60
63
 
64
+ public async stopWorkspaceByName(namespace: string, workspaceName: string) {
65
+ Logger.debug('TestWorkspaceUtil.stopWorkspaceByName');
66
+
67
+ const stopWorkspaceApiUrl: string = this.apiUrlResolver.getWorkspaceApiUrl(namespace, workspaceName);
68
+ let stopWorkspaceResponse;
69
+
70
+ try {
71
+ stopWorkspaceResponse = await this.processRequestHandler.patch(stopWorkspaceApiUrl, [{'op': 'replace', 'path': '/spec/started', 'value': false}]);
72
+ } catch (err) {
73
+ console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}`);
74
+ throw err;
75
+ }
76
+
77
+ if (stopWorkspaceResponse.status !== 200) {
78
+ throw new Error(`Cannot stop workspace. Code: ${stopWorkspaceResponse.status} Data: ${stopWorkspaceResponse.data}`);
79
+ }
80
+
81
+ await this.waitWorkspaceStatus(namespace, workspaceName, WorkspaceStatus.STOPPED);
82
+ }
83
+
84
+ // delete a worksapce without stopping phase (similar with force deleting)
85
+ public async deleteWorkspaceByName(namespace: string, workspaceName: string) {
86
+ Logger.debug(`TestWorkspaceUtil.deleteWorkspaceByName ${workspaceName}` );
87
+
88
+ const deleteWorkspaceApiUrl: string = this.apiUrlResolver.getWorkspaceApiUrl(namespace, workspaceName);
89
+ let deleteWorkspaceResponse;
90
+ let deleteWorkspaceStatus: boolean = false;
91
+ try {
92
+ deleteWorkspaceResponse = await this.processRequestHandler.delete(deleteWorkspaceApiUrl);
93
+ } catch (error) {
94
+ if (axios.isAxiosError(error) && error.response?.status === 404) {
95
+ Logger.error(`The workspace :${workspaceName} not found`);
96
+ throw error;
97
+ }
98
+ Logger.error(`Delete workspace call failed. URL used: ${deleteWorkspaceStatus}`);
99
+ throw error;
100
+ }
101
+
102
+ if (deleteWorkspaceResponse.status !== 204) {
103
+ throw new Error(`Can not delete workspace. Code: ${deleteWorkspaceResponse.status} Data: ${deleteWorkspaceResponse.data}`);
104
+ }
105
+
106
+ for (let i = 0; i < this.attempts; i++) {
107
+ try {
108
+ deleteWorkspaceResponse = await this.processRequestHandler.get(deleteWorkspaceApiUrl);
109
+ } catch (error) {
110
+ if (axios.isAxiosError(error) && error.response?.status === 404) {
111
+ deleteWorkspaceStatus = true;
112
+ break;
113
+ }
114
+ }
115
+ }
116
+
117
+ if (!deleteWorkspaceStatus) {
118
+ let waitTime = this.attempts * this.polling;
119
+ throw new error.TimeoutError(`The workspace was not stopped in ${waitTime} ms.`);
120
+ }
121
+ }
122
+
123
+ // stop workspace before deleting with checking stopping phase
124
+ public async stopAndDeleteWorkspaceByName(namespace: string, workspaceName: string) {
125
+ Logger.debug('TestWorkspaceUtil.stopAndDeleteWorkspaceByName');
126
+
127
+ await this.stopWorkspaceByName(namespace, workspaceName);
128
+ await this.deleteWorkspaceByName(namespace, workspaceName);
129
+ }
130
+
131
+ // stop all run workspaces in the namespace
132
+ public async stopAllRunningWorkspaces(namespace: string) {
133
+ Logger.debug('TestWorkspaceUtil.stopAllRunProjects');
134
+ let response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspacesApiUrl(namespace));
135
+ for (let i = 0; i < response.data.items.length; i++) {
136
+ Logger.info('The project is being stopped: ' + response.data.items[i].metadata.name);
137
+ await this.stopWorkspaceByName(namespace, response.data.items[i].metadata.name);
138
+ }
139
+ }
140
+
141
+ // stop all run workspaces, check statused and remove the workspaces
142
+ public async stopAndDeleteAllRunningWorkspaces(namespace: string) {
143
+ Logger.debug('TestWorkspaceUtil.stopAndDeleteAllRunProjects');
144
+ let response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspacesApiUrl(namespace));
145
+ await this.stopAllRunningWorkspaces(namespace);
146
+ for (let i = 0; i < response.data.items.length; i++) {
147
+ Logger.info('The project is being deleted: ' + response.data.items[i].metadata.name);
148
+ await this.deleteWorkspaceByName(namespace, response.data.items[i].metadata.name);
149
+ }
150
+ }
151
+
152
+ // stop all run workspaces without stopping and waiting for of 'Stopped' phase
153
+ // similar with 'force' deleting
154
+ public async deleteAllWorkspaces(namespace: string) {
155
+ Logger.debug('TestWorkspaceUtil.deleteAllRunProjects');
156
+ let response = await this.processRequestHandler.get(this.apiUrlResolver.getWorkspacesApiUrl(namespace));
157
+
158
+ for (let i = 0; i < response.data.items.length; i++) {
159
+ Logger.info('The project is being deleted .......: ' + response.data.items[i].metadata.name);
160
+ await this.deleteWorkspaceByName(namespace, response.data.items[i].metadata.name);
161
+ }
162
+ }
163
+
164
+ /**
165
+ * @deprecated Method deprecated. Works with CHE server only
166
+ */
61
167
  public async waitPluginAdding(namespace: string, workspaceName: string, pluginName: string) {
62
168
  Logger.debug('TestWorkspaceUtil.waitPluginAdding');
63
169
 
@@ -88,6 +194,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
88
194
  }
89
195
  }
90
196
 
197
+ /**
198
+ * @deprecated Method deprecated. Works with CHE server only
199
+ */
91
200
  public async getListOfWorkspaceId(): Promise<string[]> {
92
201
  Logger.debug('TestWorkspaceUtil.getListOfWorkspaceId');
93
202
 
@@ -109,6 +218,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
109
218
  return wsList;
110
219
  }
111
220
 
221
+ /**
222
+ * @deprecated Method deprecated. Works with CHE server only
223
+ */
112
224
  public async getIdOfRunningWorkspace(wsName: string): Promise<string> {
113
225
  Logger.debug('TestWorkspaceUtil.getIdOfRunningWorkspace');
114
226
 
@@ -117,6 +229,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
117
229
 
118
230
  }
119
231
 
232
+ /**
233
+ * @deprecated Method deprecated. Works with CHE server only
234
+ */
120
235
  public async getIdOfRunningWorkspaces(): Promise<Array<string>> {
121
236
  Logger.debug('TestWorkspaceUtil.getIdOfRunningWorkspaces');
122
237
 
@@ -144,13 +259,15 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
144
259
  }
145
260
  }
146
261
 
262
+ /**
263
+ * @deprecated Method deprecated. Works with CHE server only
264
+ */
147
265
  public async removeWorkspaceById(id: string) {
148
266
  Logger.debug('TestWorkspaceUtil.removeWorkspaceById');
149
267
 
150
268
  const workspaceIdUrl: string = `${TestWorkspaceUtil.WORKSPACE_API_URL}/${id}`;
151
269
  try {
152
270
  const deleteWorkspaceResponse = await this.processRequestHandler.delete(workspaceIdUrl);
153
- // response code 204: "No Content" expected
154
271
  if (deleteWorkspaceResponse.status !== 204) {
155
272
  throw new Error(`Can not remove workspace. Code: ${deleteWorkspaceResponse.status} Data: ${deleteWorkspaceResponse.data}`);
156
273
  }
@@ -160,6 +277,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
160
277
  }
161
278
  }
162
279
 
280
+ /**
281
+ * @deprecated Method deprecated. Works with CHE server only
282
+ */
163
283
  public async stopWorkspaceById(id: string) {
164
284
  Logger.debug('TestWorkspaceUtil.stopWorkspaceById');
165
285
 
@@ -167,20 +287,13 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
167
287
  let stopWorkspaceResponse;
168
288
 
169
289
  try {
170
- stopWorkspaceResponse = await this.processRequestHandler.delete(`${stopWorkspaceApiUrl}/runtime`);
290
+ stopWorkspaceResponse = await this.processRequestHandler.delete(`${stopWorkspaceApiUrl}`);
171
291
  } catch (err) {
172
- console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}/runtime`);
292
+ console.log(`Stop workspace call failed. URL used: ${stopWorkspaceApiUrl}`);
173
293
  throw err;
174
294
  }
175
295
 
176
- // if workspace is already stopped, it will return 409: "Conflict"
177
- if (stopWorkspaceResponse.status === 409) {
178
- Logger.warn(`TestWorkspaceUtil.stopWorkspaceById Workspace {${id}} is already STOPPED`);
179
- return;
180
- }
181
-
182
- // response code 204: "No Content" expected
183
- if (stopWorkspaceResponse.status !== 204) {
296
+ if (stopWorkspaceResponse.status !== 200) {
184
297
  throw new Error(`Can not stop workspace. Code: ${stopWorkspaceResponse.status} Data: ${stopWorkspaceResponse.data}`);
185
298
  }
186
299
 
@@ -188,7 +301,7 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
188
301
  let wsStatus = await this.processRequestHandler.get(stopWorkspaceApiUrl);
189
302
  for (let i = 0; i < TestConstants.TS_SELENIUM_PLUGIN_PRECENCE_ATTEMPTS; i++) {
190
303
  wsStatus = await this.processRequestHandler.get(stopWorkspaceApiUrl);
191
- if (wsStatus.data.status === 'STOPPED') {
304
+ if (wsStatus.data.status === WorkspaceStatus.STOPPED) {
192
305
  stopped = true;
193
306
  break;
194
307
  }
@@ -201,6 +314,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
201
314
  }
202
315
  }
203
316
 
317
+ /**
318
+ * @deprecated Method deprecated. Works with CHE server only
319
+ */
204
320
  public async cleanUpAllWorkspaces() {
205
321
  Logger.debug('TestWorkspaceUtil.cleanUpAllWorkspaces');
206
322
 
@@ -217,6 +333,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
217
333
 
218
334
  }
219
335
 
336
+ /**
337
+ * @deprecated Method deprecated. Works with CHE server only
338
+ */
220
339
  public async cleanUpRunningWorkspace(workspaceName: string) {
221
340
  if (workspaceName === undefined || workspaceName.length === 0) {
222
341
  Logger.warn(`Could nod delete workspace because workspaceName is undefined or empty`);
@@ -237,6 +356,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
237
356
  await this.removeWorkspaceById(workspaceID);
238
357
  }
239
358
 
359
+ /**
360
+ * @deprecated Method deprecated. Works with CHE server only
361
+ */
240
362
  async createWsFromDevFile(customTemplate: che.workspace.devfile.Devfile) {
241
363
  Logger.debug('TestWorkspaceUtil.createWsFromDevFile');
242
364
 
@@ -248,6 +370,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
248
370
  }
249
371
  }
250
372
 
373
+ /**
374
+ * @deprecated Method deprecated. Works with CHE server only
375
+ */
251
376
  async getBaseDevfile(): Promise<che.workspace.devfile.Devfile> {
252
377
  Logger.debug('TestWorkspaceUtil.getBaseDevfile');
253
378
 
@@ -261,6 +386,9 @@ export class TestWorkspaceUtil implements ITestWorkspaceUtil {
261
386
  return baseDevfile;
262
387
  }
263
388
 
389
+ /**
390
+ * @deprecated Method deprecated. Works with CHE server only
391
+ */
264
392
  async startWorkspace(workspaceId: string) {
265
393
  Logger.debug('TestWorkspaceUtil.startWorkspace');
266
394
 
@@ -9,7 +9,7 @@
9
9
  **********************************************************************/
10
10
 
11
11
  export enum WorkspaceStatus {
12
- RUNNING = 'RUNNING',
13
- STOPPED = 'STOPPED',
14
- STARTING = 'STARTING'
12
+ RUNNING = 'Running',
13
+ STOPPED = 'Stopped',
14
+ STARTING = 'Starting'
15
15
  }
@@ -1,26 +0,0 @@
1
- /*********************************************************************
2
- * Copyright (c) 2019 Red Hat, Inc.
3
- *
4
- * This program and the accompanying materials are made
5
- * available under the terms of the Eclipse Public License 2.0
6
- * which is available at https://www.eclipse.org/legal/epl-2.0/
7
- *
8
- * SPDX-License-Identifier: EPL-2.0
9
- **********************************************************************/
10
-
11
- import { WorkspaceStatus } from './WorkspaceStatus';
12
- import { che } from '@eclipse-che/api';
13
-
14
- export interface ITestWorkspaceUtil {
15
- cleanUpAllWorkspaces() : void;
16
- cleanUpRunningWorkspace(workspaceName: string) : void;
17
- waitWorkspaceStatus(namespace: string, workspaceName: string, expectedWorkspaceStatus: WorkspaceStatus) : void;
18
- waitPluginAdding(namespace: string, workspaceName: string, pluginId: string) : void;
19
- removeWorkspaceById(id: string) : void;
20
- stopWorkspaceById(id: string) : void;
21
- getIdOfRunningWorkspace(workspaceName: string): Promise<string>;
22
- getIdOfRunningWorkspaces(): Promise<Array<string>>;
23
- createWsFromDevFile(customTemplate: che.workspace.devfile.Devfile): void;
24
- getBaseDevfile(): Promise<che.workspace.devfile.Devfile>;
25
- startWorkspace(workspaceId: string): void;
26
- }