@eclipse-che/che-e2e 7.67.0 → 7.67.1-dev-e49f025

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 (196) hide show
  1. package/README.md +13 -4
  2. package/build/dockerfiles/Dockerfile +1 -1
  3. package/configs/inversify.config.ts +20 -17
  4. package/configs/inversify.types.ts +3 -3
  5. package/configs/mocharc.ts +14 -4
  6. package/configs/sh-scripts/generateIndex.sh +2 -3
  7. package/constants/APITestConstants.ts +56 -0
  8. package/constants/BaseTestConstants.ts +65 -0
  9. package/constants/ChromeDriverConstants.ts +46 -0
  10. package/constants/FactoryTestConstants.ts +45 -0
  11. package/constants/MonacoConstants.ts +22 -0
  12. package/constants/OAuthConstants.ts +56 -0
  13. package/constants/PluginsTestConstants.ts +15 -0
  14. package/constants/ReporterConstants.ts +45 -0
  15. package/constants/TimeoutConstants.ts +28 -146
  16. package/dist/configs/inversify.config.js +17 -13
  17. package/dist/configs/inversify.config.js.map +1 -1
  18. package/dist/configs/inversify.types.js +3 -2
  19. package/dist/configs/inversify.types.js.map +1 -1
  20. package/dist/configs/mocharc.js +13 -4
  21. package/dist/configs/mocharc.js.map +1 -1
  22. package/dist/constants/APITestConstants.js +54 -0
  23. package/dist/constants/APITestConstants.js.map +1 -0
  24. package/dist/constants/BaseTestConstants.js +61 -0
  25. package/dist/constants/BaseTestConstants.js.map +1 -0
  26. package/dist/constants/ChromeDriverConstants.js +44 -0
  27. package/dist/constants/ChromeDriverConstants.js.map +1 -0
  28. package/dist/constants/FactoryTestConstants.js +44 -0
  29. package/dist/constants/FactoryTestConstants.js.map +1 -0
  30. package/dist/constants/MonacoConstants.js +25 -0
  31. package/dist/constants/MonacoConstants.js.map +1 -0
  32. package/dist/constants/OAuthConstants.js +52 -0
  33. package/dist/constants/OAuthConstants.js.map +1 -0
  34. package/dist/constants/PluginsTestConstants.js +19 -0
  35. package/dist/constants/PluginsTestConstants.js.map +1 -0
  36. package/dist/constants/ReporterConstants.js +43 -0
  37. package/dist/constants/ReporterConstants.js.map +1 -0
  38. package/dist/constants/TimeoutConstants.js +22 -113
  39. package/dist/constants/TimeoutConstants.js.map +1 -1
  40. package/dist/driver/ChromeDriver.js +7 -7
  41. package/dist/driver/ChromeDriver.js.map +1 -1
  42. package/dist/index.js +22 -12
  43. package/dist/index.js.map +1 -1
  44. package/dist/pageobjects/dashboard/CreateWorkspace.js +2 -2
  45. package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
  46. package/dist/pageobjects/dashboard/Dashboard.js +7 -6
  47. package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
  48. package/dist/pageobjects/dashboard/Workspaces.js +3 -4
  49. package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
  50. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +2 -3
  51. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
  52. package/dist/pageobjects/git-providers/OauthPage.js +12 -19
  53. package/dist/pageobjects/git-providers/OauthPage.js.map +1 -1
  54. package/dist/pageobjects/ide/CheCodeLocatorLoader.js +2 -2
  55. package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -1
  56. package/dist/pageobjects/login/interfaces/ICheLoginPage.js.map +1 -0
  57. package/dist/pageobjects/login/interfaces/IOcpLoginPage.js.map +1 -0
  58. package/dist/pageobjects/login/kubernetes/DexLoginPage.js +68 -0
  59. package/dist/pageobjects/login/kubernetes/DexLoginPage.js.map +1 -0
  60. package/dist/pageobjects/{openshift/CheLoginPage.js → login/kubernetes/KubernetesLoginPage.js} +21 -26
  61. package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js.map +1 -0
  62. package/dist/pageobjects/{openshift → login/openshift}/OcpLoginPage.js +7 -7
  63. package/dist/pageobjects/login/openshift/OcpLoginPage.js.map +1 -0
  64. package/dist/pageobjects/login/{OcpRedHatLoginPage.js → openshift/OcpRedHatLoginPage.js} +5 -5
  65. package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js.map +1 -0
  66. package/dist/pageobjects/login/{OcpUserLoginPage.js → openshift/OcpUserLoginPage.js} +7 -7
  67. package/dist/pageobjects/login/openshift/OcpUserLoginPage.js.map +1 -0
  68. package/dist/pageobjects/login/{RedHatLoginPage.js → openshift/RedHatLoginPage.js} +6 -6
  69. package/dist/pageobjects/login/openshift/RedHatLoginPage.js.map +1 -0
  70. package/dist/pageobjects/login/{RegularUserOcpCheLoginPage.js → openshift/RegularUserOcpCheLoginPage.js} +8 -8
  71. package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js.map +1 -0
  72. package/dist/specs/MochaHooks.js +18 -11
  73. package/dist/specs/MochaHooks.js.map +1 -1
  74. package/dist/specs/SmokeTest.spec.js +5 -2
  75. package/dist/specs/SmokeTest.spec.js.map +1 -1
  76. package/dist/specs/api/ContainerOverridesAPI.spec.js +5 -4
  77. package/dist/specs/api/ContainerOverridesAPI.spec.js.map +1 -1
  78. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +93 -0
  79. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +1 -0
  80. package/dist/specs/api/EmptyWorkspaceAPI.spec.js +62 -0
  81. package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +1 -0
  82. package/dist/specs/api/PodOverridesAPI.spec.js +5 -4
  83. package/dist/specs/api/PodOverridesAPI.spec.js.map +1 -1
  84. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js +7 -2
  85. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js.map +1 -1
  86. package/dist/specs/dashboard-samples/RecomendedExtentions.spec.js +7 -6
  87. package/dist/specs/dashboard-samples/RecomendedExtentions.spec.js.map +1 -1
  88. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +4 -4
  89. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -1
  90. package/dist/specs/factory/Factory.spec.js +20 -18
  91. package/dist/specs/factory/Factory.spec.js.map +1 -1
  92. package/dist/specs/factory/NoSetupRepoFactory.spec.js +28 -28
  93. package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
  94. package/dist/specs/factory/RefusedOAuthFactory.spec.js +28 -26
  95. package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
  96. package/dist/tests-library/LoginTests.js +4 -4
  97. package/dist/tests-library/LoginTests.js.map +1 -1
  98. package/dist/tests-library/ProjectAndFileTests.js.map +1 -1
  99. package/dist/tests-library/WorkspaceHandlingTests.js +1 -2
  100. package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
  101. package/dist/utils/BrowserTabsUtil.js +2 -2
  102. package/dist/utils/BrowserTabsUtil.js.map +1 -1
  103. package/dist/utils/CheReporter.js +33 -36
  104. package/dist/utils/CheReporter.js.map +1 -1
  105. package/dist/utils/DevWorkspaceConfigurationHelper.js +72 -0
  106. package/dist/utils/DevWorkspaceConfigurationHelper.js.map +1 -0
  107. package/dist/utils/DevfilesRegistryHelper.js +82 -0
  108. package/dist/utils/DevfilesRegistryHelper.js.map +1 -0
  109. package/dist/utils/DriverHelper.js +20 -17
  110. package/dist/utils/DriverHelper.js.map +1 -1
  111. package/dist/utils/KubernetesCommandLineToolsExecutor.js +42 -29
  112. package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -1
  113. package/dist/utils/Logger.js +11 -11
  114. package/dist/utils/Logger.js.map +1 -1
  115. package/dist/utils/ScreenCatcher.js +9 -12
  116. package/dist/utils/ScreenCatcher.js.map +1 -1
  117. package/dist/utils/ShellExecutor.js +5 -2
  118. package/dist/utils/ShellExecutor.js.map +1 -1
  119. package/dist/utils/{vsc/GitUtil.js → StringUtil.js} +26 -8
  120. package/dist/utils/StringUtil.js.map +1 -0
  121. package/dist/utils/request-handlers/CheApiRequestHandler.js +2 -2
  122. package/dist/utils/request-handlers/CheApiRequestHandler.js.map +1 -1
  123. package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js +4 -2
  124. package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
  125. package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
  126. package/dist/utils/workspace/TestWorkspaceUtil.js +9 -7
  127. package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
  128. package/driver/ChromeDriver.ts +7 -7
  129. package/index.ts +22 -12
  130. package/package.json +4 -2
  131. package/pageobjects/dashboard/CreateWorkspace.ts +2 -2
  132. package/pageobjects/dashboard/Dashboard.ts +7 -6
  133. package/pageobjects/dashboard/Workspaces.ts +3 -4
  134. package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +2 -3
  135. package/pageobjects/git-providers/OauthPage.ts +8 -16
  136. package/pageobjects/ide/CheCodeLocatorLoader.ts +2 -2
  137. package/pageobjects/login/kubernetes/DexLoginPage.ts +58 -0
  138. package/pageobjects/login/kubernetes/KubernetesLoginPage.ts +33 -0
  139. package/pageobjects/{openshift → login/openshift}/OcpLoginPage.ts +7 -7
  140. package/pageobjects/login/{OcpRedHatLoginPage.ts → openshift/OcpRedHatLoginPage.ts} +6 -6
  141. package/pageobjects/login/{OcpUserLoginPage.ts → openshift/OcpUserLoginPage.ts} +8 -8
  142. package/pageobjects/login/{RedHatLoginPage.ts → openshift/RedHatLoginPage.ts} +6 -6
  143. package/pageobjects/login/{RegularUserOcpCheLoginPage.ts → openshift/RegularUserOcpCheLoginPage.ts} +9 -9
  144. package/specs/MochaHooks.ts +18 -12
  145. package/specs/SmokeTest.spec.ts +5 -2
  146. package/specs/api/ContainerOverridesAPI.spec.ts +5 -4
  147. package/specs/api/DevfileAcceptanceTestAPI.spec.ts +106 -0
  148. package/specs/api/EmptyWorkspaceAPI.spec.ts +74 -0
  149. package/specs/api/PodOverridesAPI.spec.ts +5 -4
  150. package/specs/dashboard-samples/EmptyWorkspace.spec.ts +10 -2
  151. package/specs/dashboard-samples/RecomendedExtentions.spec.ts +8 -7
  152. package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +4 -4
  153. package/specs/factory/Factory.spec.ts +21 -19
  154. package/specs/factory/NoSetupRepoFactory.spec.ts +29 -30
  155. package/specs/factory/RefusedOAuthFactory.spec.ts +29 -28
  156. package/tests-library/LoginTests.ts +9 -9
  157. package/tests-library/ProjectAndFileTests.ts +1 -1
  158. package/tests-library/WorkspaceHandlingTests.ts +11 -12
  159. package/utils/BrowserTabsUtil.ts +2 -2
  160. package/utils/CheReporter.ts +35 -42
  161. package/utils/DevWorkspaceConfigurationHelper.ts +83 -0
  162. package/utils/DevfilesRegistryHelper.ts +77 -0
  163. package/utils/DriverHelper.ts +54 -50
  164. package/utils/KubernetesCommandLineToolsExecutor.ts +43 -28
  165. package/utils/Logger.ts +16 -17
  166. package/utils/ScreenCatcher.ts +8 -9
  167. package/utils/ShellExecutor.ts +6 -2
  168. package/utils/StringUtil.ts +46 -0
  169. package/utils/request-handlers/CheApiRequestHandler.ts +4 -4
  170. package/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +4 -2
  171. package/utils/workspace/ApiUrlResolver.ts +2 -2
  172. package/utils/workspace/TestWorkspaceUtil.ts +16 -14
  173. package/constants/TestConstants.ts +0 -247
  174. package/dist/constants/TestConstants.js +0 -198
  175. package/dist/constants/TestConstants.js.map +0 -1
  176. package/dist/pageobjects/login/ICheLoginPage.js.map +0 -1
  177. package/dist/pageobjects/login/IOcpLoginPage.js.map +0 -1
  178. package/dist/pageobjects/login/OcpRedHatLoginPage.js.map +0 -1
  179. package/dist/pageobjects/login/OcpUserLoginPage.js.map +0 -1
  180. package/dist/pageobjects/login/RedHatLoginPage.js.map +0 -1
  181. package/dist/pageobjects/login/RegularUserOcpCheLoginPage.js.map +0 -1
  182. package/dist/pageobjects/openshift/CheLoginPage.js.map +0 -1
  183. package/dist/pageobjects/openshift/OcpLoginPage.js.map +0 -1
  184. package/dist/specs/api/CloneGitRepoAPI.spec.js +0 -60
  185. package/dist/specs/api/CloneGitRepoAPI.spec.js.map +0 -1
  186. package/dist/utils/Sanitizer.js +0 -29
  187. package/dist/utils/Sanitizer.js.map +0 -1
  188. package/dist/utils/vsc/GitUtil.js.map +0 -1
  189. package/pageobjects/openshift/CheLoginPage.ts +0 -42
  190. package/specs/api/CloneGitRepoAPI.spec.ts +0 -72
  191. package/utils/Sanitizer.ts +0 -19
  192. package/utils/vsc/GitUtil.ts +0 -25
  193. /package/dist/pageobjects/login/{ICheLoginPage.js → interfaces/ICheLoginPage.js} +0 -0
  194. /package/dist/pageobjects/login/{IOcpLoginPage.js → interfaces/IOcpLoginPage.js} +0 -0
  195. /package/pageobjects/login/{ICheLoginPage.ts → interfaces/ICheLoginPage.ts} +0 -0
  196. /package/pageobjects/login/{IOcpLoginPage.ts → interfaces/IOcpLoginPage.ts} +0 -0
