@eclipse-che/che-e2e 7.74.0-dev-1d09cb7 → 7.74.0-dev-41d1364

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 (221) hide show
  1. package/.eslintignore +10 -0
  2. package/.eslintrc.js +183 -0
  3. package/.prettierignore +10 -0
  4. package/.prettierrc.json +10 -0
  5. package/README.md +47 -47
  6. package/configs/inversify.config.ts +13 -9
  7. package/configs/inversify.types.ts +29 -29
  8. package/configs/mocharc.ts +21 -24
  9. package/constants/API_TEST_CONSTANTS.ts +67 -0
  10. package/constants/BASE_TEST_CONSTANTS.ts +80 -0
  11. package/constants/CHROME_DRIVER_CONSTANTS.ts +54 -0
  12. package/constants/FACTORY_TEST_CONSTANTS.ts +61 -0
  13. package/constants/MONACO_CONSTANTS.ts +25 -0
  14. package/constants/OAUTH_CONSTANTS.ts +67 -0
  15. package/constants/PLUGIN_TEST_CONSTANTS.ts +15 -0
  16. package/constants/REPORTER_CONSTANTS.ts +53 -0
  17. package/constants/TIMEOUT_CONSTANTS.ts +131 -0
  18. package/dist/configs/inversify.config.js +14 -8
  19. package/dist/configs/inversify.config.js.map +1 -1
  20. package/dist/configs/inversify.types.js +2 -2
  21. package/dist/configs/inversify.types.js.map +1 -1
  22. package/dist/configs/mocharc.js +13 -16
  23. package/dist/configs/mocharc.js.map +1 -1
  24. package/dist/constants/{APITestConstants.js → API_TEST_CONSTANTS.js} +12 -12
  25. package/dist/constants/API_TEST_CONSTANTS.js.map +1 -0
  26. package/dist/constants/{BaseTestConstants.js → BASE_TEST_CONSTANTS.js} +16 -16
  27. package/dist/constants/BASE_TEST_CONSTANTS.js.map +1 -0
  28. package/dist/constants/{ChromeDriverConstants.js → CHROME_DRIVER_CONSTANTS.js} +13 -13
  29. package/dist/constants/CHROME_DRIVER_CONSTANTS.js.map +1 -0
  30. package/dist/constants/{FactoryTestConstants.js → FACTORY_TEST_CONSTANTS.js} +14 -13
  31. package/dist/constants/FACTORY_TEST_CONSTANTS.js.map +1 -0
  32. package/dist/constants/{MonacoConstants.js → MONACO_CONSTANTS.js} +7 -7
  33. package/dist/constants/MONACO_CONSTANTS.js.map +1 -0
  34. package/dist/constants/{OAuthConstants.js → OAUTH_CONSTANTS.js} +14 -14
  35. package/dist/constants/OAUTH_CONSTANTS.js.map +1 -0
  36. package/dist/constants/{PluginsTestConstants.js → PLUGIN_TEST_CONSTANTS.js} +7 -7
  37. package/dist/constants/PLUGIN_TEST_CONSTANTS.js.map +1 -0
  38. package/dist/constants/{ReporterConstants.js → REPORTER_CONSTANTS.js} +12 -12
  39. package/dist/constants/REPORTER_CONSTANTS.js.map +1 -0
  40. package/dist/constants/{TimeoutConstants.js → TIMEOUT_CONSTANTS.js} +24 -24
  41. package/dist/constants/TIMEOUT_CONSTANTS.js.map +1 -0
  42. package/dist/driver/ChromeDriver.js +12 -16
  43. package/dist/driver/ChromeDriver.js.map +1 -1
  44. package/dist/index.js +9 -9
  45. package/dist/index.js.map +1 -1
  46. package/dist/pageobjects/dashboard/CreateWorkspace.js +11 -11
  47. package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
  48. package/dist/pageobjects/dashboard/Dashboard.js +16 -16
  49. package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
  50. package/dist/pageobjects/dashboard/Workspaces.js +28 -28
  51. package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
  52. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +36 -25
  53. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
  54. package/dist/pageobjects/git-providers/OauthPage.js +20 -18
  55. package/dist/pageobjects/git-providers/OauthPage.js.map +1 -1
  56. package/dist/pageobjects/ide/CheCodeLocatorLoader.js +9 -9
  57. package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -1
  58. package/dist/pageobjects/login/interfaces/ICheLoginPage.js +2 -2
  59. package/dist/pageobjects/login/interfaces/IOcpLoginPage.js +2 -2
  60. package/dist/pageobjects/login/kubernetes/DexLoginPage.js +5 -5
  61. package/dist/pageobjects/login/kubernetes/DexLoginPage.js.map +1 -1
  62. package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js +5 -5
  63. package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js.map +1 -1
  64. package/dist/pageobjects/login/openshift/OcpLoginPage.js +13 -13
  65. package/dist/pageobjects/login/openshift/OcpLoginPage.js.map +1 -1
  66. package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js +5 -5
  67. package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js.map +1 -1
  68. package/dist/pageobjects/login/openshift/OcpUserLoginPage.js +6 -6
  69. package/dist/pageobjects/login/openshift/OcpUserLoginPage.js.map +1 -1
  70. package/dist/pageobjects/login/openshift/RedHatLoginPage.js +5 -5
  71. package/dist/pageobjects/login/openshift/RedHatLoginPage.js.map +1 -1
  72. package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js +8 -8
  73. package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js.map +1 -1
  74. package/dist/pageobjects/openshift/OcpApplicationPage.js +5 -5
  75. package/dist/pageobjects/openshift/OcpApplicationPage.js.map +1 -1
  76. package/dist/pageobjects/openshift/OcpImportFromGitPage.js +4 -4
  77. package/dist/pageobjects/openshift/OcpImportFromGitPage.js.map +1 -1
  78. package/dist/pageobjects/openshift/OcpMainPage.js +6 -6
  79. package/dist/pageobjects/openshift/OcpMainPage.js.map +1 -1
  80. package/dist/specs/MochaHooks.js +26 -23
  81. package/dist/specs/MochaHooks.js.map +1 -1
  82. package/dist/specs/SmokeTest.spec.js +11 -11
  83. package/dist/specs/SmokeTest.spec.js.map +1 -1
  84. package/dist/specs/api/ContainerOverridesAPI.spec.js +10 -1
  85. package/dist/specs/api/ContainerOverridesAPI.spec.js.map +1 -1
  86. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +26 -15
  87. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +1 -1
  88. package/dist/specs/api/EmptyWorkspaceAPI.spec.js +17 -11
  89. package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +1 -1
  90. package/dist/specs/api/PodOverridesAPI.spec.js +12 -3
  91. package/dist/specs/api/PodOverridesAPI.spec.js.map +1 -1
  92. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js +5 -5
  93. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js.map +1 -1
  94. package/dist/specs/dashboard-samples/Quarkus.spec.js +7 -7
  95. package/dist/specs/dashboard-samples/Quarkus.spec.js.map +1 -1
  96. package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js +41 -41
  97. package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js.map +1 -1
  98. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +14 -9
  99. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -1
  100. package/dist/specs/factory/Factory.spec.js +25 -25
  101. package/dist/specs/factory/Factory.spec.js.map +1 -1
  102. package/dist/specs/factory/NoSetupRepoFactory.spec.js +37 -34
  103. package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
  104. package/dist/specs/factory/RefusedOAuthFactory.spec.js +33 -33
  105. package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
  106. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +12 -3
  107. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +1 -1
  108. package/dist/tests-library/LoginTests.js +7 -7
  109. package/dist/tests-library/LoginTests.js.map +1 -1
  110. package/dist/tests-library/ProjectAndFileTests.js +7 -5
  111. package/dist/tests-library/ProjectAndFileTests.js.map +1 -1
  112. package/dist/tests-library/WorkspaceHandlingTests.js +16 -13
  113. package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
  114. package/dist/utils/BrowserTabsUtil.js +19 -14
  115. package/dist/utils/BrowserTabsUtil.js.map +1 -1
  116. package/dist/utils/CheReporter.js +44 -44
  117. package/dist/utils/CheReporter.js.map +1 -1
  118. package/dist/utils/DevWorkspaceConfigurationHelper.js +17 -8
  119. package/dist/utils/DevWorkspaceConfigurationHelper.js.map +1 -1
  120. package/dist/utils/DevfilesRegistryHelper.js +19 -13
  121. package/dist/utils/DevfilesRegistryHelper.js.map +1 -1
  122. package/dist/utils/DriverHelper.js +64 -66
  123. package/dist/utils/DriverHelper.js.map +1 -1
  124. package/dist/utils/KubernetesCommandLineToolsExecutor.js +28 -24
  125. package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -1
  126. package/dist/utils/Logger.js +18 -19
  127. package/dist/utils/Logger.js.map +1 -1
  128. package/dist/utils/ScreenCatcher.js +18 -12
  129. package/dist/utils/ScreenCatcher.js.map +1 -1
  130. package/dist/utils/ShellExecutor.js +9 -0
  131. package/dist/utils/ShellExecutor.js.map +1 -1
  132. package/dist/utils/StringUtil.js +15 -7
  133. package/dist/utils/StringUtil.js.map +1 -1
  134. package/dist/utils/request-handlers/CheApiRequestHandler.js +27 -27
  135. package/dist/utils/request-handlers/CheApiRequestHandler.js.map +1 -1
  136. package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js +10 -6
  137. package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
  138. package/dist/utils/request-handlers/headers/IAuthorizationHeaderHandler.js +2 -2
  139. package/dist/utils/workspace/ApiUrlResolver.js +3 -3
  140. package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
  141. package/dist/utils/workspace/ITestWorkspaceUtil.js +2 -2
  142. package/dist/utils/workspace/TestWorkspaceUtil.js +21 -19
  143. package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
  144. package/dist/utils/workspace/WorkspaceStatus.js +2 -2
  145. package/dist/utils/workspace/WorkspaceStatus.js.map +1 -1
  146. package/driver/ChromeDriver.ts +44 -50
  147. package/driver/IDriver.ts +3 -3
  148. package/index.ts +9 -9
  149. package/package.json +59 -49
  150. package/pageobjects/dashboard/CreateWorkspace.ts +64 -55
  151. package/pageobjects/dashboard/Dashboard.ts +101 -100
  152. package/pageobjects/dashboard/Workspaces.ts +196 -164
  153. package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +150 -125
  154. package/pageobjects/git-providers/OauthPage.ts +177 -166
  155. package/pageobjects/ide/CheCodeLocatorLoader.ts +49 -46
  156. package/pageobjects/login/interfaces/ICheLoginPage.ts +3 -3
  157. package/pageobjects/login/interfaces/IOcpLoginPage.ts +3 -3
  158. package/pageobjects/login/kubernetes/DexLoginPage.ts +31 -30
  159. package/pageobjects/login/kubernetes/KubernetesLoginPage.ts +15 -14
  160. package/pageobjects/login/openshift/OcpLoginPage.ts +61 -54
  161. package/pageobjects/login/openshift/OcpRedHatLoginPage.ts +29 -24
  162. package/pageobjects/login/openshift/OcpUserLoginPage.ts +15 -18
  163. package/pageobjects/login/openshift/RedHatLoginPage.ts +48 -46
  164. package/pageobjects/login/openshift/RegularUserOcpCheLoginPage.ts +38 -34
  165. package/pageobjects/openshift/OcpApplicationPage.ts +21 -20
  166. package/pageobjects/openshift/OcpImportFromGitPage.ts +70 -68
  167. package/pageobjects/openshift/OcpMainPage.ts +69 -68
  168. package/specs/MochaHooks.ts +59 -50
  169. package/specs/SmokeTest.spec.ts +43 -40
  170. package/specs/api/ContainerOverridesAPI.spec.ts +33 -26
  171. package/specs/api/DevfileAcceptanceTestAPI.spec.ts +106 -95
  172. package/specs/api/EmptyWorkspaceAPI.spec.ts +62 -57
  173. package/specs/api/PodOverridesAPI.spec.ts +42 -33
  174. package/specs/dashboard-samples/EmptyWorkspace.spec.ts +31 -31
  175. package/specs/dashboard-samples/Quarkus.spec.ts +34 -34
  176. package/specs/dashboard-samples/RecommendedExtensions.spec.ts +192 -174
  177. package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +61 -52
  178. package/specs/factory/Factory.spec.ts +178 -168
  179. package/specs/factory/NoSetupRepoFactory.spec.ts +226 -211
  180. package/specs/factory/RefusedOAuthFactory.spec.ts +218 -204
  181. package/specs/miscellaneous/PredefinedNamespace.spec.ts +64 -54
  182. package/tests-library/LoginTests.ts +34 -32
  183. package/tests-library/ProjectAndFileTests.ts +21 -18
  184. package/tests-library/WorkspaceHandlingTests.ts +98 -89
  185. package/tsconfig.json +15 -15
  186. package/utils/BrowserTabsUtil.ts +103 -97
  187. package/utils/CheReporter.ts +141 -145
  188. package/utils/DevWorkspaceConfigurationHelper.ts +70 -61
  189. package/utils/DevfilesRegistryHelper.ts +67 -58
  190. package/utils/DriverHelper.ts +726 -700
  191. package/utils/KubernetesCommandLineToolsExecutor.ts +196 -180
  192. package/utils/Logger.ts +102 -125
  193. package/utils/ScreenCatcher.ts +57 -46
  194. package/utils/ShellExecutor.ts +19 -11
  195. package/utils/StringUtil.ts +40 -32
  196. package/utils/request-handlers/CheApiRequestHandler.ts +91 -88
  197. package/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +32 -21
  198. package/utils/request-handlers/headers/IAuthorizationHeaderHandler.ts +3 -3
  199. package/utils/workspace/ApiUrlResolver.ts +31 -26
  200. package/utils/workspace/ITestWorkspaceUtil.ts +31 -31
  201. package/utils/workspace/TestWorkspaceUtil.ts +152 -145
  202. package/utils/workspace/WorkspaceStatus.ts +5 -5
  203. package/constants/APITestConstants.ts +0 -57
  204. package/constants/BaseTestConstants.ts +0 -68
  205. package/constants/ChromeDriverConstants.ts +0 -46
  206. package/constants/FactoryTestConstants.ts +0 -51
  207. package/constants/MonacoConstants.ts +0 -22
  208. package/constants/OAuthConstants.ts +0 -57
  209. package/constants/PluginsTestConstants.ts +0 -15
  210. package/constants/ReporterConstants.ts +0 -45
  211. package/constants/TimeoutConstants.ts +0 -113
  212. package/dist/constants/APITestConstants.js.map +0 -1
  213. package/dist/constants/BaseTestConstants.js.map +0 -1
  214. package/dist/constants/ChromeDriverConstants.js.map +0 -1
  215. package/dist/constants/FactoryTestConstants.js.map +0 -1
  216. package/dist/constants/MonacoConstants.js.map +0 -1
  217. package/dist/constants/OAuthConstants.js.map +0 -1
  218. package/dist/constants/PluginsTestConstants.js.map +0 -1
  219. package/dist/constants/ReporterConstants.js.map +0 -1
  220. package/dist/constants/TimeoutConstants.js.map +0 -1
  221. package/tslint.json +0 -126
