@eclipse-che/che-e2e 7.74.0-dev-1d09cb7 → 7.74.0-dev-aace77a

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 (229) hide show
  1. package/.eslintignore +10 -0
  2. package/.eslintrc.js +197 -0
  3. package/.prettierignore +10 -0
  4. package/.prettierrc.json +10 -0
  5. package/CODE_STYLE.md +144 -0
  6. package/README.md +47 -47
  7. package/configs/inversify.config.ts +39 -14
  8. package/configs/inversify.types.ts +44 -30
  9. package/configs/mocharc.ts +21 -24
  10. package/constants/API_TEST_CONSTANTS.ts +67 -0
  11. package/constants/BASE_TEST_CONSTANTS.ts +80 -0
  12. package/constants/CHROME_DRIVER_CONSTANTS.ts +42 -0
  13. package/constants/FACTORY_TEST_CONSTANTS.ts +61 -0
  14. package/constants/MONACO_CONSTANTS.ts +25 -0
  15. package/constants/OAUTH_CONSTANTS.ts +67 -0
  16. package/constants/PLUGIN_TEST_CONSTANTS.ts +15 -0
  17. package/constants/REPORTER_CONSTANTS.ts +53 -0
  18. package/constants/TIMEOUT_CONSTANTS.ts +131 -0
  19. package/dist/configs/inversify.config.js +36 -9
  20. package/dist/configs/inversify.config.js.map +1 -1
  21. package/dist/configs/inversify.types.js +19 -5
  22. package/dist/configs/inversify.types.js.map +1 -1
  23. package/dist/configs/mocharc.js +13 -16
  24. package/dist/configs/mocharc.js.map +1 -1
  25. package/dist/constants/{APITestConstants.js → API_TEST_CONSTANTS.js} +12 -12
  26. package/dist/constants/API_TEST_CONSTANTS.js.map +1 -0
  27. package/dist/constants/{BaseTestConstants.js → BASE_TEST_CONSTANTS.js} +16 -16
  28. package/dist/constants/BASE_TEST_CONSTANTS.js.map +1 -0
  29. package/dist/constants/CHROME_DRIVER_CONSTANTS.js +36 -0
  30. package/dist/constants/CHROME_DRIVER_CONSTANTS.js.map +1 -0
  31. package/dist/constants/{FactoryTestConstants.js → FACTORY_TEST_CONSTANTS.js} +14 -13
  32. package/dist/constants/FACTORY_TEST_CONSTANTS.js.map +1 -0
  33. package/dist/constants/{MonacoConstants.js → MONACO_CONSTANTS.js} +7 -7
  34. package/dist/constants/MONACO_CONSTANTS.js.map +1 -0
  35. package/dist/constants/{OAuthConstants.js → OAUTH_CONSTANTS.js} +14 -14
  36. package/dist/constants/OAUTH_CONSTANTS.js.map +1 -0
  37. package/dist/constants/{PluginsTestConstants.js → PLUGIN_TEST_CONSTANTS.js} +7 -7
  38. package/dist/constants/PLUGIN_TEST_CONSTANTS.js.map +1 -0
  39. package/dist/constants/{ReporterConstants.js → REPORTER_CONSTANTS.js} +12 -12
  40. package/dist/constants/REPORTER_CONSTANTS.js.map +1 -0
  41. package/dist/constants/{TimeoutConstants.js → TIMEOUT_CONSTANTS.js} +24 -24
  42. package/dist/constants/TIMEOUT_CONSTANTS.js.map +1 -0
  43. package/dist/driver/ChromeDriver.js +12 -22
  44. package/dist/driver/ChromeDriver.js.map +1 -1
  45. package/dist/index.js +18 -12
  46. package/dist/index.js.map +1 -1
  47. package/dist/pageobjects/dashboard/CreateWorkspace.js +15 -15
  48. package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
  49. package/dist/pageobjects/dashboard/Dashboard.js +20 -21
  50. package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
  51. package/dist/pageobjects/dashboard/Workspaces.js +55 -60
  52. package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
  53. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +58 -48
  54. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
  55. package/dist/pageobjects/git-providers/OauthPage.js +22 -20
  56. package/dist/pageobjects/git-providers/OauthPage.js.map +1 -1
  57. package/dist/pageobjects/ide/CheCodeLocatorLoader.js +26 -12
  58. package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -1
  59. package/dist/pageobjects/login/interfaces/ICheLoginPage.js +2 -2
  60. package/dist/pageobjects/login/interfaces/IOcpLoginPage.js +2 -2
  61. package/dist/pageobjects/login/kubernetes/DexLoginPage.js +14 -14
  62. package/dist/pageobjects/login/kubernetes/DexLoginPage.js.map +1 -1
  63. package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js +7 -7
  64. package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js.map +1 -1
  65. package/dist/pageobjects/login/openshift/OcpLoginPage.js +24 -28
  66. package/dist/pageobjects/login/openshift/OcpLoginPage.js.map +1 -1
  67. package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js +13 -16
  68. package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js.map +1 -1
  69. package/dist/pageobjects/login/openshift/OcpUserLoginPage.js +9 -9
  70. package/dist/pageobjects/login/openshift/OcpUserLoginPage.js.map +1 -1
  71. package/dist/pageobjects/login/openshift/RedHatLoginPage.js +19 -23
  72. package/dist/pageobjects/login/openshift/RedHatLoginPage.js.map +1 -1
  73. package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js +20 -19
  74. package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js.map +1 -1
  75. package/dist/pageobjects/openshift/OcpApplicationPage.js +11 -11
  76. package/dist/pageobjects/openshift/OcpApplicationPage.js.map +1 -1
  77. package/dist/pageobjects/openshift/OcpImportFromGitPage.js +24 -24
  78. package/dist/pageobjects/openshift/OcpImportFromGitPage.js.map +1 -1
  79. package/dist/pageobjects/openshift/OcpMainPage.js +30 -30
  80. package/dist/pageobjects/openshift/OcpMainPage.js.map +1 -1
  81. package/dist/specs/MochaHooks.js +33 -27
  82. package/dist/specs/MochaHooks.js.map +1 -1
  83. package/dist/specs/SmokeTest.spec.js +17 -17
  84. package/dist/specs/SmokeTest.spec.js.map +1 -1
  85. package/dist/specs/api/ContainerOverridesAPI.spec.js +8 -6
  86. package/dist/specs/api/ContainerOverridesAPI.spec.js.map +1 -1
  87. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +27 -24
  88. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +1 -1
  89. package/dist/specs/api/EmptyWorkspaceAPI.spec.js +17 -17
  90. package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +1 -1
  91. package/dist/specs/api/PodOverridesAPI.spec.js +10 -8
  92. package/dist/specs/api/PodOverridesAPI.spec.js.map +1 -1
  93. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js +10 -10
  94. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js.map +1 -1
  95. package/dist/specs/dashboard-samples/Quarkus.spec.js +13 -13
  96. package/dist/specs/dashboard-samples/Quarkus.spec.js.map +1 -1
  97. package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js +52 -52
  98. package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js.map +1 -1
  99. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +23 -19
  100. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -1
  101. package/dist/specs/factory/Factory.spec.js +38 -41
  102. package/dist/specs/factory/Factory.spec.js.map +1 -1
  103. package/dist/specs/factory/NoSetupRepoFactory.spec.js +52 -50
  104. package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
  105. package/dist/specs/factory/RefusedOAuthFactory.spec.js +49 -51
  106. package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
  107. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +45 -42
  108. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +1 -1
  109. package/dist/tests-library/LoginTests.js +13 -13
  110. package/dist/tests-library/LoginTests.js.map +1 -1
  111. package/dist/tests-library/ProjectAndFileTests.js +9 -7
  112. package/dist/tests-library/ProjectAndFileTests.js.map +1 -1
  113. package/dist/tests-library/WorkspaceHandlingTests.js +22 -19
  114. package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
  115. package/dist/utils/BrowserTabsUtil.js +21 -21
  116. package/dist/utils/BrowserTabsUtil.js.map +1 -1
  117. package/dist/utils/CheReporter.js +91 -65
  118. package/dist/utils/CheReporter.js.map +1 -1
  119. package/dist/utils/DevWorkspaceConfigurationHelper.js +34 -15
  120. package/dist/utils/DevWorkspaceConfigurationHelper.js.map +1 -1
  121. package/dist/utils/DevfilesRegistryHelper.js +34 -18
  122. package/dist/utils/DevfilesRegistryHelper.js.map +1 -1
  123. package/dist/utils/DriverHelper.js +73 -68
  124. package/dist/utils/DriverHelper.js.map +1 -1
  125. package/dist/utils/IContextParams.js +12 -0
  126. package/dist/utils/IContextParams.js.map +1 -0
  127. package/dist/utils/IKubernetesCommandLineToolsExecutor.js +3 -0
  128. package/dist/utils/IKubernetesCommandLineToolsExecutor.js.map +1 -0
  129. package/dist/utils/KubernetesCommandLineToolsExecutor.js +146 -107
  130. package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -1
  131. package/dist/utils/Logger.js +18 -19
  132. package/dist/utils/Logger.js.map +1 -1
  133. package/dist/utils/ScreenCatcher.js +26 -16
  134. package/dist/utils/ScreenCatcher.js.map +1 -1
  135. package/dist/utils/ShellExecutor.js +29 -9
  136. package/dist/utils/ShellExecutor.js.map +1 -1
  137. package/dist/utils/StringUtil.js +19 -9
  138. package/dist/utils/StringUtil.js.map +1 -1
  139. package/dist/utils/request-handlers/CheApiRequestHandler.js +29 -29
  140. package/dist/utils/request-handlers/CheApiRequestHandler.js.map +1 -1
  141. package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js +12 -8
  142. package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
  143. package/dist/utils/request-handlers/headers/IAuthorizationHeaderHandler.js +2 -2
  144. package/dist/utils/workspace/ApiUrlResolver.js +5 -5
  145. package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
  146. package/dist/utils/workspace/ITestWorkspaceUtil.js +2 -2
  147. package/dist/utils/workspace/TestWorkspaceUtil.js +25 -23
  148. package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
  149. package/dist/utils/workspace/WorkspaceStatus.js +2 -2
  150. package/dist/utils/workspace/WorkspaceStatus.js.map +1 -1
  151. package/driver/ChromeDriver.ts +45 -58
  152. package/driver/IDriver.ts +3 -3
  153. package/index.ts +11 -9
  154. package/package.json +59 -49
  155. package/pageobjects/dashboard/CreateWorkspace.ts +65 -55
  156. package/pageobjects/dashboard/Dashboard.ts +100 -100
  157. package/pageobjects/dashboard/Workspaces.ts +210 -186
  158. package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +153 -131
  159. package/pageobjects/git-providers/OauthPage.ts +177 -166
  160. package/pageobjects/ide/CheCodeLocatorLoader.ts +51 -46
  161. package/pageobjects/login/interfaces/ICheLoginPage.ts +3 -3
  162. package/pageobjects/login/interfaces/IOcpLoginPage.ts +3 -3
  163. package/pageobjects/login/kubernetes/DexLoginPage.ts +31 -30
  164. package/pageobjects/login/kubernetes/KubernetesLoginPage.ts +15 -14
  165. package/pageobjects/login/openshift/OcpLoginPage.ts +51 -56
  166. package/pageobjects/login/openshift/OcpRedHatLoginPage.ts +27 -27
  167. package/pageobjects/login/openshift/OcpUserLoginPage.ts +15 -18
  168. package/pageobjects/login/openshift/RedHatLoginPage.ts +49 -46
  169. package/pageobjects/login/openshift/RegularUserOcpCheLoginPage.ts +43 -34
  170. package/pageobjects/openshift/OcpApplicationPage.ts +21 -19
  171. package/pageobjects/openshift/OcpImportFromGitPage.ts +68 -68
  172. package/pageobjects/openshift/OcpMainPage.ts +69 -69
  173. package/specs/MochaHooks.ts +59 -52
  174. package/specs/SmokeTest.spec.ts +47 -45
  175. package/specs/api/ContainerOverridesAPI.spec.ts +39 -26
  176. package/specs/api/DevfileAcceptanceTestAPI.spec.ts +110 -97
  177. package/specs/api/EmptyWorkspaceAPI.spec.ts +67 -58
  178. package/specs/api/PodOverridesAPI.spec.ts +48 -34
  179. package/specs/dashboard-samples/EmptyWorkspace.spec.ts +36 -36
  180. package/specs/dashboard-samples/Quarkus.spec.ts +41 -40
  181. package/specs/dashboard-samples/RecommendedExtensions.spec.ts +202 -183
  182. package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +85 -75
  183. package/specs/factory/Factory.spec.ts +184 -178
  184. package/specs/factory/NoSetupRepoFactory.spec.ts +233 -219
  185. package/specs/factory/RefusedOAuthFactory.spec.ts +223 -211
  186. package/specs/miscellaneous/PredefinedNamespace.spec.ts +70 -64
  187. package/tests-library/LoginTests.ts +34 -32
  188. package/tests-library/ProjectAndFileTests.ts +21 -18
  189. package/tests-library/WorkspaceHandlingTests.ts +98 -89
  190. package/tsconfig.json +15 -15
  191. package/utils/BrowserTabsUtil.ts +78 -74
  192. package/utils/CheReporter.ts +159 -157
  193. package/utils/DevWorkspaceConfigurationHelper.ts +63 -69
  194. package/utils/DevfilesRegistryHelper.ts +71 -57
  195. package/utils/DriverHelper.ts +728 -700
  196. package/utils/IContextParams.ts +26 -0
  197. package/utils/IKubernetesCommandLineToolsExecutor.ts +42 -0
  198. package/utils/KubernetesCommandLineToolsExecutor.ts +231 -183
  199. package/utils/Logger.ts +102 -125
  200. package/utils/ScreenCatcher.ts +57 -46
  201. package/utils/ShellExecutor.ts +23 -12
  202. package/utils/StringUtil.ts +49 -36
  203. package/utils/request-handlers/CheApiRequestHandler.ts +91 -88
  204. package/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +32 -21
  205. package/utils/request-handlers/headers/IAuthorizationHeaderHandler.ts +3 -3
  206. package/utils/workspace/ApiUrlResolver.ts +31 -26
  207. package/utils/workspace/ITestWorkspaceUtil.ts +31 -31
  208. package/utils/workspace/TestWorkspaceUtil.ts +152 -145
  209. package/utils/workspace/WorkspaceStatus.ts +5 -5
  210. package/constants/APITestConstants.ts +0 -57
  211. package/constants/BaseTestConstants.ts +0 -68
  212. package/constants/ChromeDriverConstants.ts +0 -46
  213. package/constants/FactoryTestConstants.ts +0 -51
  214. package/constants/MonacoConstants.ts +0 -22
  215. package/constants/OAuthConstants.ts +0 -57
  216. package/constants/PluginsTestConstants.ts +0 -15
  217. package/constants/ReporterConstants.ts +0 -45
  218. package/constants/TimeoutConstants.ts +0 -113
  219. package/dist/constants/APITestConstants.js.map +0 -1
  220. package/dist/constants/BaseTestConstants.js.map +0 -1
  221. package/dist/constants/ChromeDriverConstants.js +0 -44
  222. package/dist/constants/ChromeDriverConstants.js.map +0 -1
  223. package/dist/constants/FactoryTestConstants.js.map +0 -1
  224. package/dist/constants/MonacoConstants.js.map +0 -1
  225. package/dist/constants/OAuthConstants.js.map +0 -1
  226. package/dist/constants/PluginsTestConstants.js.map +0 -1
  227. package/dist/constants/ReporterConstants.js.map +0 -1
  228. package/dist/constants/TimeoutConstants.js.map +0 -1
  229. package/tslint.json +0 -126
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
  }
