@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
@@ -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
@@ -15,169 +15,171 @@ import * as rm from 'rimraf';
15
15
  import { logging } from 'selenium-webdriver';
16
16
  import { DriverHelper } from './DriverHelper';
17
17
  import { ScreenCatcher } from './ScreenCatcher';
18
- import { TimeoutConstants } from '../constants/TimeoutConstants';
18
+ import { TIMEOUT_CONSTANTS } from '../constants/TIMEOUT_CONSTANTS';
19
19
  import { Logger } from './Logger';
20
- import { e2eContainer } from '../configs/inversify.config';
21
20
  import { StringUtil } from './StringUtil';
22
- import { BaseTestConstants } from '../constants/BaseTestConstants';
23
- import { ChromeDriverConstants } from '../constants/ChromeDriverConstants';
24
- import { OAuthConstants } from '../constants/OAuthConstants';
25
- import { ReporterConstants } from '../constants/ReporterConstants';
26
- import { PluginsTestConstants } from '../constants/PluginsTestConstants';
27
-
28
- const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
29
- const screenCatcher: ScreenCatcher = e2eContainer.get(CLASSES.ScreenCatcher);
30
- let methodIndex: number = 0;
31
- let deleteScreencast: boolean = true;
32
-
21
+ import { BASE_TEST_CONSTANTS } from '../constants/BASE_TEST_CONSTANTS';
22
+ import { CHROME_DRIVER_CONSTANTS } from '../constants/CHROME_DRIVER_CONSTANTS';
23
+ import { OAUTH_CONSTANTS } from '../constants/OAUTH_CONSTANTS';
24
+ import { REPORTER_CONSTANTS } from '../constants/REPORTER_CONSTANTS';
25
+ import { PLUGIN_TEST_CONSTANTS } from '../constants/PLUGIN_TEST_CONSTANTS';
26
+ import { inject, injectable } from 'inversify';
27
+
28
+ @injectable()
33
29
  class CheReporter extends mocha.reporters.Spec {
34
-
35
- constructor(runner: mocha.Runner, options: mocha.MochaOptions) {
36
- super(runner, options);
37
-
38
- runner.on('start', async (): Promise<void> => {
39
- let launchInformation: string =
40
- `################## Launch Information ##################
41
-
42
- TS_SELENIUM_BASE_URL: ${BaseTestConstants.TS_SELENIUM_BASE_URL}
43
- TS_SELENIUM_HEADLESS: ${ChromeDriverConstants.TS_SELENIUM_HEADLESS}
44
- TS_SELENIUM_OCP_USERNAME: ${OAuthConstants.TS_SELENIUM_OCP_USERNAME}
45
- TS_SELENIUM_EDITOR: ${BaseTestConstants.TS_SELENIUM_EDITOR}
46
-
47
- TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME: ${BaseTestConstants.TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME}
48
- TS_SELENIUM_DELAY_BETWEEN_SCREENSHOTS: ${ReporterConstants.TS_SELENIUM_DELAY_BETWEEN_SCREENSHOTS}
49
- TS_SELENIUM_REPORT_FOLDER: ${ReporterConstants.TS_SELENIUM_REPORT_FOLDER}
50
- TS_SELENIUM_EXECUTION_SCREENCAST: ${ReporterConstants.TS_SELENIUM_EXECUTION_SCREENCAST}
51
- DELETE_SCREENCAST_IF_TEST_PASS: ${ReporterConstants.DELETE_SCREENCAST_IF_TEST_PASS}
52
- TS_SELENIUM_REMOTE_DRIVER_URL: ${ChromeDriverConstants.TS_SELENIUM_REMOTE_DRIVER_URL}
53
- DELETE_WORKSPACE_ON_FAILED_TEST: ${BaseTestConstants.DELETE_WORKSPACE_ON_FAILED_TEST}
54
- TS_SELENIUM_LOG_LEVEL: ${ReporterConstants.TS_SELENIUM_LOG_LEVEL}
55
- TS_SELENIUM_LAUNCH_FULLSCREEN: ${ChromeDriverConstants.TS_SELENIUM_LAUNCH_FULLSCREEN}
56
-
57
- TS_COMMON_DASHBOARD_WAIT_TIMEOUT: ${TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT}
58
- TS_SELENIUM_START_WORKSPACE_TIMEOUT: ${TimeoutConstants.TS_SELENIUM_START_WORKSPACE_TIMEOUT}
59
- TS_WAIT_LOADER_PRESENCE_TIMEOUT: ${TimeoutConstants.TS_WAIT_LOADER_PRESENCE_TIMEOUT}
60
-
61
- TS_SAMPLE_LIST: ${PluginsTestConstants.TS_SAMPLE_LIST}
30
+ private static methodIndex: number = 0;
31
+ private static deleteScreencast: boolean = true;
32
+
33
+ constructor(
34
+ runner: mocha.Runner,
35
+ options: mocha.MochaOptions,
36
+ @inject(CLASSES.DriverHelper)
37
+ private readonly driverHelper: DriverHelper,
38
+ @inject(CLASSES.ScreenCatcher)
39
+ private readonly screenCatcher: ScreenCatcher
40
+ ) {
41
+ super(runner, options);
42
+
43
+ runner.on('start', (): void => {
44
+ let launchInformation: string = `################## Launch Information ##################
45
+
46
+ TS_SELENIUM_BASE_URL: ${BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL}
47
+ TS_SELENIUM_HEADLESS: ${CHROME_DRIVER_CONSTANTS.TS_SELENIUM_HEADLESS}
48
+ TS_SELENIUM_OCP_USERNAME: ${OAUTH_CONSTANTS.TS_SELENIUM_OCP_USERNAME}
49
+ TS_SELENIUM_EDITOR: ${BASE_TEST_CONSTANTS.TS_SELENIUM_EDITOR}
50
+
51
+ TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME: ${BASE_TEST_CONSTANTS.TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME}
52
+ TS_SELENIUM_DELAY_BETWEEN_SCREENSHOTS: ${REPORTER_CONSTANTS.TS_SELENIUM_DELAY_BETWEEN_SCREENSHOTS}
53
+ TS_SELENIUM_REPORT_FOLDER: ${REPORTER_CONSTANTS.TS_SELENIUM_REPORT_FOLDER}
54
+ TS_SELENIUM_EXECUTION_SCREENCAST: ${REPORTER_CONSTANTS.TS_SELENIUM_EXECUTION_SCREENCAST}
55
+ DELETE_SCREENCAST_IF_TEST_PASS: ${REPORTER_CONSTANTS.DELETE_SCREENCAST_IF_TEST_PASS}
56
+ TS_SELENIUM_REMOTE_DRIVER_URL: ${CHROME_DRIVER_CONSTANTS.TS_SELENIUM_REMOTE_DRIVER_URL}
57
+ DELETE_WORKSPACE_ON_FAILED_TEST: ${BASE_TEST_CONSTANTS.DELETE_WORKSPACE_ON_FAILED_TEST}
58
+ TS_SELENIUM_LOG_LEVEL: ${REPORTER_CONSTANTS.TS_SELENIUM_LOG_LEVEL}
59
+ TS_SELENIUM_LAUNCH_FULLSCREEN: ${CHROME_DRIVER_CONSTANTS.TS_SELENIUM_LAUNCH_FULLSCREEN}
60
+
61
+ TS_COMMON_DASHBOARD_WAIT_TIMEOUT: ${TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT}
62
+ TS_SELENIUM_START_WORKSPACE_TIMEOUT: ${TIMEOUT_CONSTANTS.TS_SELENIUM_START_WORKSPACE_TIMEOUT}
63
+ TS_WAIT_LOADER_PRESENCE_TIMEOUT: ${TIMEOUT_CONSTANTS.TS_WAIT_LOADER_PRESENCE_TIMEOUT}
64
+
65
+ TS_SAMPLE_LIST: ${PLUGIN_TEST_CONSTANTS.TS_SAMPLE_LIST}
62
66
 
63
67
  ${process.env.MOCHA_DIRECTORY ? 'MOCHA_DIRECTORY: ' + process.env.MOCHA_DIRECTORY : 'MOCHA_DRIRECTORY is not set'}
64
68
  ${process.env.USERSTORY ? 'USERSTORY: ' + process.env.USERSTORY : 'USERSTORY is not set'}
65
69
  `;
66
70
 
67
- if (ReporterConstants.TS_SELENIUM_PRINT_TIMEOUT_VARIABLES) {
68
- launchInformation += `\n TS_SELENIUM_PRINT_TIMEOUT_VARIABLES is set to true: \n`;
69
- Object.entries(TimeoutConstants).forEach(
70
- ([key, value]) => launchInformation += `\n ${key}: ${value}`);
71
- } else {
72
- launchInformation += `\n to output timeout variables, set TS_SELENIUM_PRINT_TIMEOUT_VARIABLES to true`;
73
- }
74
-
75
- launchInformation += `\n ######################################################## \n`;
76
-
77
- console.log(launchInformation);
78
-
79
- rm.sync(ReporterConstants.TS_SELENIUM_REPORT_FOLDER);
80
- });
81
-
82
- runner.on('test', async function(test: mocha.Test): Promise<void> {
83
- if (!ReporterConstants.TS_SELENIUM_EXECUTION_SCREENCAST) {
84
- return;
85
- }
86
-
87
- methodIndex = methodIndex + 1;
88
- const currentMethodIndex: number = methodIndex;
89
- let iterationIndex: number = 1;
90
-
91
- while (!(test.state === 'passed' || test.state === 'failed')) {
92
- await screenCatcher.catchMethodScreen(test.title, currentMethodIndex, iterationIndex);
93
- iterationIndex = iterationIndex + 1;
94
-
95
- await driverHelper.wait(ReporterConstants.TS_SELENIUM_DELAY_BETWEEN_SCREENSHOTS);
96
- }
97
- });
98
-
99
- runner.on('pass', async (test: mocha.Test) => {
100
- if (BaseTestConstants.TS_LOAD_TESTS) {
101
- const loadTestReportFolder: string = ReporterConstants.TS_SELENIUM_LOAD_TEST_REPORT_FOLDER;
102
- const loadTestFilePath: string = loadTestReportFolder + '/load-test-results.txt';
103
- const report: string = test.title + ': ' + test.duration + '\r';
104
- if (!fs.existsSync(loadTestReportFolder)) {
105
- fs.mkdirSync(loadTestReportFolder);
106
- }
107
- fs.appendFileSync(loadTestFilePath, report);
108
- }
109
- });
110
-
111
- runner.on('end', async function(): Promise<void> {
112
- // ensure that fired events done
113
- await driverHelper.wait(5000);
114
-
115
- // close driver
116
- await driverHelper.getDriver().quit();
117
-
118
- // delete screencast folder if conditions matched
119
- if (deleteScreencast && ReporterConstants.DELETE_SCREENCAST_IF_TEST_PASS) {
120
- rm.sync(ReporterConstants.TS_SELENIUM_REPORT_FOLDER);
121
- }
122
- });
123
-
124
- runner.on('fail', async function(test: mocha.Test): Promise<void> {
125
- Logger.error(`CheReporter runner.on.fail: ${test.fullTitle()} failed after ${test.duration}ms`);
126
- // raise flag for keeping the screencast
127
- deleteScreencast = false;
128
-
129
- Logger.trace(`FullTitle:${test.fullTitle()}`);
130
- const testFullTitle: string = StringUtil.sanitizeTitle(test.fullTitle());
131
- Logger.trace(`FullTitleSanitized:${testFullTitle}`);
132
- Logger.trace(`TestTitle:${test.title}`);
133
- const testTitle: string = StringUtil.sanitizeTitle(test.title);
134
- Logger.trace(`TestTitleSanitized:${testTitle}`);
135
-
136
- const testReportDirPath: string = `${ReporterConstants.TS_SELENIUM_REPORT_FOLDER}/${testFullTitle}`;
137
- const screenshotFileName: string = `${testReportDirPath}/screenshot-${testTitle}.png`;
138
- const pageSourceFileName: string = `${testReportDirPath}/pagesource-${testTitle}.html`;
139
- const browserLogsFileName: string = `${testReportDirPath}/browserlogs-${testTitle}.txt`;
140
-
141
- // create reporter dir if not exist
142
- const reportDirExists: boolean = fs.existsSync(ReporterConstants.TS_SELENIUM_REPORT_FOLDER);
143
-
144
- if (!reportDirExists) {
145
- fs.mkdirSync(ReporterConstants.TS_SELENIUM_REPORT_FOLDER);
146
- }
147
-
148
- // create dir for failed test report if not exist
149
- const testReportDirExists: boolean = fs.existsSync(testReportDirPath);
150
-
151
- if (!testReportDirExists) {
152
- fs.mkdirSync(testReportDirPath);
153
- }
154
-
155
- // take screenshot and write to file
156
- const screenshot: string = await driverHelper.getDriver().takeScreenshot();
157
- const screenshotStream: WriteStream = fs.createWriteStream(screenshotFileName);
158
- screenshotStream.write(Buffer.from(screenshot, 'base64'));
159
- screenshotStream.end();
160
-
161
- // take page source and write to file
162
- const pageSource: string = await driverHelper.getDriver().getPageSource();
163
- const pageSourceStream: WriteStream = fs.createWriteStream(pageSourceFileName);
164
- pageSourceStream.write(Buffer.from(pageSource));
165
- pageSourceStream.end();
166
-
167
- // take browser console logs and write to file
168
- const browserLogsEntries: logging.Entry[] = await driverHelper.getDriver().manage().logs().get('browser');
169
- let browserLogs: string = '';
170
-
171
- browserLogsEntries.forEach(log => {
172
- browserLogs += `\"${log.level}\" \"${log.type}\" \"${log.message}\"\n`;
173
- });
174
-
175
- const browserLogsStream: WriteStream = fs.createWriteStream(browserLogsFileName);
176
- browserLogsStream.write(Buffer.from(browserLogs));
177
- browserLogsStream.end();
178
-
179
- });
180
- }
71
+ if (REPORTER_CONSTANTS.TS_SELENIUM_PRINT_TIMEOUT_VARIABLES) {
72
+ launchInformation += '\n TS_SELENIUM_PRINT_TIMEOUT_VARIABLES is set to true: \n';
73
+ Object.entries(TIMEOUT_CONSTANTS).forEach(([key, value]): string => (launchInformation += `\n ${key}: ${value}`));
74
+ } else {
75
+ launchInformation += '\n to output timeout variables, set TS_SELENIUM_PRINT_TIMEOUT_VARIABLES to true';
76
+ }
77
+
78
+ launchInformation += '\n ######################################################## \n';
79
+
80
+ console.log(launchInformation);
81
+
82
+ rm.sync(REPORTER_CONSTANTS.TS_SELENIUM_REPORT_FOLDER);
83
+ });
84
+
85
+ runner.on('test', async (test: mocha.Test): Promise<void> => {
86
+ if (!REPORTER_CONSTANTS.TS_SELENIUM_EXECUTION_SCREENCAST) {
87
+ return;
88
+ }
89
+
90
+ CheReporter.methodIndex = CheReporter.methodIndex + 1;
91
+ const currentMethodIndex: number = CheReporter.methodIndex;
92
+ let iterationIndex: number = 1;
93
+
94
+ while (!(test.state === 'passed' || test.state === 'failed')) {
95
+ await this.screenCatcher.catchMethodScreen(test.title, currentMethodIndex, iterationIndex);
96
+ iterationIndex = iterationIndex + 1;
97
+
98
+ await this.driverHelper.wait(REPORTER_CONSTANTS.TS_SELENIUM_DELAY_BETWEEN_SCREENSHOTS);
99
+ }
100
+ });
101
+
102
+ runner.on('pass', (test: mocha.Test): void => {
103
+ if (BASE_TEST_CONSTANTS.TS_LOAD_TESTS) {
104
+ const loadTestReportFolder: string = REPORTER_CONSTANTS.TS_SELENIUM_LOAD_TEST_REPORT_FOLDER;
105
+ const loadTestFilePath: string = loadTestReportFolder + '/load-test-results.txt';
106
+ const report: string = test.title + ': ' + test.duration + '\r';
107
+ if (!fs.existsSync(loadTestReportFolder)) {
108
+ fs.mkdirSync(loadTestReportFolder);
109
+ }
110
+ fs.appendFileSync(loadTestFilePath, report);
111
+ }
112
+ });
113
+
114
+ runner.on('end', async (): Promise<void> => {
115
+ // ensure that fired events done
116
+ await this.driverHelper.wait(5000);
117
+
118
+ // close driver
119
+ await this.driverHelper.getDriver().quit();
120
+
121
+ // delete screencast folder if conditions matched
122
+ if (CheReporter.deleteScreencast && REPORTER_CONSTANTS.DELETE_SCREENCAST_IF_TEST_PASS) {
123
+ rm.sync(REPORTER_CONSTANTS.TS_SELENIUM_REPORT_FOLDER);
124
+ }
125
+ });
126
+
127
+ runner.on('fail', async (test: mocha.Test): Promise<void> => {
128
+ Logger.error(`CheReporter runner.on.fail: ${test.fullTitle()} failed after ${test.duration}ms`);
129
+ // raise flag for keeping the screencast
130
+ CheReporter.deleteScreencast = false;
131
+
132
+ Logger.trace(`FullTitle:${test.fullTitle()}`);
133
+ const testFullTitle: string = StringUtil.sanitizeTitle(test.fullTitle());
134
+ Logger.trace(`FullTitleSanitized:${testFullTitle}`);
135
+ Logger.trace(`TestTitle:${test.title}`);
136
+ const testTitle: string = StringUtil.sanitizeTitle(test.title);
137
+ Logger.trace(`TestTitleSanitized:${testTitle}`);
138
+
139
+ const testReportDirPath: string = `${REPORTER_CONSTANTS.TS_SELENIUM_REPORT_FOLDER}/${testFullTitle}`;
140
+ const screenshotFileName: string = `${testReportDirPath}/screenshot-${testTitle}.png`;
141
+ const pageSourceFileName: string = `${testReportDirPath}/pagesource-${testTitle}.html`;
142
+ const browserLogsFileName: string = `${testReportDirPath}/browserlogs-${testTitle}.txt`;
143
+
144
+ // create reporter dir if not exist
145
+ const reportDirExists: boolean = fs.existsSync(REPORTER_CONSTANTS.TS_SELENIUM_REPORT_FOLDER);
146
+
147
+ if (!reportDirExists) {
148
+ fs.mkdirSync(REPORTER_CONSTANTS.TS_SELENIUM_REPORT_FOLDER);
149
+ }
150
+
151
+ // create dir for failed test report if not exist
152
+ const testReportDirExists: boolean = fs.existsSync(testReportDirPath);
153
+
154
+ if (!testReportDirExists) {
155
+ fs.mkdirSync(testReportDirPath);
156
+ }
157
+
158
+ // take screenshot and write to file
159
+ const screenshot: string = await this.driverHelper.getDriver().takeScreenshot();
160
+ const screenshotStream: WriteStream = fs.createWriteStream(screenshotFileName);
161
+ screenshotStream.write(Buffer.from(screenshot, 'base64'));
162
+ screenshotStream.end();
163
+
164
+ // take page source and write to file
165
+ const pageSource: string = await this.driverHelper.getDriver().getPageSource();
166
+ const pageSourceStream: WriteStream = fs.createWriteStream(pageSourceFileName);
167
+ pageSourceStream.write(Buffer.from(pageSource));
168
+ pageSourceStream.end();
169
+
170
+ // take browser console logs and write to file
171
+ const browserLogsEntries: logging.Entry[] = await this.driverHelper.getDriver().manage().logs().get('browser');
172
+ let browserLogs: string = '';
173
+
174
+ browserLogsEntries.forEach((log): void => {
175
+ browserLogs += `\"${log.level}\" \"${log.type}\" \"${log.message}\"\n`;
176
+ });
177
+
178
+ const browserLogsStream: WriteStream = fs.createWriteStream(browserLogsFileName);
179
+ browserLogsStream.write(Buffer.from(browserLogs));
180
+ browserLogsStream.end();
181
+ });
182
+ }
181
183
  }