@@ -1,190 +1,206 @@
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
+ **********************************************************************/
1
10
  import { echo, exec, ShellString } from 'shelljs';
2
11
  import { Logger } from './Logger';
3
12
  import { ShellExecutor } from './ShellExecutor';
4
13
  import * as path from 'path';
5
- import { APITestConstants, KubernetesCommandLineTool } from '../constants/APITestConstants';
6
- import { BaseTestConstants } from '../constants/BaseTestConstants';
7
- import { OAuthConstants } from '../constants/OAuthConstants';
14
+ import { API_TEST_CONSTANTS, KubernetesCommandLineTool } from '../constants/API_TEST_CONSTANTS';
15
+ import { BASE_TEST_CONSTANTS } from '../constants/BASE_TEST_CONSTANTS';
16
+ import { OAUTH_CONSTANTS } from '../constants/OAUTH_CONSTANTS';
8
17
 
9
18
  export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
10
- private static container: string;
11
- private static pod: string;
12
- private readonly namespace: string;
13
- private readonly workspaceName: string | undefined;
14
- private readonly KUBERNETES_COMMAND_LINE_TOOL: string =
15
- APITestConstants.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL;
16
-
17
- constructor(_workspaceName?: string, _namespace?: string) {
18
- super();
19
- this.workspaceName = _workspaceName;
20
- this.namespace = this.setNamespace(_namespace);
21
- }
22
-
23
- get getWorkspaceName(): string {
24
- return <string>this.workspaceName;
25
- }
26
-
27
- get getNamespace(): string {
28
- return this.namespace;
29
- }
30
-
31
- // login to Openshift cluster with username and password
32
- loginToOcp(): void {
33
- if (this.KUBERNETES_COMMAND_LINE_TOOL === KubernetesCommandLineTool.OC) {
34
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - login to the "OC" client.`);
35
- const url: string = this.getServerUrl();
36
- if (this.isUserLoggedIn()) {
37
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - user already logged`);
38
- } else {
39
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - login ${url}, ${OAuthConstants.TS_SELENIUM_OCP_USERNAME}`);
40
- exec(`oc login --server=${url} -u=${OAuthConstants.TS_SELENIUM_OCP_USERNAME} -p=${OAuthConstants.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`);
41
- }
42
- } else {
43
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - doesn't support login command`);
44
- }
45
- }
46
-
47
- getContainerName(): string {
48
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - get container name.`);
49
- const output: ShellString = ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} get ${KubernetesCommandLineToolsExecutor.pod} -o jsonpath='{.spec.containers[*].name}' -n ${this.namespace}`);
50
- echo('\n');
51
- return output.stderr ? output.stderr : output.stdout;
52
- }
53
-
54
- getWorkspacePodName(): string {
55
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - get workspace pod name.`);
56
- 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`);
57
- return output.stderr ? output.stderr : output.stdout.replace('\n', '');
58
- }
59
-
60
- deleteDevWorkspace(): void {
61
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - delete '${this.workspaceName}' workspace`);
62
- ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} patch dw ${this.workspaceName} -n ${this.namespace} -p '{ "metadata": { "finalizers": null }}' --type merge || true`);
63
- ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete dw ${this.workspaceName} -n ${this.namespace} || true`);
64
- ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete dwt ${BaseTestConstants.TS_SELENIUM_EDITOR}-${this.workspaceName} -n ${this.namespace} || true`);
65
- }
66
-
67
- applyAndWaitDevWorkspace(yamlConfiguration: string): ShellString {
68
- if (this.KUBERNETES_COMMAND_LINE_TOOL === KubernetesCommandLineTool.KUBECTL) {
69
- this.createNamespace();
70
- }
71
- this.applyYamlConfigurationAsStringOutput(yamlConfiguration);
72
- return this.waitDevWorkspace();
73
- }
74
-
75
- executeCommand(
76
- commandToExecute: string,
77
- container: string = KubernetesCommandLineToolsExecutor.container): ShellString {
78
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
79
- return ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'`);
80
- }
81
-
82
- applyYamlConfigurationAsStringOutput(yamlConfiguration: string): ShellString {
83
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
84
- return ShellExecutor.execWithLog(`cat <<EOF | ${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f - \n` +
85
- yamlConfiguration +
86
- '\n' +
87
- 'EOF');
88
- }
89
-
90
- applyYamlConfigurationAsFile(pathToFile: string): void {
91
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
92
- ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f "${path.resolve(pathToFile)}"`);
93
- }
94
-
95
- getDevWorkspaceYamlConfiguration(): ShellString {
96
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
97
- return ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} get dw ${this.workspaceName} -n ${this.namespace} -o yaml`);
98
- }
99
-
100
- waitDevWorkspace(timeout: number = 360): ShellString {
101
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - wait till workspace ready.`);
102
- const output: ShellString = ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`);
103
- this.getPodAndContainerNames();
104
- return output;
105
- }
106
-
107
- createNamespace(): void {
108
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - create namespace "${this.namespace}".`);
109
- ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} create namespace ${this.namespace}`);
110
- }
111
-
112
- createProject(projectName: string): void {
113
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - create new project "${projectName}".`);
114
- ShellExecutor.execWithLog(
115
- `${this.KUBERNETES_COMMAND_LINE_TOOL} new-project ${projectName} -n ${this.namespace}`
116
- );
117
- }
118
-
119
- deleteProject(projectName: string): void {
120
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - delete "${projectName}".`);
121
- ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete project ${projectName} -n ${this.namespace}`);
122
- }
123
-
124
- private getPodAndContainerNames(): void {
125
- KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
126
- KubernetesCommandLineToolsExecutor.container = this.getContainerName();
127
- }
128
-
129
- private isUserLoggedIn(): boolean {
130
- const whoamiCommandOutput: ShellString = ShellExecutor.execWithLog('oc whoami && oc whoami --show-server=true');
131
-
132
- return (
133
- whoamiCommandOutput.stdout.includes(OAuthConstants.TS_SELENIUM_OCP_USERNAME) && whoamiCommandOutput.stdout.includes(this.getServerUrl()));
134
- }
135
-
136
- private setNamespace(_namespace: string | undefined): string {
137
- _namespace =
138
- _namespace !== undefined
139
- ? _namespace
140
- : BaseTestConstants.TS_SELENIUM_BASE_URL.includes('devspaces')
141
- ? OAuthConstants.TS_SELENIUM_OCP_USERNAME + '-devspaces'
142
- : BaseTestConstants.TS_SELENIUM_BASE_URL.includes('che')
143
- ? OAuthConstants.TS_SELENIUM_OCP_USERNAME + '-che'
144
- : 'default';
145
- return _namespace;
146
- }
147
-
148
- private getServerUrl(): string {
149
- Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - get server api url.`);
150
- return (BaseTestConstants.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443');
151
- }
19
+ private static container: string;
20
+ private static pod: string;
21
+ private readonly namespace: string;
22
+ private readonly workspaceName: string | undefined;
23
+ private readonly KUBERNETES_COMMAND_LINE_TOOL: string = API_TEST_CONSTANTS.TS_API_TEST_KUBERNETES_COMMAND_LINE_TOOL;
24
+
25
+ constructor(_workspaceName?: string, _namespace?: string) {
26
+ super();
27
+ this.workspaceName = _workspaceName;
28
+ this.namespace = this.setNamespace(_namespace);
29
+ }
30
+
31
+ get getWorkspaceName(): string {
32
+ return <string>this.workspaceName;
33
+ }
34
+
35
+ get getNamespace(): string {
36
+ return this.namespace;
37
+ }
38
+
39
+ // login to Openshift cluster with username and password
40
+ loginToOcp(): void {
41
+ if (this.KUBERNETES_COMMAND_LINE_TOOL === KubernetesCommandLineTool.OC) {
42
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - login to the "OC" client.`);
43
+ const url: string = this.getServerUrl();
44
+ if (this.isUserLoggedIn()) {
45
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - user already logged`);
46
+ } else {
47
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - login ${url}, ${OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME}`);
48
+ exec(
49
+ `oc login --server=${url} -u=${OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME} -p=${OAUTH_CONSTANTS.TS_SELENIUM_OCP_PASSWORD} --insecure-skip-tls-verify`
50
+ );
51
+ }
52
+ } else {
53
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - doesn't support login command`);
54
+ }
55
+ }
56
+
57
+ getContainerName(): string {
58
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - get container name.`);
59
+ const output: ShellString = ShellExecutor.execWithLog(
60
+ `${this.KUBERNETES_COMMAND_LINE_TOOL} get ${KubernetesCommandLineToolsExecutor.pod} -o jsonpath='{.spec.containers[*].name}' -n ${this.namespace}`
61
+ );
62
+ echo('\n');
63
+ return output.stderr ? output.stderr : output.stdout;
64
+ }
65
+
66
+ getWorkspacePodName(): string {
67
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - get workspace pod name.`);
68
+ const output: ShellString = ShellExecutor.execWithLog(
69
+ `${this.KUBERNETES_COMMAND_LINE_TOOL} get pod -l controller.devfile.io/devworkspace_name=${this.workspaceName} -n ${this.namespace} -o name`
70
+ );
71
+ return output.stderr ? output.stderr : output.stdout.replace('\n', '');
72
+ }
73
+
74
+ deleteDevWorkspace(): void {
75
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - delete '${this.workspaceName}' workspace`);
76
+ ShellExecutor.execWithLog(
77
+ `${this.KUBERNETES_COMMAND_LINE_TOOL} patch dw ${this.workspaceName} -n ${this.namespace} -p '{ "metadata": { "finalizers": null }}' --type merge || true`
78
+ );
79
+ ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete dw ${this.workspaceName} -n ${this.namespace} || true`);
80
+ ShellExecutor.execWithLog(
81
+ `${this.KUBERNETES_COMMAND_LINE_TOOL} delete dwt ${BASE_TEST_CONSTANTS.TS_SELENIUM_EDITOR}-${this.workspaceName} -n ${this.namespace} || true`
82
+ );
83
+ }
84
+
85
+ applyAndWaitDevWorkspace(yamlConfiguration: string): ShellString {
86
+ if (this.KUBERNETES_COMMAND_LINE_TOOL === KubernetesCommandLineTool.KUBECTL) {
87
+ this.createNamespace();
88
+ }
89
+ this.applyYamlConfigurationAsStringOutput(yamlConfiguration);
90
+ return this.waitDevWorkspace();
91
+ }
92
+
93
+ executeCommand(commandToExecute: string, container: string = KubernetesCommandLineToolsExecutor.container): ShellString {
94
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
95
+ return ShellExecutor.execWithLog(
96
+ `${this.KUBERNETES_COMMAND_LINE_TOOL} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'`
97
+ );
98
+ }
99
+
100
+ applyYamlConfigurationAsStringOutput(yamlConfiguration: string): ShellString {
101
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
102
+ return ShellExecutor.execWithLog(
103
+ `cat <<EOF | ${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f - \n` + yamlConfiguration + '\n' + 'EOF'
104
+ );
105
+ }
106
+
107
+ applyYamlConfigurationAsFile(pathToFile: string): void {
108
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
109
+ ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} apply -n ${this.namespace} -f "${path.resolve(pathToFile)}"`);
110
+ }
111
+
112
+ getDevWorkspaceYamlConfiguration(): ShellString {
113
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL}`);
114
+ return ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} get dw ${this.workspaceName} -n ${this.namespace} -o yaml`);
115
+ }
116
+
117
+ waitDevWorkspace(timeout: number = 360): ShellString {
118
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - wait till workspace ready.`);
119
+ const output: ShellString = ShellExecutor.execWithLog(
120
+ `${this.KUBERNETES_COMMAND_LINE_TOOL} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`
121
+ );
122
+ this.getPodAndContainerNames();
123
+ return output;
124
+ }
125
+
126
+ createNamespace(): void {
127
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - create namespace "${this.namespace}".`);
128
+ ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} create namespace ${this.namespace}`);
129
+ }
130
+
131
+ createProject(projectName: string): void {
132
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - create new project "${projectName}".`);
133
+ ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} new-project ${projectName} -n ${this.namespace}`);
134
+ }
135
+
136
+ deleteProject(projectName: string): void {
137
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - delete "${projectName}".`);
138
+ ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete project ${projectName} -n ${this.namespace}`);
139
+ }
140
+
141
+ private getPodAndContainerNames(): void {
142
+ KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
143
+ KubernetesCommandLineToolsExecutor.container = this.getContainerName();
144
+ }
145
+
146
+ private isUserLoggedIn(): boolean {
147
+ const whoamiCommandOutput: ShellString = ShellExecutor.execWithLog('oc whoami && oc whoami --show-server=true');
148
+
149
+ return (
150
+ whoamiCommandOutput.stdout.includes(OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME) &&
151
+ whoamiCommandOutput.stdout.includes(this.getServerUrl())
152
+ );
153
+ }
154
+
155
+ private setNamespace(_namespace: string | undefined): string {
156
+ _namespace =
157
+ _namespace !== undefined
158
+ ? _namespace
159
+ : BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('devspaces')
160
+ ? OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-devspaces'
161
+ : BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.includes('che')
162
+ ? OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME + '-che'
163
+ : 'default';
164
+ return _namespace;
165
+ }
166
+
167
+ private getServerUrl(): string {
168
+ Logger.debug(`${this.KUBERNETES_COMMAND_LINE_TOOL} - get server api url.`);
169
+ return BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL.replace('devspaces.apps', 'api') + ':6443';
170
+ }
152
171
  }