@@ -1,5 +1,5 @@
1
- /*********************************************************************
2
- * Copyright (c) 2021-2023 Red Hat, Inc.
1
+ /** *******************************************************************
2
+ * copyright (c) 2021-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
@@ -14,61 +14,72 @@ import { CLASSES } from '../configs/inversify.types';
14
14
  import { DriverHelper } from './DriverHelper';
15
15
  import { error } from 'selenium-webdriver';
16
16
  import { StringUtil } from './StringUtil';
17
- import { ReporterConstants } from '../constants/ReporterConstants';
17
+ import { REPORTER_CONSTANTS } from '../constants/REPORTER_CONSTANTS';
18
18
 
19
19
  @injectable()
20
20
  export class ScreenCatcher {
21
- constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }
21
+ constructor(
22
+ @inject(CLASSES.DriverHelper)
23
+ private readonly driverHelper: DriverHelper
24
+ ) {}
22
25
 
23
- async catchMethodScreen(methodName: string, methodIndex: number, screenshotIndex: number): Promise<void> {
24
- const executionScreenCastDir: string = `${ReporterConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencast`;
25
- const executionScreenCastErrorsDir: string = `${ReporterConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencastErrors`;
26
- const formattedMethodIndex: string = new Intl.NumberFormat('en-us', { minimumIntegerDigits: 3 }).format(methodIndex);
27
- const formattedScreenshotIndex: string = new Intl.NumberFormat('en-us', { minimumIntegerDigits: 5 }).format(screenshotIndex).replace(/,/g, '');
26
+ async catchMethodScreen(methodName: string, methodIndex: number, screenshotIndex: number): Promise<void> {
27
+ const executionScreenCastDir: string = `${REPORTER_CONSTANTS.TS_SELENIUM_REPORT_FOLDER}/executionScreencast`;
28
+ const executionScreenCastErrorsDir: string = `${REPORTER_CONSTANTS.TS_SELENIUM_REPORT_FOLDER}/executionScreencastErrors`;
29
+ const formattedMethodIndex: string = new Intl.NumberFormat('en-us', {
30
+ minimumIntegerDigits: 3
31
+ }).format(methodIndex);
32
+ const formattedScreenshotIndex: string = new Intl.NumberFormat('en-us', { minimumIntegerDigits: 5 })
33
+ .format(screenshotIndex)
34
+ .replace(/,/g, '');
28
35
 
29
- if (!fs.existsSync(ReporterConstants.TS_SELENIUM_REPORT_FOLDER)) {
30
- fs.mkdirSync(ReporterConstants.TS_SELENIUM_REPORT_FOLDER);
31
- }
36
+ if (!fs.existsSync(REPORTER_CONSTANTS.TS_SELENIUM_REPORT_FOLDER)) {
37
+ fs.mkdirSync(REPORTER_CONSTANTS.TS_SELENIUM_REPORT_FOLDER);
38
+ }
32
39
 
33
- if (!fs.existsSync(executionScreenCastDir)) {
34
- fs.mkdirSync(executionScreenCastDir);
35
- }
40
+ if (!fs.existsSync(executionScreenCastDir)) {
41
+ fs.mkdirSync(executionScreenCastDir);
42
+ }
36
43
 
37
- const date: Date = new Date();
38
- const timeStr: string = date.toLocaleTimeString('en-us', { hour12: false }) + '.' + new Intl.NumberFormat('en-us', { minimumIntegerDigits: 3 }).format(date.getMilliseconds());
44
+ const date: Date = new Date();
45
+ const timeStr: string =
46
+ date.toLocaleTimeString('en-us', { hour12: false }) +
47
+ '.' +
48
+ new Intl.NumberFormat('en-us', { minimumIntegerDigits: 3 }).format(date.getMilliseconds());
39
49
 
40
- const screenshotPath: string = `${executionScreenCastDir}/${formattedMethodIndex}-${formattedScreenshotIndex}--(${StringUtil.sanitizeTitle(timeStr)})_${StringUtil.sanitizeTitle(methodName)}.png`;
50
+ const screenshotPath: string = `${executionScreenCastDir}/${formattedMethodIndex}-${formattedScreenshotIndex}--(${StringUtil.sanitizeTitle(
51
+ timeStr
52
+ )})_${StringUtil.sanitizeTitle(methodName)}.png`;
41
53
 
42
- try {
43
- await this.catchScreen(screenshotPath);
44
- } catch (err) {
45
- if (!fs.existsSync(executionScreenCastErrorsDir)) {
46
- fs.mkdirSync(executionScreenCastErrorsDir);
47
- }
54
+ try {
55
+ await this.catchScreen(screenshotPath);
56
+ } catch (err) {
57
+ if (!fs.existsSync(executionScreenCastErrorsDir)) {
58
+ fs.mkdirSync(executionScreenCastErrorsDir);
59
+ }
48
60
 
49
- let errorLogFilePath: string = screenshotPath.replace('.png', '.txt');
50
- errorLogFilePath = errorLogFilePath.replace(executionScreenCastDir, executionScreenCastErrorsDir);
51
- if (err instanceof error.IError) {
52
- await this.writeErrorLog(errorLogFilePath, err);
53
- }
54
- }
55
- }
61
+ let errorLogFilePath: string = screenshotPath.replace('.png', '.txt');
62
+ errorLogFilePath = errorLogFilePath.replace(executionScreenCastDir, executionScreenCastErrorsDir);
63
+ if (err instanceof error.IError) {
64
+ this.writeErrorLog(errorLogFilePath, err);
65
+ }
66
+ }
67
+ }
56
68
 
57
- async catchScreen(screenshotPath: string): Promise<void> {
58
- const screenshot: string = await this.driverHelper.getDriver().takeScreenshot();
59
- const screenshotStream: WriteStream = fs.createWriteStream(screenshotPath);
60
- screenshotStream.write(Buffer.from(screenshot, 'base64'));
61
- screenshotStream.end();
62
- }
69
+ async catchScreen(screenshotPath: string): Promise<void> {
70
+ const screenshot: string = await this.driverHelper.getDriver().takeScreenshot();
71
+ const screenshotStream: WriteStream = fs.createWriteStream(screenshotPath);
72
+ screenshotStream.write(Buffer.from(screenshot, 'base64'));
73
+ screenshotStream.end();
74
+ }
63
75
 
64
- async writeErrorLog(errorLogPath: string, err: error.IError): Promise<void> {
65
- console.log(`Failed to save screenshot, additional information in the ${errorLogPath}`);
66
-
67
- if (err.stack) {
68
- const screenshotStream: WriteStream = fs.createWriteStream(errorLogPath);
69
- screenshotStream.write(Buffer.from(err.stack, 'utf8'));
70
- screenshotStream.end();
71
- }
72
- }
76
+ writeErrorLog(errorLogPath: string, err: error.IError): void {
77
+ console.log(`Failed to save screenshot, additional information in the ${errorLogPath}`);
73
78
 
79
+ if (err.stack) {
80
+ const screenshotStream: WriteStream = fs.createWriteStream(errorLogPath);
81
+ screenshotStream.write(Buffer.from(err.stack, 'utf8'));
82
+ screenshotStream.end();
83
+ }
84
+ }
74
85
  }
@@ -1,17 +1,28 @@
1
- import { echo, exec, ShellString } from 'shelljs';
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 { exec, ShellString } from 'shelljs';
11
+ import { Logger } from './Logger';
12
+ import { injectable } from 'inversify';
2
13
 
14
+ @injectable()
3
15
  export class ShellExecutor {
16
+ wait(seconds: number): void {
17
+ this.executeCommand(`sleep ${seconds}s`);
18
+ }
4
19
 
5
- static wait(seconds: number): void {
6
- this.execWithLog(`sleep ${seconds}s`);
7
- }
20
+ curl(link: string): ShellString {
21
+ return this.executeCommand(`curl -k ${link}`);
22
+ }
8
23
 
9
- static curl(link: string): ShellString {
10
- return this.execWithLog(`curl -k ${link}`);
11
- }
12
-
13
- protected static execWithLog(command: string): ShellString {
14
- echo(command);
15
- return exec(command);
16
- }
24
+ executeCommand(command: string): ShellString {
25
+ Logger.debug(command);
26
+ return exec(command);
27
+ }
17
28
  }
@@ -1,5 +1,5 @@
1
- /*********************************************************************
2
- * Copyright (c) 2019 Red Hat, Inc.
1
+ /** *******************************************************************
2
+ * copyright (c) 2019 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
@@ -8,42 +8,55 @@
8
8
  * SPDX-License-Identifier: EPL-2.0
9
9
  **********************************************************************/