182
184
 
183
185
  export = CheReporter;
@@ -1,3 +1,12 @@
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 { Main as Generator } from '@eclipse-che/che-devworkspace-generator/lib/main';
2
11
  import { DevfileContext } from '@eclipse-che/che-devworkspace-generator/lib/api/devfile-context';
3
12
  import { V1alpha2DevWorkspaceTemplate } from '@devfile/api';
@@ -5,79 +14,64 @@ import YAML from 'yaml';
5
14
  import * as axios from 'axios';
6
15
  import { Logger } from './Logger';
7
16
  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
- }
17
+ import { API_TEST_CONSTANTS } from '../constants/API_TEST_CONSTANTS';
18
+ import { injectable } from 'inversify';
19
+ import { IContextParams } from './IContextParams';
20
+ import { e2eContainer } from '../configs/inversify.config';
21
+ import { CLASSES, EXTERNAL_CLASSES } from '../configs/inversify.types';
31
22
 
23
+ @injectable()
32
24
  export class DevWorkspaceConfigurationHelper {
33
- private generator: Generator = new Generator();
34
- private readonly params: IContextParams;
25
+ private generator: Generator = e2eContainer.get(EXTERNAL_CLASSES.Generator);
26
+ private shellExecutor: ShellExecutor = e2eContainer.get(CLASSES.ShellExecutor);
27
+
28
+ private readonly params: IContextParams;
35
29
 
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
- }
30
+ constructor(params: IContextParams) {
31
+ // check if all undefined
32
+ if (!(params.editorPath || params.editorEntry || params.editorContent)) {
33
+ params.editorEntry = 'che-incubator/che-code/latest';
34
+ }
35
+ // check if one or both has value
36
+ if (API_TEST_CONSTANTS.TS_API_TEST_UDI_IMAGE || params.defaultComponentImage) {
37
+ params.injectDefaultComponent = 'true';
38
+ // check if not explicitly passed than assign value from the constants
39
+ if (!params.defaultComponentImage) {
40
+ params.defaultComponentImage = API_TEST_CONSTANTS.TS_API_TEST_UDI_IMAGE;
41
+ }
42
+ }
43
+ // assign value from the constants if not explicitly passed
44
+ if (API_TEST_CONSTANTS.TS_API_TEST_PLUGIN_REGISTRY_URL && !params.pluginRegistryUrl) {
45
+ params.pluginRegistryUrl = API_TEST_CONSTANTS.TS_API_TEST_PLUGIN_REGISTRY_URL;
46
+ }
47
+ if (API_TEST_CONSTANTS.TS_API_TEST_CHE_CODE_EDITOR_DEVFILE_URI && !params.editorContent) {
48
+ params.editorContent = this.shellExecutor.curl(API_TEST_CONSTANTS.TS_API_TEST_CHE_CODE_EDITOR_DEVFILE_URI).stdout;
49
+ }
50
+ this.params = params;
51
+ }
58
52
 