153
172
 
173
+ // eslint-disable-next-line no-redeclare
154
174
  export namespace KubernetesCommandLineToolsExecutor {
155
- export class ContainerTerminal extends KubernetesCommandLineToolsExecutor {
156
- constructor(cluster: KubernetesCommandLineToolsExecutor) {
157
- super(cluster.getWorkspaceName, cluster.getNamespace);
158
- }
159
-
160
- ls(path: string = ''): ShellString {
161
- return this.executeCommand('ls ' + path);
162
- }
163
-
164
- pwd(): ShellString {
165
- return this.executeCommand('pwd');
166
- }
167
-
168
- cd(path: string): ShellString {
169
- return this.executeCommand('cd ' + path);
170
- }
171
-
172
- gitClone(repository: string): ShellString {
173
- return this.executeCommand('git clone ' + repository);
174
- }
175
-
176
- removeFolder(path: string): ShellString {
177
- return this.executeCommand('rm -rf ' + path);
178
- }
179
-
180
- getEnvValue(envName: string): string {
181
- envName = envName.replace(/[${}]/g, '');
182
- const output: ShellString = this.executeCommand(`env | grep ${envName}`);
183
- return output.stderr
184
- ? output.stderr
185
- : output.stdout
186
- .substring(output.stdout.lastIndexOf('=') + 1)
187
- .replace('\n', '');
188
- }
189
- }
175
+ export class ContainerTerminal extends KubernetesCommandLineToolsExecutor {
176
+ constructor(cluster: KubernetesCommandLineToolsExecutor) {
177
+ super(cluster.getWorkspaceName, cluster.getNamespace);
178
+ }
179
+
180
+ ls(path: string = ''): ShellString {
181
+ return this.executeCommand('ls ' + path);
182
+ }
183
+
184
+ pwd(): ShellString {
185
+ return this.executeCommand('pwd');
186
+ }
187
+
188
+ cd(path: string): ShellString {
189
+ return this.executeCommand('cd ' + path);
190
+ }
191
+
192
+ gitClone(repository: string): ShellString {
193
+ return this.executeCommand('git clone ' + repository);
194
+ }
195
+
196
+ removeFolder(path: string): ShellString {
197
+ return this.executeCommand('rm -rf ' + path);
198
+ }
199
+
200
+ getEnvValue(envName: string): string {
201
+ envName = envName.replace(/[${}]/g, '');
202
+ const output: ShellString = this.executeCommand(`env | grep ${envName}`);
203
+ return output.stderr ? output.stderr : output.stdout.substring(output.stdout.lastIndexOf('=') + 1).replace('\n', '');
204
+ }
205
+ }
190
206
  }