10
10
 
11
- import { injectable } from 'inversify';
12
11
  import { Logger } from './Logger';
12
+ import { injectable } from 'inversify';
13
13
 
14
14
  @injectable()
15
15
  export class StringUtil {
16
- /**
17
- * Method extracts a test repo name from git clone https url;
18
- * it splits the url into string[] by "/" or ".", deletes empty elements and elements that contains just "git", "main" or "tree" word, than returns the last one;
19
- * please, avoid to call the test repo as just "git" or to use dots in the name, like: github.com/user/git.git, github.com/user/name.with.dots.
20
- * @param url git https url (which using for "git clone")
21
- * @return project name
22
- */
23
- static getProjectNameFromGitUrl(url: string): string {
24
- Logger.debug(`${url}`);
25
- if (url.includes('?')) {
26
- url = url.substring(0, url.indexOf('?'));
27
- }
28
- if (url.includes('/tree/')) {
29
- url = url.split('/').slice(0, -2).join('/');
30
- }
31
- const projectName: string = url.split(/[\/.]/).filter((e: string) => !['git', ''].includes(e)).reverse()[0];
32
- Logger.debug(`${projectName}`);
33
- return projectName;
34
- }
35
-
36
- static sanitizeTitle(arg: string): string {
37
- return arg.replace(/\//g, '+').replace(/,/g, '.').replace(/:/g, '-').replace(/['"]/g, '').replace(/[^a-z0-9+\-.()\[\]_]/gi, '_');
38
- }
39
-
40
- /**
41
- * Replaces ${ENV}, $ENV to "$ENV"
42
- * @param command string command with environmental variables in unsupported format
43
- * @return updated command with environmental variables in supported format
44
- */
45
-
46
- static updateCommandEnvsToShStyle(command: string): string {
47
- return command.replace(/[{}]/g, '').replace(/(?<!")\${?[a-zA-Z0-9_+\-\s]+\b}?/gm, `"\$&"`);
48
- }
16
+ /**
17
+ * method extracts a test repo name from git clone https url;
18
+ * it splits the url into string[] by "/" or ".", deletes empty elements and elements that contains just "git", "main" or "tree" word, than returns the last one;
19
+ * please, avoid to call the test repo as just "git" or to use dots in the name, like: github.com/user/git.git, github.com/user/name.with.dots.
20
+ * @param url git https url (which using for "git clone")
21
+ * @return project name
22
+ */
23
+ static getProjectNameFromGitUrl(url: string): string {
24
+ Logger.debug(`${url}`);
25
+
26
+ if (url.includes('?')) {
27
+ url = url.substring(0, url.indexOf('?'));
28
+ }
29
+ if (url.includes('/tree/')) {
30
+ url = url.split('/').slice(0, -2).join('/');
31
+ }
32
+ const projectName: string = url
33
+ .split(/[\/.]/)
34
+ .filter((e: string): boolean => !['git', ''].includes(e))
35
+ .reverse()[0];
36
+ Logger.debug(`${projectName}`);
37
+ return projectName;
38
+ }
39
+
40
+ static sanitizeTitle(arg: string): string {
41
+ Logger.trace();
42
+
43
+ return arg
44
+ .replace(/\//g, '+')
45
+ .replace(/,/g, '.')
46
+ .replace(/:/g, '-')
47
+ .replace(/['"]/g, '')
48
+ .replace(/[^a-z0-9+\-.()\[\]_]/gi, '_');
49
+ }
50
+
51
+ /**
52
+ * replaces ${ENV}, $ENV to "$ENV"
53
+ * @param command string command with environmental variables in unsupported format
54
+ * @return updated command with environmental variables in supported format
55
+ */
56
+
57
+ static updateCommandEnvsToShStyle(command: string): string {
58
+ Logger.trace();
59
+
60
+ return command.replace(/[{}]/g, '').replace(/(?<!")\${?[a-zA-Z0-9_+\-\s]+\b}?/gm, '"$&"');
61
+ }
49
62
  }