59
- async generateDevfileContext(): Promise<DevfileContext> {
60
- Logger.debug();
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
- }
53
+ async generateDevfileContext(): Promise<DevfileContext> {
54
+ Logger.debug();
55
+ if (!this.params.projects) {
56
+ this.params.projects = [];
57
+ }
58
+ return await this.generator.generateDevfileContext(
59
+ {
60
+ ...this.params,
61
+ projects: this.params.projects
62
+ },
63
+ axios.default as any
64
+ );
65
+ }
72
66
 
73
- // write templates and then DevWorkspace in a single file
74
- async getDevWorkspaceConfigurationYamlAsString(context: DevfileContext): Promise<string> {
75
- Logger.debug();
76
- const allContentArray: any[] = context.devWorkspaceTemplates.map(
77
- (template: V1alpha2DevWorkspaceTemplate) => YAML.stringify(template)
78
- );
79
- allContentArray.push(YAML.stringify(context.devWorkspace));
67
+ // write templates and then DevWorkspace in a single file
68
+ getDevWorkspaceConfigurationYamlAsString(context: DevfileContext): string {
69
+ Logger.debug();
70
+ const allContentArray: any[] = context.devWorkspaceTemplates.map((template: V1alpha2DevWorkspaceTemplate): string =>
71
+ YAML.stringify(template)
72
+ );
73
+ allContentArray.push(YAML.stringify(context.devWorkspace));
80
74
 
81
- return allContentArray.join('---\n');
82
- }
75
+ return allContentArray.join('---\n');
76
+ }
83
77
  }