package/utils/Logger.ts CHANGED
@@ -1,5 +1,5 @@
1
- /*********************************************************************
2
- * Copyright (c) 2019-2023 Red Hat, Inc.
1
+ /** *******************************************************************
2
+ * copyright (c) 2019-2023 Red Hat, Inc.
3
3
  *
4
4
  * This program and the accompanying materials are made
5
5
  * available under the terms of the Eclipse Public License 2.0
@@ -7,137 +7,114 @@
7
7
  *
8
8
  * SPDX-License-Identifier: EPL-2.0
9
9
  **********************************************************************/
10
- import { ReporterConstants } from '../constants/ReporterConstants';
10
+ import { REPORTER_CONSTANTS } from '../constants/REPORTER_CONSTANTS';
11
11
 
12
12
  export abstract class Logger {
13
- /**
14
- * Uses for logging of fatal errors.
15
- * @param text log text
16
- * @param indentLevel log level
17
- */
18
- static error(text: string = '', indentLevel: number = 1): void {
19
- const callerInfo: string = this.getCallerInfo();
20
- const logLevelSymbol: string = '[ERROR] ';
21
- this.logText(
22
- indentLevel,
23
- logLevelSymbol,
24
- `${this.getFullMessage(callerInfo, text)}`
25
- );
26
- }
13
+ /**
14
+ * uses for logging of fatal errors.
15
+ * @param text log text
16
+ * @param indentLevel log level
17
+ */
18
+ static error(text: string = '', indentLevel: number = 1): void {
19
+ const callerInfo: string = this.getCallerInfo();
20
+ const logLevelSymbol: string = '[ERROR] ';
21
+ this.logText(indentLevel, logLevelSymbol, `${this.getFullMessage(callerInfo, text)}`);
22
+ }
27
23
 
28
- /**
29
- * Uses for logging of recoverable errors and general warnings.
30
- * @param text log text
31
- * @param indentLevel log level
32
- */
33
- static warn(text: string = '', indentLevel: number = 1): void {
34
- if (ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR') {
35
- return;
36
- }
37
- const callerInfo: string = this.getCallerInfo();
38
- const logLevelSymbol: string = '[WARN] ';
39
- this.logText(
40
- indentLevel,
41
- logLevelSymbol,
42
- `${this.getFullMessage(callerInfo, text)}`
43
- );
44
- }
24
+ /**
25
+ * uses for logging of recoverable errors and general warnings.
26
+ * @param text log text
27
+ * @param indentLevel log level
28
+ */
29
+ static warn(text: string = '', indentLevel: number = 1): void {
30
+ if (REPORTER_CONSTANTS.TS_SELENIUM_LOG_LEVEL === 'ERROR') {
31
+ return;
32
+ }
33
+ const callerInfo: string = this.getCallerInfo();
34
+ const logLevelSymbol: string = '[WARN] ';
35
+ this.logText(indentLevel, logLevelSymbol, `${this.getFullMessage(callerInfo, text)}`);
36
+ }
45
37
 
46
- /**
47
- * Uses for logging of the public methods of the pageobjects.
48
- * @param text log text
49
- * @param indentLevel log level
50
- */
51
- static info(text: string = '', indentLevel: number = 3): void {
52
- if (
53
- ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
54
- ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'WARN'
55
- ) {
56
- return;
57
- }
58
- const callerInfo: string = this.getCallerInfo();
59
- const logLevelSymbol: string = '• ';
60
- this.logText(
61
- indentLevel,
62
- logLevelSymbol,
63
- `${this.getFullMessage(callerInfo, text)}`
64
- );
65
- }
38
+ /**
39
+ * uses for logging of the public methods of the pageobjects.
40
+ * @param text log text
41
+ * @param indentLevel log level
42
+ */
43
+ static info(text: string = '', indentLevel: number = 3): void {
44
+ if (REPORTER_CONSTANTS.TS_SELENIUM_LOG_LEVEL === 'ERROR' || REPORTER_CONSTANTS.TS_SELENIUM_LOG_LEVEL === 'WARN') {
45
+ return;
46
+ }
47
+ const callerInfo: string = this.getCallerInfo();
48
+ const logLevelSymbol: string = '• ';
49
+ this.logText(indentLevel, logLevelSymbol, `${this.getFullMessage(callerInfo, text)}`);
50
+ }
66
51
 
67
- /**
68
- * Uses for logging of the public methods of the pageobjects.
69
- * @param text log text
70
- * @param indentLevel log level
71
- */
72
- static debug(text: string = '', indentLevel: number = 5): void {
73
- if (
74
- ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
75
- ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'WARN' ||
76
- ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'INFO'
77
- ) {
78
- return;
79
- }
80
- const callerInfo: string = this.getCallerInfo();
81
- const logLevelSymbol: string = '▼ ';
82
- this.logText(
83
- indentLevel,
84
- logLevelSymbol,
85
- `${this.getFullMessage(callerInfo, text)}`
86
- );
87
- }
52
+ /**
53
+ * uses for logging of the public methods of the pageobjects.
54
+ * @param text log text
55
+ * @param indentLevel log level
56
+ */
57
+ static debug(text: string = '', indentLevel: number = 5): void {
58
+ if (
59
+ REPORTER_CONSTANTS.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
60
+ REPORTER_CONSTANTS.TS_SELENIUM_LOG_LEVEL === 'WARN' ||
61
+ REPORTER_CONSTANTS.TS_SELENIUM_LOG_LEVEL === 'INFO'
62
+ ) {
63
+ return;
64
+ }
65
+ const callerInfo: string = this.getCallerInfo();
66
+ const logLevelSymbol: string = '▼ ';
67
+ this.logText(indentLevel, logLevelSymbol, `${this.getFullMessage(callerInfo, text)}`);
68
+ }
88
69
 
89
- /**
90
- * Uses for logging of the public methods of the {@link DriverHelper} or
91
- * private methods inside of pageobjects.
92
- * @param text log text
93
- * @param indentLevel log level
94
- */
95
- static trace(text: string = '', indentLevel: number = 6): void {
96
- if (
97
- ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
98
- ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'WARN' ||
99
- ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'INFO' ||
100
- ReporterConstants.TS_SELENIUM_LOG_LEVEL === 'DEBUG'
101
- ) {
102
- return;
103
- }
104
- const callerInfo: string = this.getCallerInfo();
105
- const logLevelSymbol: string = '‣ ';
106
- this.logText(
107
- indentLevel,
108
- logLevelSymbol,
109
- `${this.getFullMessage(callerInfo, text)}`
110
- );
111
- }
70
+ /**
71
+ * uses for logging of the public methods of the {@link DriverHelper} or
72
+ * private methods inside of pageobjects.
73
+ * @param text log text
74
+ * @param indentLevel log level
75
+ */
76
+ static trace(text: string = '', indentLevel: number = 6): void {
77
+ if (
78
+ REPORTER_CONSTANTS.TS_SELENIUM_LOG_LEVEL === 'ERROR' ||
79
+ REPORTER_CONSTANTS.TS_SELENIUM_LOG_LEVEL === 'WARN' ||
80
+ REPORTER_CONSTANTS.TS_SELENIUM_LOG_LEVEL === 'INFO' ||
81
+ REPORTER_CONSTANTS.TS_SELENIUM_LOG_LEVEL === 'DEBUG'
82
+ ) {
83
+ return;
84
+ }
85
+ const callerInfo: string = this.getCallerInfo();
86
+ const logLevelSymbol: string = '‣ ';
87
+ this.logText(indentLevel, logLevelSymbol, `${this.getFullMessage(callerInfo, text)}`);
88
+ }
112
89
 
113
- private static getFullMessage(callerInfo: string, text: string): string {
114
- return `${callerInfo}${this.separator(text, callerInfo)}${text}`;
115
- }
90
+ private static getFullMessage(callerInfo: string, text: string): string {
91
+ return `${callerInfo}${this.separator(text, callerInfo)}${text}`;
92
+ }
116
93
 
117
- private static logText(messageIndentationLevel: number, logLevelSymbol: string, text: string): void {
118
- if (text) {
119
- // start group for every level
120
- for (let i: number = 0; i < messageIndentationLevel; i++) {
121
- console.group();
122
- }
123
- // print the trimmed text
124
- // if multiline, the message should be properly padded
125
- console.log(logLevelSymbol + text);
126
- // end group for every level
127
- for (let i: number = 0; i < messageIndentationLevel; i++) {
128
- console.groupEnd();
129
- }
130
- }
131
- }
94
+ private static logText(messageIndentationLevel: number, logLevelSymbol: string, text: string): void {
95
+ if (text) {
96
+ // start group for every level
97
+ for (let i: number = 0; i < messageIndentationLevel; i++) {
98
+ console.group();
99
+ }
100
+ // print the trimmed text
101
+ // if multiline, the message should be properly padded
102
+ console.log(logLevelSymbol + text);
103
+ // end group for every level
104
+ for (let i: number = 0; i < messageIndentationLevel; i++) {
105
+ console.groupEnd();
106
+ }
107
+ }
108
+ }
132
109
 
133
- private static getCallerInfo(): string {
134
- const e: Error = new Error();
135
- const stack: string[] = e.stack ? e.stack.split('\n') : [];
136
- // " at functionName ( ..." => "functionName"
137
- return stack[3].includes('.<anonymous') ? '' : stack[3].replace(/^\s+at\s+(.+?)\s.+/g, '$1');
138
- }
110
+ private static getCallerInfo(): string {
111
+ const e: Error = new Error();
112
+ const stack: string[] = e.stack ? e.stack.split('\n') : [];
113
+ // " at functionName ( ..." => "functionName"
114
+ return stack[3].includes('.<anonymous') ? '' : stack[3].replace(/^\s+at\s+(.+?)\s.+/g, '$1');
115
+ }
139
116
 
140
- private static separator(text: string, caller: string): string {
141
- return text ? caller ? ' - ' : '' : '';
142
- }
117
+ private static separator(text: string, caller: string): string {
118
+ return text ? (caller ? ' - ' : '') : '';
119
+ }
143
120
  }