@@ -0,0 +1,83 @@
1
+ import { Main as Generator } from '@eclipse-che/che-devworkspace-generator/lib/main';
2
+ import { DevfileContext } from '@eclipse-che/che-devworkspace-generator/lib/api/devfile-context';
3
+ import { V1alpha2DevWorkspaceTemplate } from '@devfile/api';
4
+ import YAML from 'yaml';
5
+ import * as axios from 'axios';
6
+ import { Logger } from './Logger';
7
+ import { ShellExecutor } from './ShellExecutor';
8
+ import { APITestConstants } from '../constants/APITestConstants';
9
+
10
+ /**
11
+ * to see more about IContextParams and generateDevfileContext(params) check README.md in "@eclipse-che/che-devworkspace-generator;
12
+ * tests/e2e/node_modules/@eclipse-che/che-devworkspace-generator/README.md
13
+ */
14
+
15
+ interface IContextParams {
16
+ devfilePath?: string | undefined;
17
+ devfileUrl?: string | undefined;
18
+ devfileContent?: string | undefined;
19
+ outputFile?: string | undefined;
20
+ editorPath?: string | undefined;
21
+ editorContent?: string | undefined;
22
+ editorEntry?: string | undefined;
23
+ pluginRegistryUrl?: string | undefined;
24
+ projects?: {
25
+ name: string;
26
+ location: string;
27
+ }[];
28
+ injectDefaultComponent?: string | undefined;
29
+ defaultComponentImage?: string | undefined;
30
+ }
31
+
32
+ export class DevWorkspaceConfigurationHelper {
33
+ private generator: Generator = new Generator();
34
+ private readonly params: IContextParams;
35
+
36
+ constructor(params: IContextParams) {
37
+ // check if all undefined
38
+ if (!(params.editorPath || params.editorEntry || params.editorContent)) {
39
+ params.editorEntry = 'che-incubator/che-code/latest';
40
+ }
41
+ // check if one or both has value
42
+ if (APITestConstants.TS_API_TEST_UDI_IMAGE || params.defaultComponentImage) {
43
+ params.injectDefaultComponent = 'true';
44
+ // check if not explicitly passed than assign value from the constants
45
+ if (!params.defaultComponentImage) {
46
+ params.defaultComponentImage = APITestConstants.TS_API_TEST_UDI_IMAGE;
47
+ }
48
+ }
49
+ // assign value from the constants if not explicitly passed
50
+ if (APITestConstants.TS_API_TEST_PLUGIN_REGISTRY_URL && !params.pluginRegistryUrl) {
51
+ params.pluginRegistryUrl = APITestConstants.TS_API_TEST_PLUGIN_REGISTRY_URL;
52
+ }
53
+ if (APITestConstants.TS_API_TEST_CHE_CODE_EDITOR_DEVFILE_URI && !params.editorContent) {
54
+ params.editorContent = ShellExecutor.curl(APITestConstants.TS_API_TEST_CHE_CODE_EDITOR_DEVFILE_URI).stdout;
55
+ }
56
+ this.params = params;
57
+ }
58
+
59
+ async generateDevfileContext(): Promise<DevfileContext> {
60
+ Logger.debug(`${this.constructor.name}.${this.generateDevfileContext.name}`);
61
+ if (!this.params.projects) {
62
+ this.params.projects = [];
63
+ }
64
+ return await this.generator.generateDevfileContext(
65
+ {
66
+ ...this.params,
67
+ projects: this.params.projects
68
+ },
69
+ axios.default as any
70
+ );
71
+ }
72
+
73
+ // write templates and then DevWorkspace in a single file
74
+ async getDevWorkspaceConfigurationYamlAsString(context: DevfileContext): Promise<string> {
75
+ Logger.debug(`${this.constructor.name}.${this.getDevWorkspaceConfigurationYamlAsString.name}`);
76
+ const allContentArray: any[] = context.devWorkspaceTemplates.map(
77
+ (template: V1alpha2DevWorkspaceTemplate) => YAML.stringify(template)
78
+ );
79
+ allContentArray.push(YAML.stringify(context.devWorkspace));
80
+
81
+ return allContentArray.join('---\n');
82
+ }
83
+ }
@@ -0,0 +1,77 @@
1
+ /*********************************************************************
2
+ * Copyright (c) 2023 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
+ import axios, { AxiosResponse } from 'axios';
11
+ import { Logger } from './Logger';
12
+ import YAML from 'yaml';
13
+ import { APITestConstants, SupportedDevfilesRegistries } from '../constants/APITestConstants';
14
+
15
+ export class DevfilesRegistryHelper {
16
+
17
+ async getInbuiltDevfilesRegistryContent(): Promise<AxiosResponse> {
18
+ Logger.debug(`${this.constructor.name}.${this.getInbuiltDevfilesRegistryContent.name}`);
19
+ return await this.getContent(SupportedDevfilesRegistries.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL());
20
+ }
21
+
22
+ async getGitHubCheDevfileRegistryContent(): Promise<AxiosResponse> {
23
+ Logger.debug(`${this.constructor.name}.${this.getGitHubCheDevfileRegistryContent.name}`);
24
+ return await this.getContent(SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL);
25
+ }
26
+
27
+ async collectPathsToDevfilesFromRegistry(): Promise<object[]> {
28
+ Logger.debug(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}`);
29
+ const devfileSamples: object[] = [];
30
+ const sampleNames: string[] = [];
31
+ switch (APITestConstants.TS_API_ACCEPTANCE_TEST_REGISTRY_URL()) {
32
+ case (SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL): {
33
+ const content: any[any] = await this.getGitHubCheDevfileRegistryContent();
34
+ content.forEach((e: any) => {
35
+ if (e.name[0] !== '.') { sampleNames.push(e.name); }
36
+ });
37
+
38
+ for (const sample of sampleNames) {
39
+ const sampleEndpoint: string = `${SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL}${sample}/meta.yaml`;
40
+ const sampleEndpointContent: AxiosResponse = await this.getContent(sampleEndpoint);
41
+ const decodedFileContent: string = Buffer.from((sampleEndpointContent as any).content, 'base64').toString();
42
+ const metaYamlContent: any = YAML.parse(decodedFileContent);
43
+ devfileSamples.push({name: sample, link: metaYamlContent.links.v2});
44
+ }
45
+ Logger.debug(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}: samples list: ${JSON.stringify(devfileSamples)}`);
46
+ }
47
+ break;
48
+ case (SupportedDevfilesRegistries.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL()): {
49
+ const content: any[any] = await this.getInbuiltDevfilesRegistryContent();
50
+
51
+ for (const sample of content) {
52
+ devfileSamples.push({name: sample.displayName, link: sample.links.v2});
53
+ }
54
+ Logger.debug(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}: samples list: ${JSON.stringify(devfileSamples)}`);
55
+ }
56
+ break;
57
+ default: {
58
+ Logger.error(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}: unsupported registry url - ${APITestConstants.TS_API_ACCEPTANCE_TEST_REGISTRY_URL()}\n
59
+ supported registries: ${JSON.stringify(SupportedDevfilesRegistries)}`);
60
+ }
61
+ }
62
+ return devfileSamples;
63
+ }
64
+
65
+ private async getContent(url: string, headers?: object): Promise<AxiosResponse> {
66
+ Logger.debug(`${this.constructor.name}.${this.getContent.name}: ${url}`);
67
+
68
+ let response: AxiosResponse | undefined;
69
+ try {
70
+ response = await axios.get(url, headers);
71
+ } catch (error) {
72
+ Logger.error(`${error} + ${url}`);
73
+ throw error;
74
+ }
75
+ return response?.data;
76
+ }
77
+ }
@@ -12,7 +12,6 @@ import { inject, injectable } from 'inversify';
12
12
  import { TYPES } from '../configs/inversify.types';
13
13
  import { Actions, By, error, ThenableWebDriver, until, WebElement } from 'selenium-webdriver';
14
14
  import 'reflect-metadata';
15
- import { TestConstants } from '../constants/TestConstants';
16
15
  import { Logger } from './Logger';
17
16
  import { TimeoutConstants } from '../constants/TimeoutConstants';
18
17
 
@@ -25,13 +24,13 @@ export class DriverHelper {
25
24
  this.driver = driver.get() as ThenableWebDriver;
26
25
  }
27
26
 
28
- public getAction(): Actions {
27
+ getAction(): Actions {
29
28
  Logger.trace('DriverHelper.getAction');
30
29
 
31
30
  return this.driver.actions();
32
31
  }
33
32
 
34
- public async isVisible(locator: By): Promise<boolean> {
33
+ async isVisible(locator: By): Promise<boolean> {
35
34
  Logger.trace(`DriverHelper.isVisible ${locator}`);
36
35
 
37
36
  try {
@@ -42,21 +41,21 @@ export class DriverHelper {
42
41
  }
43
42
  }
44
43
 
45
- public async wait(milliseconds: number): Promise<void> {
44
+ async wait(milliseconds: number): Promise<void> {
46
45
  Logger.trace(`DriverHelper.wait (${milliseconds} milliseconds)`);
47
46
 
48
47
  await this.driver.sleep(milliseconds);
49
48
  }
50
49
 
51
- public async refreshPage(): Promise<void> {
50
+ async refreshPage(): Promise<void> {
52
51
  Logger.trace(`DriverHelper.refreshPage`);
53
52
 
54
53
  await this.driver.navigate().refresh();
55
54
  }
56
55
 
57
- public async waitVisibilityBoolean(locator: By,
58
- attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
59
- polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<boolean> {
56
+ async waitVisibilityBoolean(locator: By,
57
+ attempts: number = TimeoutConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
58
+ polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<boolean> {
60
59
 
61
60
  Logger.trace(`DriverHelper.waitVisibilityBoolean ${locator}`);
62
61
 
@@ -73,9 +72,9 @@ export class DriverHelper {
73
72
  return false;
74
73
  }
75
74
 
76
- public async waitDisappearanceBoolean(locator: By,
77
- attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
78
- polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<boolean> {
75
+ async waitDisappearanceBoolean(locator: By,
76
+ attempts: number = TimeoutConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
77
+ polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<boolean> {
79
78
 
80
79
  Logger.trace(`DriverHelper.waitDisappearanceBoolean ${locator}`);
81
80
 
@@ -92,8 +91,8 @@ export class DriverHelper {
92
91
  return false;
93
92
  }
94
93
 
95
- public async waitVisibility(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<WebElement> {
96
- const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
94
+ async waitVisibility(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<WebElement> {
95
+ const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
97
96
  const attempts: number = Math.ceil(timeout / polling);
98
97
 
99
98
  Logger.trace(`DriverHelper.waitVisibility ${elementLocator}`);
@@ -150,8 +149,8 @@ export class DriverHelper {
150
149
  throw new error.TimeoutError(`Exceeded maximum visibility checkings attempts for '${elementLocator}' element, timeouted after ${timeout}`);
151
150
  }
152
151
 
153
- public async waitPresence(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<WebElement> {
154
- const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
152
+ async waitPresence(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<WebElement> {
153
+ const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
155
154
  const attempts: number = Math.ceil(timeout / polling);
156
155
 
157
156
  Logger.trace(`DriverHelper.waitPresence ${elementLocator}`);
@@ -178,8 +177,8 @@ export class DriverHelper {
178
177
  throw new error.TimeoutError(`Exceeded maximum presence checking attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
179
178
  }
180
179
 
181
- public async waitAllPresence(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<Array<WebElement>> {
182
- const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
180
+ async waitAllPresence(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<Array<WebElement>> {
181
+ const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
183
182
  const attempts: number = Math.ceil(timeout / polling);
184
183
 
185
184
  Logger.trace(`DriverHelper.waitAllPresence ${elementLocator}`);
@@ -206,7 +205,7 @@ export class DriverHelper {
206
205
  throw new error.TimeoutError(`Exceeded maximum presence checkings attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
207
206
  }
208
207
 
209
- public async waitAllVisibility(locators: Array<By>, timeout: number): Promise<void> {
208
+ async waitAllVisibility(locators: Array<By>, timeout: number): Promise<void> {
210
209
  Logger.trace(`DriverHelper.waitAllVisibility ${locators}`);
211
210
 
212
211
  for (const elementLocator of locators) {
@@ -214,9 +213,9 @@ export class DriverHelper {
214
213
  }
215
214
  }
216
215
 
217
- public async waitDisappearance(elementLocator: By,
218
- attempts: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
219
- polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<void> {
216
+ async waitDisappearance(elementLocator: By,
217
+ attempts: number = TimeoutConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
218
+ polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<void> {
220
219
 
221
220
  Logger.trace(`DriverHelper.waitDisappearance ${elementLocator}`);
222
221
 
@@ -227,7 +226,7 @@ export class DriverHelper {
227
226
  }
228
227
  }
229
228
 
230
- public async waitDisappearanceWithTimeout(elementLocator: By, timeout: number): Promise<void> {
229
+ async waitDisappearanceWithTimeout(elementLocator: By, timeout: number): Promise<void> {
231
230
  Logger.trace(`DriverHelper.waitDisappearanceWithTimeout ${elementLocator}`);
232
231
 
233
232
  await this.getDriver().wait(async () => {
@@ -239,9 +238,9 @@ export class DriverHelper {
239
238
  }, timeout);
240
239
  }
241
240
 
242
- public async waitAllDisappearance(locators: Array<By>,
243
- attemptsPerLocator: number = TestConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
244
- pollingPerLocator: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<void> {
241
+ async waitAllDisappearance(locators: Array<By>,
242
+ attemptsPerLocator: number = TimeoutConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
243
+ pollingPerLocator: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<void> {
245
244
 
246
245
  Logger.trace(`DriverHelper.waitAllDisappearance ${locators}`);
247
246
 
@@ -250,8 +249,8 @@ export class DriverHelper {
250
249
  }
251
250
  }
252
251
 
253
- public async waitAndClick(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
254
- const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
252
+ async waitAndClick(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
253
+ const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
255
254
  const attempts: number = Math.ceil(timeout / polling);
256
255
 
257
256
  Logger.trace(`DriverHelper.waitAndClick ${elementLocator}`);
@@ -308,9 +307,9 @@ export class DriverHelper {
308
307
  throw new error.TimeoutError(`Exceeded maximum clicking attempts, the '${elementLocator}' element is not clickable`);
309
308
  }
310
309
 
311
- public async waitAndGetElementAttribute(elementLocator: By, attribute: string,
310
+ async waitAndGetElementAttribute(elementLocator: By, attribute: string,
312
311
  timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<string> {
313
- const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
312
+ const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
314
313
  const attempts: number = Math.ceil(timeout / polling);
315
314
 
316
315
  Logger.trace(`DriverHelper.waitAndGetElementAttribute ${elementLocator} attribute: '${attribute}'`);
@@ -350,9 +349,9 @@ export class DriverHelper {
350
349
  throw new error.TimeoutError(`Exceeded maximum gettin of the '${attribute}' attribute attempts, from the '${elementLocator}' element`);
351
350
  }
352
351
 
353
- public async waitAndGetCssValue(elementLocator: By, cssAttribute: string,
352
+ async waitAndGetCssValue(elementLocator: By, cssAttribute: string,
354
353
  timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<string> {
355
- const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
354
+ const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
356
355
  const attempts: number = Math.ceil(timeout / polling);
357
356
 
358
357
  Logger.trace(`DriverHelper.waitAndGetCssValue ${elementLocator} cssAttribute: ${cssAttribute}`);
@@ -392,7 +391,7 @@ export class DriverHelper {
392
391
  throw new error.TimeoutError(`Exceeded maximum gettin of the '${cssAttribute}' css attribute attempts, from the '${elementLocator}' element`);
393
392
  }
394
393
 
395
- public async waitAttributeValue(elementLocator: By,
394
+ async waitAttributeValue(elementLocator: By,
396
395
  attribute: string,
397
396
  expectedValue: string,
398
397
  timeout: number): Promise<void> {
@@ -408,8 +407,8 @@ export class DriverHelper {
408
407
  `The '${attribute}' attribute value doesn't match with expected value '${expectedValue}'`);
409
408
  }
410
409
 
411
- public async type(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
412
- const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
410
+ async type(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
411
+ const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
413
412
  const attempts: number = Math.ceil(timeout / polling);
414
413
 
415
414
  if (elementLocator.toString().toLocaleLowerCase().includes('password')) {
@@ -454,8 +453,8 @@ export class DriverHelper {
454
453
  throw new error.TimeoutError(`Exceeded maximum typing attempts, to the '${elementLocator}' element`);
455
454
  }
456
455
 
457
- public async typeToInvisible(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
458
- const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
456
+ async typeToInvisible(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
457
+ const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
459
458
  const attempts: number = Math.ceil(timeout / polling);
460
459
 
461
460
  Logger.trace(`DriverHelper.typeToInvisible ${elementLocator} text: ${text}`);
@@ -496,8 +495,8 @@ export class DriverHelper {
496
495
  throw new error.TimeoutError(`Exceeded maximum typing attempts, to the '${elementLocator}' element`);
497
496
  }
498
497
 
499
- public async clear(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
500
- const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
498
+ async clear(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
499
+ const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
501
500
  const attempts: number = Math.ceil(timeout / polling);
502
501
 
503
502
  Logger.trace(`DriverHelper.clear ${elementLocator}`);
@@ -538,8 +537,8 @@ export class DriverHelper {
538
537
  throw new error.TimeoutError(`Exceeded maximum clearing attempts, to the '${elementLocator}' element`);
539
538
  }
540
539
 
541
- public async clearInvisible(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
542
- const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
540
+ async clearInvisible(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
541
+ const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
543
542
  const attempts: number = Math.ceil(timeout / polling);
544
543
 
545
544
  Logger.trace(`DriverHelper.clearInvisible ${elementLocator}`);
@@ -580,7 +579,7 @@ export class DriverHelper {
580
579
  throw new error.TimeoutError(`Exceeded maximum clearing attempts, to the '${elementLocator}' element`);
581
580
  }
582
581
 
583
- public async enterValue(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
582
+ async enterValue(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
584
583
  if (elementLocator.toString().toLocaleLowerCase().includes('password')) {
585
584
  Logger.trace(`DriverHelper.enterValue ${elementLocator} text: ***`);
586
585
  } else {
@@ -594,14 +593,14 @@ export class DriverHelper {
594
593
  await this.waitAttributeValue(elementLocator, 'value', text, timeout);
595
594
  }
596
595
 
597
- public async waitAndSwitchToFrame(iframeLocator: By, timeout: number): Promise<void> {
596
+ async waitAndSwitchToFrame(iframeLocator: By, timeout: number): Promise<void> {
598
597
  Logger.trace(`DriverHelper.waitAndSwitchToFrame ${iframeLocator}`);
599
598
 
600
599
  await this.driver.wait(until.ableToSwitchToFrame(iframeLocator), timeout);
601
600
  }
602
601
 
603
- public async waitAndGetText(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<string> {
604
- const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
602
+ async waitAndGetText(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<string> {
603
+ const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
605
604
  const attempts: number = Math.ceil(timeout / polling);
606
605
 
607
606
  Logger.trace(`DriverHelper.waitAndGetText ${elementLocator}`);
@@ -641,20 +640,20 @@ export class DriverHelper {
641
640
  throw new error.TimeoutError(`Exceeded maximum text obtaining attempts, from the '${elementLocator}' element`);
642
641
  }
643
642
 
644
- public async waitAndGetValue(elementLocator: By, timeout: number): Promise<string> {
643
+ async waitAndGetValue(elementLocator: By, timeout: number): Promise<string> {
645
644
  Logger.trace(`DriverHelper.waitAndGetValue ${elementLocator}`);
646
645
 
647
646
  return await this.waitAndGetElementAttribute(elementLocator, 'value', timeout);
648
647
  }
649
648
 
650
- public async waitUntilTrue(callback: any, timeout: number): Promise<void> {
649
+ async waitUntilTrue(callback: any, timeout: number): Promise<void> {
651
650
  Logger.trace('DriverHelper.waitUntilTrue');
652
651
 
653
652
  await this.driver.wait(callback, timeout);
654
653
  }
655
654
 
656
- public async scrollTo(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
657
- const polling: number = TestConstants.TS_SELENIUM_DEFAULT_POLLING;
655
+ async scrollTo(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
656
+ const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
658
657
  const attempts: number = Math.ceil(timeout / polling);
659
658
 
660
659
  Logger.trace(`DriverHelper.scrollTo ${elementLocator}`);
@@ -696,16 +695,21 @@ export class DriverHelper {
696
695
  throw new error.TimeoutError(`Exceeded maximum mouse move attempts, for the '${elementLocator}' element`);
697
696
  }
698
697
 
699
- public async scrollToAndClick(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
698
+ async scrollToAndClick(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
700
699
  await this.scrollTo(elementLocator, timeout);
701
700
  await this.waitAndClick(elementLocator, timeout);
702
701
  }
703
702
 
704
- public async scrollToAndEnterValue(elementLocator: By, value: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
703
+ async scrollToAndEnterValue(elementLocator: By, value: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
705
704
  await this.scrollTo(elementLocator, timeout);
706
705
  await this.enterValue(elementLocator, value, timeout);
707
706
  }
708
707
 
708
+ // method is useful to debug page object elements
709
+ async highLightElement(element: WebElement): Promise<void> {
710
+ await this.getDriver().executeScript('arguments[0].style.border=\'2px solid red\'', element);
711
+ }
712
+
709
713
  getDriver(): ThenableWebDriver {
710
714
  Logger.trace('DriverHelper.getDriver');
711
715
 
@@ -1,15 +1,17 @@
1
1
  import { echo, exec, ShellString } from 'shelljs';
2
- import { KubernetesCommandLineTool, TestConstants } from '../constants/TestConstants';
3
2
  import { Logger } from './Logger';
4
3
  import { ShellExecutor } from './ShellExecutor';
5
4
  import * as path from 'path';
5
+ import { APITestConstants, KubernetesCommandLineTool } from '../constants/APITestConstants';
6
+ import { BaseTestConstants } from '../constants/BaseTestConstants';
7
+ import { OAuthConstants } from '../constants/OAuthConstants';
6
8
 
7
9
  export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
8
10
  private static container: string;
9
11
  private static pod: string;
10
12
  private readonly namespace: string;
11
13
  private readonly workspaceName: string | undefined;
12
- private readonly KUBERNETES_COMMAND_LINE_TOOL: string = TestConstants.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL;
14
+ private readonly KUBERNETES_COMMAND_LINE_TOOL: string = APITestConstants.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL;
13
15
 
14
16
  constructor(_workspaceName?: string, _namespace?: string) {
15
17
  super();
@@ -33,8 +35,8 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
33
35
  if (this.isUserLoggedIn()) {
34
36
  Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: User already logged`);
35
37
  } else {
36
- Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: Login ${url}, ${TestConstants.TS_SELENIUM_OCP_USERNAME}`);
37
- exec(`oc login --server=${url} -u=${TestConstants.TS_SELENIUM_OCP_USERNAME} -p=${TestConstants.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`);
38
+ Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: Login ${url}, ${APITestConstants.TS_SELENIUM_OCP_USERNAME}`);
39
+ exec(`oc login --server=${url} -u=${APITestConstants.TS_SELENIUM_OCP_USERNAME} -p=${APITestConstants.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`);
38
40
  }
39
41
  } else {
40
42
  Logger.debug(`${this.getLoggingName(this.loginToOcp.name)}: doesn't support login command`);
@@ -43,22 +45,22 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
43
45
 
44
46
  getContainerName(): string {
45
47
  Logger.debug(`${this.getLoggingName(this.getContainerName.name)}: Get container name.`);
46
- const output: ShellString = this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} get ${(KubernetesCommandLineToolsExecutor.pod)} -o jsonpath='{.spec.containers[*].name}' -n ${this.namespace}`);
48
+ const output: ShellString = ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} get ${(KubernetesCommandLineToolsExecutor.pod)} -o jsonpath='{.spec.containers[*].name}' -n ${this.namespace}`);
47
49
  echo('\n');
48
50
  return output.stderr ? output.stderr : output.stdout;
49
51
  }
50
52
 
51
53
  getWorkspacePodName(): string {
52
54
  Logger.debug(`${this.getLoggingName(this.getWorkspacePodName.name)}: Get workspace pod name.`);
53
- const output: ShellString = this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} get pod -l controller.devfile.io/devworkspace_name=${this.workspaceName} -n ${this.namespace} -o name`);
55
+ const output: ShellString = ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} get pod -l controller.devfile.io/devworkspace_name=${this.workspaceName} -n ${this.namespace} -o name`);
54
56
  return output.stderr ? output.stderr : output.stdout.replace('\n', '');
55
57
  }
56
58
 
57
59
  deleteDevWorkspace(): void {
58
60
  Logger.debug(`${this.getLoggingName(this.deleteDevWorkspace.name)}: Delete '${this.workspaceName}' workspace`);
59
- this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} patch dw ${this.workspaceName} -n ${this.namespace} -p '{ "metadata": { "finalizers": null }}' --type merge || true`);
60
- this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} delete dw ${this.workspaceName} -n ${this.namespace} || true`);
61
- this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} delete dwt ${TestConstants.TS_SELENIUM_EDITOR}-${this.workspaceName} -n ${this.namespace} || true`);
61
+ ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} patch dw ${this.workspaceName} -n ${this.namespace} -p '{ "metadata": { "finalizers": null }}' --type merge || true`);
62
+ ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} delete dw ${this.workspaceName} -n ${this.namespace} || true`);
63
+ ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} delete dwt ${APITestConstants.TS_SELENIUM_EDITOR}-${this.workspaceName} -n ${this.namespace} || true`);
62
64
  }
63
65
 
64
66
  applyAndWaitDevWorkspace(yamlConfiguration: string): ShellString {
@@ -66,58 +68,62 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
66
68
  this.createNamespace();
67
69
  }
68
70
  this.applyYamlConfigurationAsStringOutput(yamlConfiguration);
69
- const output: ShellString = this.waitDevWorkspace();
70
- KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
71
- KubernetesCommandLineToolsExecutor.container = this.getContainerName();
72
- return output;
71
+ return this.waitDevWorkspace();
73
72
  }
74
73
 
75
- executeCommand(commandToExecute: string): ShellString {
74
+ executeCommand(commandToExecute: string, container: string = KubernetesCommandLineToolsExecutor.container): ShellString {
76
75
  Logger.debug(`${this.getLoggingName(this.executeCommand.name)}:`);
77
- return this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${KubernetesCommandLineToolsExecutor.container} -- sh -c "${commandToExecute}"`);
76
+ return ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'`);
78
77
  }
79
78
 
80
- applyYamlConfigurationAsStringOutput(yamlConfiguration: string): void {
79
+ applyYamlConfigurationAsStringOutput(yamlConfiguration: string): ShellString {
81
80
  Logger.debug(`${this.getLoggingName(this.applyYamlConfigurationAsStringOutput.name)}:`);
82
- this.execWithLog(`cat <<EOF | ${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f - \n` +
81
+ return ShellExecutor.execWithLog(`cat <<EOF | ${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f - \n` +
83
82
  yamlConfiguration + '\n' +
84
83
  'EOF');
85
84
  }
86
85
 
87
86
  applyYamlConfigurationAsFile(pathToFile: string): void {
88
87
  Logger.debug(`${this.getLoggingName(this.applyYamlConfigurationAsFile.name)}:`);
89
- this.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f "${path.resolve(pathToFile)}"`);
88
+ ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f "${path.resolve(pathToFile)}"`);
90
89
  }
91
90
 
92
91
  getDevWorkspaceYamlConfiguration(): ShellString {
93
92
  Logger.debug(`${this.getLoggingName(this.getDevWorkspaceYamlConfiguration.name)}:`);
94
- return this.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} get dw ${this.workspaceName} -n ${this.namespace} -o yaml`);
93
+ return ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} get dw ${this.workspaceName} -n ${this.namespace} -o yaml`);
95
94
  }
96
95
 
97
96
  waitDevWorkspace(timeout: number = 360): ShellString {
98
97
  Logger.debug(`${this.getLoggingName(this.waitDevWorkspace.name)}: Wait till workspace ready.`);
99
- return this.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`);
98
+ const output: ShellString = ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`);
99
+ this.getPodAndContainerNames();
100
+ return output;
100
101
  }
101
102
 
102
103
  createNamespace(): void {
103
104
  Logger.debug(`${this.getLoggingName(this.createNamespace.name)}: Create namespace "${this.namespace}".`);
104
- this.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} create namespace ${this.namespace}`);
105
+ ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} create namespace ${this.namespace}`);
105
106
  }
106
107
 
107
108
  createProject(projectName: string): void {
108
109
  Logger.debug(`${this.getLoggingName(this.createProject.name)}: Create new project "${projectName}".`);
109
- this.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} new-project ${projectName} -n ${this.namespace}`);
110
+ ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} new-project ${projectName} -n ${this.namespace}`);
110
111
  }
111
112
 
112
113
  deleteProject(projectName: string): void {
113
114
  Logger.debug(`${this.getLoggingName(this.deleteProject.name)}: Delete "${projectName}".`);
114
- this.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete project ${projectName} -n ${this.namespace}`);
115
+ ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete project ${projectName} -n ${this.namespace}`);
116
+ }
117
+
118
+ private getPodAndContainerNames(): void {
119
+ KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
120
+ KubernetesCommandLineToolsExecutor.container = this.getContainerName();
115
121
  }
116
122
 
117
123
  private isUserLoggedIn(): boolean {
118
- const whoamiCommandOutput: ShellString = this.execWithLog('oc whoami && oc whoami --show-server=true');
124
+ const whoamiCommandOutput: ShellString = ShellExecutor.execWithLog('oc whoami && oc whoami --show-server=true');
119
125
 
120
- return whoamiCommandOutput.stdout.includes(TestConstants.TS_SELENIUM_OCP_USERNAME) && whoamiCommandOutput.stdout.includes(this.getServerUrl());
126
+ return whoamiCommandOutput.stdout.includes(OAuthConstants.TS_SELENIUM_OCP_USERNAME) && whoamiCommandOutput.stdout.includes(this.getServerUrl());
121
127
  }
122
128
 
123
129
  private getLoggingName(methodName: string): string {
@@ -126,15 +132,15 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
126
132
 
127
133
  private setNamespace(_namespace: string | undefined): string {
128
134
  _namespace = _namespace !== undefined ? _namespace
129
- : TestConstants.TS_SELENIUM_BASE_URL.includes('devspaces') ? TestConstants.TS_SELENIUM_OCP_USERNAME + '-devspaces'
130
- : TestConstants.TS_SELENIUM_BASE_URL.includes('che') ? TestConstants.TS_SELENIUM_OCP_USERNAME + '-che'
135
+ : BaseTestConstants.TS_SELENIUM_BASE_URL.includes('devspaces') ? OAuthConstants.TS_SELENIUM_OCP_USERNAME + '-devspaces'
136
+ : BaseTestConstants.TS_SELENIUM_BASE_URL.includes('che') ? OAuthConstants.TS_SELENIUM_OCP_USERNAME + '-che'
131
137
  : 'default';
132
138
  return _namespace;
133
139
  }
134
140
 
135
141
  private getServerUrl(): string {
136
142
  Logger.debug(`${this.getLoggingName(this.getServerUrl.name)}: Get server api url.`);
137
- return TestConstants.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443';
143
+ return BaseTestConstants.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443';
138
144
  }
139
145
  }
140
146
 
@@ -163,5 +169,14 @@ export namespace KubernetesCommandLineToolsExecutor {
163
169
  removeFolder(path: string): ShellString {
164
170
  return this.executeCommand('rm -rf ' + path);
165
171
  }
172
+
173
+ getEnvValue(envName: string): string {
174
+ envName = envName.replace(/[${}]/g, '');
175
+ const output: ShellString = this.executeCommand(`env | grep ${envName}`);
176
+ return output.stderr ? output.stderr :
177
+ output.stdout
178
+ .substring(output.stdout.lastIndexOf('=') + 1)
179
+ .replace('\n', '');
180
+ }
166
181
  }
167
182
  }