@@ -1,5 +1,5 @@
1
- /*********************************************************************
2
- * Copyright (c) 2023 Red Hat, Inc.
1
+ /** *******************************************************************
2
+ * copyright (c) 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
@@ -10,68 +10,82 @@
10
10
  import axios, { AxiosResponse } from 'axios';
11
11
  import { Logger } from './Logger';
12
12
  import YAML from 'yaml';
13
- import { APITestConstants, SupportedDevfilesRegistries } from '../constants/APITestConstants';
13
+ import { API_TEST_CONSTANTS, SUPPORTED_DEVFILE_REGISTRIES } from '../constants/API_TEST_CONSTANTS';
14
+ import { injectable } from 'inversify';
14
15
 
16
+ @injectable()
15
17
  export class DevfilesRegistryHelper {
18
+ async getInbuiltDevfilesRegistryContent(): Promise<AxiosResponse> {
19
+ Logger.trace();
16
20
 
17
- async getInbuiltDevfilesRegistryContent(): Promise<AxiosResponse> {
18
- Logger.debug();
19
- return await this.getContent(SupportedDevfilesRegistries.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL());
20
- }
21
+ return await this.getContent(SUPPORTED_DEVFILE_REGISTRIES.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL());
22
+ }
21
23
 
22
- async getGitHubCheDevfileRegistryContent(): Promise<AxiosResponse> {
23
- Logger.debug();
24
- return await this.getContent(SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL);
25
- }
24
+ async getGitHubCheDevfileRegistryContent(): Promise<AxiosResponse> {
25
+ Logger.trace();
26
26
 
27
- async collectPathsToDevfilesFromRegistry(): Promise<object[]> {
28
- Logger.debug();
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
- });
27
+ return await this.getContent(SUPPORTED_DEVFILE_REGISTRIES.GIT_HUB_CHE_DEVFILE_REGISTRY_URL);
28
+ }
37
29
 
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(`samples list: ${JSON.stringify(devfileSamples)}`);
46
- }
47
- break;
48
- case (SupportedDevfilesRegistries.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL()): {
49
- const content: any[any] = await this.getInbuiltDevfilesRegistryContent();
30
+ async collectPathsToDevfilesFromRegistry(): Promise<object[]> {
31
+ Logger.debug();
50
32
 
51
- for (const sample of content) {
52
- devfileSamples.push({ name: sample.displayName, link: sample.links.v2 });
53
- }
54
- Logger.debug(`samples list: ${JSON.stringify(devfileSamples)}`);
55
- }
56
- break;
57
- default: {
58
- Logger.error(`unsupported registry url - ${APITestConstants.TS_API_ACCEPTANCE_TEST_REGISTRY_URL()}\n
59
- supported registries: ${JSON.stringify(SupportedDevfilesRegistries)}`);
60
- }
61
- }
62
- return devfileSamples;
63
- }
33
+ const devfileSamples: object[] = [];
34
+ const sampleNames: string[] = [];
35
+ switch (API_TEST_CONSTANTS.TS_API_ACCEPTANCE_TEST_REGISTRY_URL()) {
36
+ case SUPPORTED_DEVFILE_REGISTRIES.GIT_HUB_CHE_DEVFILE_REGISTRY_URL:
37
+ {
38
+ const content: any[any] = await this.getGitHubCheDevfileRegistryContent();
39
+ content.forEach((e: any): void => {
40
+ if (e.name[0] !== '.') {
41
+ sampleNames.push(e.name);
42
+ }
43
+ });
64
44
 
65
- private async getContent(url: string, headers?: object): Promise<AxiosResponse> {
66
- Logger.debug(`${url}`);
45
+ for (const sample of sampleNames) {
46
+ const sampleEndpoint: string = `${SUPPORTED_DEVFILE_REGISTRIES.GIT_HUB_CHE_DEVFILE_REGISTRY_URL}${sample}/meta.yaml`;
47
+ const sampleEndpointContent: AxiosResponse = await this.getContent(sampleEndpoint);
48
+ const decodedFileContent: string = Buffer.from((sampleEndpointContent as any).content, 'base64').toString();
49
+ const metaYamlContent: any = YAML.parse(decodedFileContent);
50
+ devfileSamples.push({
51
+ name: sample,
52
+ link: metaYamlContent.links.v2
53
+ });
54
+ }
55
+ Logger.debug(`samples list: ${JSON.stringify(devfileSamples)}`);
56
+ }
57
+ break;
58
+ case SUPPORTED_DEVFILE_REGISTRIES.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL():
59
+ {
60
+ const content: any[any] = await this.getInbuiltDevfilesRegistryContent();
67
61
 
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
- }
62
+ for (const sample of content) {
63
+ devfileSamples.push({
64
+ name: sample.displayName,
65
+ link: sample.links.v2
66
+ });
67
+ }
68
+ Logger.debug(`samples list: ${JSON.stringify(devfileSamples)}`);
69
+ }
70
+ break;
71
+ default: {
72
+ Logger.error(`unsupported registry url - ${API_TEST_CONSTANTS.TS_API_ACCEPTANCE_TEST_REGISTRY_URL()}\n
73
+ supported registries: ${JSON.stringify(SUPPORTED_DEVFILE_REGISTRIES)}`);
74
+ }
75
+ }
76
+ return devfileSamples;
77
+ }
78
+
79
+ private async getContent(url: string, headers?: object): Promise<AxiosResponse> {
80
+ Logger.trace(`${url}`);
81
+
82
+ let response: AxiosResponse | undefined;
83
+ try {
84
+ response = await axios.get(url, headers);
85
+ } catch (error) {
86
+ Logger.error(`${error} + ${url}`);
87
+ throw error;
88
+ }
89
+ return response?.data;
90
+ }
77
91
  }