@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
@@ -12,107 +12,107 @@ import 'reflect-metadata';
12
12
  import { CLASSES } from '../../configs/inversify.types';
13
13
  import { By } from 'selenium-webdriver';
14
14
  import { DriverHelper } from '../../utils/DriverHelper';
15
- import { TimeoutConstants } from '../../constants/TimeoutConstants';
15
+ import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS';
16
16
  import { Workspaces } from './Workspaces';
17
17
  import { Logger } from '../../utils/Logger';
18
- import { BaseTestConstants } from '../../constants/BaseTestConstants';
18
+ import { BASE_TEST_CONSTANTS } from '../../constants/BASE_TEST_CONSTANTS';
19
19
 
20
20
  @injectable()
21
21
  export class Dashboard {
22
- private static readonly WORKSPACES_BUTTON: By = By.xpath(`//div[@id='page-sidebar']//a[contains(text(), 'Workspaces (')]`);
23
- private static readonly CREATE_WORKSPACE_BUTTON: By = By.xpath(`//div[@id='page-sidebar']//a[text()='Create Workspace']`);
24
- private static readonly LOADER_PAGE_STEP_TITLES: By = By.xpath('//*[@data-testid="step-title"]');
25
- private static readonly STARTING_PAGE_LOADER: By = By.css('.main-page-loader');
26
- private static readonly LOADER_ALERT: By = By.xpath('//*[@data-testid="loader-alert"]');
27
- private static readonly LOGOUT_BUTTON: By = By.xpath('//button[text()="Logout"]');
28
- private static readonly USER_SETTINGS_DROPDOWN: By = By.xpath('//header//button/span[text()!=\'\']//parent::button');
29
-
30
- constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
31
- @inject(CLASSES.Workspaces) private readonly workspaces: Workspaces) {
32
- }
33
-
34
- async stopWorkspaceByUI(workspaceName: string): Promise<void> {
35
- Logger.debug(`"${workspaceName}"`);
36
-
37
- await this.clickWorkspacesButton();
38
- await this.workspaces.waitPage();
39
- await this.workspaces.waitWorkspaceListItem(workspaceName);
40
- await this.workspaces.waitWorkspaceWithRunningStatus(workspaceName);
41
-
42
- await this.workspaces.stopWorkspaceByActionsButton(workspaceName);
43
- await this.workspaces.waitWorkspaceWithStoppedStatus(workspaceName);
44
- }
45
-
46
- async deleteStoppedWorkspaceByUI(workspaceName: string): Promise<void> {
47
- Logger.debug(`"${workspaceName}"`);
48
-
49
- await this.clickWorkspacesButton();
50
- await this.workspaces.waitPage();
51
- await this.workspaces.waitWorkspaceListItem(workspaceName);
52
- await this.workspaces.deleteWorkspaceByActionsButton(workspaceName);
53
- await this.workspaces.waitPage();
54
- await this.workspaces.waitWorkspaceListItemAbsence(workspaceName);
55
- }
56
-
57
- async stopAndRemoveWorkspaceByUI(workspaceName: string): Promise<void> {
58
- Logger.debug(`"${workspaceName}"`);
59
-
60
- await this.stopWorkspaceByUI(workspaceName);
61
- await this.workspaces.deleteWorkspaceByActionsButton(workspaceName);
62
- await this.workspaces.waitWorkspaceListItemAbsence(workspaceName);
63
- }
64
-
65
- async openDashboard(): Promise<void> {
66
- Logger.debug();
67
- await this.driverHelper.getDriver().navigate().to(BaseTestConstants.TS_SELENIUM_BASE_URL);
68
- await this.waitPage();
69
-
70
- }
71
-
72
- async waitPage(timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT): Promise<void> {
73
- Logger.debug();
74
-
75
- await this.driverHelper.waitVisibility(Dashboard.WORKSPACES_BUTTON, timeout);
76
- await this.driverHelper.waitVisibility(Dashboard.CREATE_WORKSPACE_BUTTON, timeout);
77
- }
78
-
79
- async clickWorkspacesButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
80
- Logger.debug();
81
-
82
- await this.driverHelper.waitAndClick(Dashboard.WORKSPACES_BUTTON, timeout);
83
- }
84
-
85
- async clickCreateWorkspaceButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
86
- Logger.debug();
87
-
88
- await this.driverHelper.waitAndClick(Dashboard.CREATE_WORKSPACE_BUTTON, timeout);
89
- }
90
-
91
- async getLoaderAlert(timeout: number = TimeoutConstants.TS_WAIT_LOADER_PRESENCE_TIMEOUT): Promise<string> {
92
- Logger.debug();
93
-
94
- return await this.driverHelper.waitAndGetText(Dashboard.LOADER_ALERT, timeout);
95
- }
96
-
97
- async waitLoader(timeout: number = TimeoutConstants.TS_WAIT_LOADER_PRESENCE_TIMEOUT): Promise<void> {
98
- Logger.debug();
99
-
100
- await this.driverHelper.waitAllPresence(Dashboard.LOADER_PAGE_STEP_TITLES, timeout);
101
- }
102
-
103
- async waitStartingPageLoaderDisappearance(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
104
- Logger.debug();
105
-
106
- await this.driverHelper.waitDisappearance(Dashboard.STARTING_PAGE_LOADER, timeout);
107
- await this.driverHelper.wait(TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING);
108
- }
109
-
110
- async logout(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
111
- Logger.debug();
112
-
113
- await this.openDashboard();
114
- await this.driverHelper.waitAndClick(Dashboard.USER_SETTINGS_DROPDOWN, timeout);
115
- await this.driverHelper.waitAndClick(Dashboard.LOGOUT_BUTTON, timeout);
116
- await this.driverHelper.waitDisappearance(Dashboard.USER_SETTINGS_DROPDOWN, timeout);
117
- }
22
+ private static readonly WORKSPACES_BUTTON: By = By.xpath('//div[@id="page-sidebar"]//a[contains(text(), "Workspaces (")]');
23
+ private static readonly CREATE_WORKSPACE_BUTTON: By = By.xpath('//div[@id="page-sidebar"]//a[text()="Create Workspace"]');
24
+ private static readonly LOADER_PAGE_STEP_TITLES: By = By.xpath('//*[@data-testid="step-title"]');
25
+ private static readonly STARTING_PAGE_LOADER: By = By.css('.main-page-loader');
26
+ private static readonly LOADER_ALERT: By = By.xpath('//*[@data-testid="loader-alert"]');
27
+ private static readonly LOGOUT_BUTTON: By = By.xpath('//button[text()="Logout"]');
28
+ private static readonly USER_SETTINGS_DROPDOWN: By = By.xpath('//header//button/span[text()!=""]//parent::button');
29
+
30
+ constructor(
31
+ @inject(CLASSES.DriverHelper)
32
+ private readonly driverHelper: DriverHelper,
33
+ @inject(CLASSES.Workspaces) private readonly workspaces: Workspaces
34
+ ) {}
35
+
36
+ async stopWorkspaceByUI(workspaceName: string): Promise<void> {
37
+ Logger.debug(`"${workspaceName}"`);
38
+
39
+ await this.clickWorkspacesButton();
40
+ await this.workspaces.waitPage();
41
+ await this.workspaces.waitWorkspaceListItem(workspaceName);
42
+ await this.workspaces.waitWorkspaceWithRunningStatus(workspaceName);
43
+ await this.workspaces.stopWorkspaceByActionsButton(workspaceName);
44
+ await this.workspaces.waitWorkspaceWithStoppedStatus(workspaceName);
45
+ }
46
+
47
+ async deleteStoppedWorkspaceByUI(workspaceName: string): Promise<void> {
48
+ Logger.debug(`"${workspaceName}"`);
49
+
50
+ await this.clickWorkspacesButton();
51
+ await this.workspaces.waitPage();
52
+ await this.workspaces.waitWorkspaceListItem(workspaceName);
53
+ await this.workspaces.deleteWorkspaceByActionsButton(workspaceName);
54
+ await this.workspaces.waitPage();
55
+ await this.workspaces.waitWorkspaceListItemAbsence(workspaceName);
56
+ }
57
+
58
+ async stopAndRemoveWorkspaceByUI(workspaceName: string): Promise<void> {
59
+ Logger.debug(`"${workspaceName}"`);
60
+
61
+ await this.stopWorkspaceByUI(workspaceName);
62
+ await this.deleteStoppedWorkspaceByUI(workspaceName);
63
+ }
64
+
65
+ async openDashboard(): Promise<void> {
66
+ Logger.debug();
67
+
68
+ await this.driverHelper.navigateToUrl(BASE_TEST_CONSTANTS.TS_SELENIUM_BASE_URL);
69
+ await this.waitPage();
70
+ }
71
+
72
+ async waitPage(timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_LOAD_PAGE_TIMEOUT): Promise<void> {
73
+ Logger.debug();
74
+
75
+ await this.driverHelper.waitVisibility(Dashboard.WORKSPACES_BUTTON, timeout);
76
+ await this.driverHelper.waitVisibility(Dashboard.CREATE_WORKSPACE_BUTTON, timeout);
77
+ }
78
+
79
+ async clickWorkspacesButton(timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
80
+ Logger.debug();
81
+
82
+ await this.driverHelper.waitAndClick(Dashboard.WORKSPACES_BUTTON, timeout);
83
+ }
84
+
85
+ async clickCreateWorkspaceButton(timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
86
+ Logger.debug();
87
+
88
+ await this.driverHelper.waitAndClick(Dashboard.CREATE_WORKSPACE_BUTTON, timeout);
89
+ }
90
+
91
+ async getLoaderAlert(timeout: number = TIMEOUT_CONSTANTS.TS_WAIT_LOADER_PRESENCE_TIMEOUT): Promise<string> {
92
+ Logger.debug();
93
+
94
+ return await this.driverHelper.waitAndGetText(Dashboard.LOADER_ALERT, timeout);
95
+ }
96
+
97
+ async waitLoader(timeout: number = TIMEOUT_CONSTANTS.TS_WAIT_LOADER_PRESENCE_TIMEOUT): Promise<void> {
98
+ Logger.debug();
99
+
100
+ await this.driverHelper.waitAllPresence(Dashboard.LOADER_PAGE_STEP_TITLES, timeout);
101
+ }
102
+
103
+ async waitStartingPageLoaderDisappearance(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
104
+ Logger.debug();
105
+
106
+ await this.driverHelper.waitDisappearance(Dashboard.STARTING_PAGE_LOADER, timeout);
107
+ await this.driverHelper.wait(TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING);
108
+ }
109
+
110
+ async logout(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
111
+ Logger.debug();
112
+
113
+ await this.openDashboard();
114
+ await this.driverHelper.waitAndClick(Dashboard.USER_SETTINGS_DROPDOWN, timeout);
115
+ await this.driverHelper.waitAndClick(Dashboard.LOGOUT_BUTTON, timeout);
116
+ await this.driverHelper.waitDisappearance(Dashboard.USER_SETTINGS_DROPDOWN, timeout);
117
+ }
118
118
  }
@@ -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
@@ -13,202 +13,226 @@ import { DriverHelper } from '../../utils/DriverHelper';
13
13
  import { CLASSES } from '../../configs/inversify.types';
14
14
  import { By, WebElement } from 'selenium-webdriver';
15
15
  import { Logger } from '../../utils/Logger';
16
- import { TimeoutConstants } from '../../constants/TimeoutConstants';
16
+ import { TIMEOUT_CONSTANTS } from '../../constants/TIMEOUT_CONSTANTS';
17
17
 
18
18
  export enum WorkspaceStatusUI {
19
- Running = 'green',
20
- Stopped = 'grey'
19
+ Running = 'green',
20
+ Stopped = 'grey'
21
21
  }
22
22
 
23
23
  @injectable()
24
24
  export class Workspaces {
25
- private static readonly ADD_WORKSPACE_BUTTON_XPATH: string = `//button[text()='Add Workspace']`;
26
- private static readonly WORKSPACE_ITEM_TABLE_NAME_SECTION_XPATH: string = `//td[@data-label="Name"]/span/a`;
25
+ private static readonly ADD_WORKSPACE_BUTTON: By = By.xpath('//button[text()="Add Workspace"]');
26
+ private static readonly WORKSPACE_ITEM_TABLE_NAME_SECTION: By = By.xpath('//td[@data-label="Name"]/span/a');
27
+ private static readonly DELETE_WORKSPACE_BUTTON_ENABLED: By = By.xpath(
28
+ '//button[@data-testid="delete-workspace-button" and not(@disabled)]'
29
+ );
30
+ private static readonly DELETE_CONFIRMATION_CHECKBOX: By = By.xpath('//input[@data-testid="confirmation-checkbox"]');
31
+ private static readonly CONFIRMATION_WINDOW: By = By.xpath('//div[@aria-label="Delete workspaces confirmation window"]');
27
32
 
28
- constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) {
29
- }
33
+ constructor(
34
+ @inject(CLASSES.DriverHelper)
35
+ private readonly driverHelper: DriverHelper
36
+ ) {}
30
37
 
31
- async waitPage(timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT): Promise<void> {
32
- Logger.debug();
38
+ async waitPage(timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_LOAD_PAGE_TIMEOUT): Promise<void> {
39
+ Logger.debug();
33
40
 
34
- await this.driverHelper.waitVisibility(By.xpath(Workspaces.ADD_WORKSPACE_BUTTON_XPATH), timeout);
35
- }
41
+ await this.driverHelper.waitVisibility(Workspaces.ADD_WORKSPACE_BUTTON, timeout);
42
+ }
36
43
 
37
- async clickAddWorkspaceButton(timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
38
- Logger.debug();
44
+ async clickAddWorkspaceButton(timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
45
+ Logger.debug();
39
46
 
40
- await this.driverHelper.waitAndClick(By.xpath(Workspaces.ADD_WORKSPACE_BUTTON_XPATH), timeout);
41
- }
47
+ await this.driverHelper.waitAndClick(Workspaces.ADD_WORKSPACE_BUTTON, timeout);
48
+ }
42
49
 
43
- async clickOpenButton(workspaceName: string, timeout: number = TimeoutConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT): Promise<void> {
44
- Logger.debug();
50
+ async clickOpenButton(workspaceName: string, timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_LOAD_PAGE_TIMEOUT): Promise<void> {
51
+ Logger.debug();
45
52
 
46
- await this.driverHelper.waitAndClick(this.getOpenButtonLocator(workspaceName), timeout);
47
- }
53
+ await this.driverHelper.waitAndClick(this.getOpenButtonLocator(workspaceName), timeout);
54
+ }
48
55
 
49
- async waitWorkspaceListItem(workspaceName: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
50
- Logger.debug(`"${workspaceName}"`);
51
-
52
- const workspaceListItemLocator: By = By.xpath(this.getWorkspaceListItemLocator(workspaceName));
53
-
54
- await this.driverHelper.waitVisibility(workspaceListItemLocator, timeout);
55
- }
56
-
57
- async waitWorkspaceWithRunningStatus(workspaceName: string, timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
58
- Logger.debug(`"${workspaceName}"`);
59
-
60
- const runningStatusLocator: By = this.getWorkspaceStatusLocator(workspaceName, WorkspaceStatusUI.Running);
61
-
62
- await this.driverHelper.waitVisibility(runningStatusLocator, timeout);
63
- }
64
-
65
- async waitWorkspaceWithStoppedStatus(workspaceName: string, timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise<void> {
66
- Logger.debug(`"${workspaceName}"`);
67
-
68
- const stoppedStatusLocator: By = this.getWorkspaceStatusLocator(workspaceName, WorkspaceStatusUI.Stopped);
69
-
70
- await this.driverHelper.waitVisibility(stoppedStatusLocator, timeout);
71
- }
72
-
73
- async clickWorkspaceListItem(workspaceName: string, timeout: number = TimeoutConstants.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
74
- Logger.debug(`"${workspaceName}"`);
75
-
76
- const workspaceListItemLocator: By = By.xpath(this.getWorkspaceListItemLocator(workspaceName));
77
-
78
- await this.driverHelper.waitAndClick(workspaceListItemLocator, timeout);
79
- }
80
-
81
- async clickActionsButton(workspaceName: string): Promise<void> {
82
- Logger.debug(`of the '${workspaceName}' list item`);
83
-
84
- await this.driverHelper.waitAndClick(this.getActionsLocator(workspaceName));
85
- }
86
-
87
- async waitActionsPopup(workspaceName: string, timeout: number = TimeoutConstants.TS_CONTEXT_MENU_TIMEOUT): Promise<void> {
88
- Logger.debug(`of the '${workspaceName}' list item`);
89
-
90
- await this.driverHelper.waitVisibility(this.getExpandedActionsLocator(workspaceName), timeout);
91
- }
92
-
93
- async openActionsPopup(workspaceName: string, timeout: number = TimeoutConstants.TS_CONTEXT_MENU_TIMEOUT): Promise<void> {
94
- Logger.debug(`for the '${workspaceName}' list item`);
95
- await this.clickActionsButton(workspaceName);
96
- await this.waitActionsPopup(workspaceName, timeout);
97
- }
98
-
99
- async clickActionsDeleteButton(workspaceName: string): Promise<void> {
100
- Logger.debug(`for the '${workspaceName}' list item`);
101
-
102
- await this.driverHelper.waitAndClick(this.getActionsPopupButtonLocator(workspaceName, 'Delete Workspace'));
103
- }
104
-
105
- async clickActionsStopWorkspaceButton(workspaceName: string): Promise<void> {
106
- Logger.debug(`for the '${workspaceName}' list item`);
107
- // todo: workaround because of issue CRW-3649
108
- try {
109
- await this.driverHelper.waitAndClick(this.getActionsPopupButtonLocator(workspaceName, 'Stop Workspace'));
110
- } catch (e) {
111
- Logger.warn(`for the '${workspaceName}' list item - popup was missed, try to click one more time (issue CRW-3649).`);
112
-
113
- await this.driverHelper.waitAndClick(this.getActionsLocator(workspaceName));
114
- await this.driverHelper.waitAndClick(this.getActionsPopupButtonLocator(workspaceName, 'Stop Workspace'));
115
- }
116
- }
117
-
118
- async waitDeleteWorkspaceConfirmationWindow(timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise<void> {
119
- Logger.debug();
120
-
121
- const confirmationWindowLocator: By = By.xpath(`//div[@aria-label='Delete workspaces confirmation window']`);
122
-
123
- await this.driverHelper.waitVisibility(confirmationWindowLocator, timeout);
124
- }
125
-
126
- async clickToDeleteConfirmationCheckbox(timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise<void> {
127
- Logger.debug(`Workspaces.clickToDeleteConfirmationCheckbox`);
128
-
129
- const deleteConfirmationCheckboxLocator: By = By.xpath(`//input[@data-testid='confirmation-checkbox']`);
130
-
131
- await this.driverHelper.waitAndClick(deleteConfirmationCheckboxLocator, timeout);
132
- }
133
-
134
- async waitAndClickEnabledConfirmationWindowDeleteButton(timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise<void> {
135
- Logger.debug(`Workspaces.waitEnabledConfirmationWindowDeleteButton`);
136
-
137
- const enabledConfirmationWindowDeleteButton: By = By.xpath(`//button[@data-testid='delete-workspace-button' and not(@disabled)]`);
138
-
139
- await this.driverHelper.waitAndClick(enabledConfirmationWindowDeleteButton, timeout);
140
- }
141
-
142
- async deleteWorkspaceByActionsButton(workspaceName: string, timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise<void> {
143
- Logger.debug('Workspaces.deleteWorkspaceByActionsButton');
144
-
145
- await this.waitWorkspaceListItem(workspaceName, timeout);
146
- await this.openActionsPopup(workspaceName, timeout);
147
- await this.clickActionsDeleteButton(workspaceName);
148
- await this.waitDeleteWorkspaceConfirmationWindow(timeout);
149
- await this.clickToDeleteConfirmationCheckbox(timeout);
150
- await this.waitAndClickEnabledConfirmationWindowDeleteButton(timeout);
151
- }
152
-
153
- async stopWorkspaceByActionsButton(workspaceName: string, timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise<void> {
154
- Logger.debug('Workspaces.stopWorkspaceByActionsButton');
155
-
156
- await this.waitWorkspaceListItem(workspaceName, timeout);
157
- await this.openActionsPopup(workspaceName, timeout);
158
- await this.clickActionsStopWorkspaceButton(workspaceName);
159
- }
160
-
161
- async waitWorkspaceListItemAbsence(workspaceName: string, timeout: number = TimeoutConstants.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise<void> {
162
- Logger.debug(`Workspaces.waitWorkspaceListItemAbsence "${workspaceName}"`);
163
-
164
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
165
- const attempts: number = Math.ceil(timeout / polling);
166
-
167
- const workspaceListItemLocator: By = By.xpath(this.getWorkspaceListItemLocator(workspaceName));
168
-
169
- await this.driverHelper.waitDisappearance(workspaceListItemLocator, attempts, polling);
170
- }
171
-
172
- async getAllCreatedWorkspacesNames(timeout: number = TimeoutConstants.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<string[]> {
173
- Logger.debug('Workspaces.getAllCreatedWorkspacesNames');
174
-
175
- const workspaceNames: string[] = [];
176
- try {
177
- const workspaceItems: WebElement[] = await this.driverHelper.waitAllPresence(By.xpath(Workspaces.WORKSPACE_ITEM_TABLE_NAME_SECTION_XPATH), timeout);
178
- for (let item of workspaceItems) {
179
- Logger.debug(`Workspaces.getAllCreatedWorkspacesNames - try to get ${workspaceItems.indexOf(item)} items name`);
180
- workspaceNames.push(await item.getText());
181
- Logger.debug(`Workspaces.getAllCreatedWorkspacesNames - workspace name is "${workspaceNames[workspaceNames.length - 1]}"`);
182
- }
183
- } catch (e) {
184
- Logger.debug(`Workspaces.getAllCreatedWorkspacesNames - ${e}`);
185
- }
186
-
187
- Logger.debug(`Workspaces.getAllCreatedWorkspacesNames - ${workspaceNames.length} workspaces have been created in DevSpaces`);
188
- return workspaceNames;
189
- }
190
-
191
- private getWorkspaceListItemLocator(workspaceName: string): string {
192
- return `//tr[td/span/a[text()='${workspaceName}']]`;
193
- }
194
-
195
- private getWorkspaceStatusLocator(workspaceName: string, workspaceStatus: WorkspaceStatusUI): By {
196
- return By.xpath(`${this.getWorkspaceListItemLocator(workspaceName)}//span[@data-testid='workspace-status-indicator']//*[local-name()='svg' and @fill='${workspaceStatus}']`);
197
- }
198
-
199
- private getActionsLocator(workspaceName: string): By {
200
- return By.xpath(`${this.getWorkspaceListItemLocator(workspaceName)}/td/div/button[@aria-label='Actions']`);
201
- }
202
-
203
- private getExpandedActionsLocator(workspaceName: string): By {
204
- return By.xpath(`${this.getWorkspaceListItemLocator(workspaceName)}//button[@aria-label='Actions' and @aria-expanded='true']`);
205
- }
206
-
207
- private getActionsPopupButtonLocator(workspaceName: string, buttonText: string): By {
208
- return By.xpath(`${this.getWorkspaceListItemLocator(workspaceName)}//li[@role='menuitem']//button[text()='${buttonText}']`);
209
- }
210
-
211
- private getOpenButtonLocator(workspaceName: string): By {
212
- return By.xpath(`${this.getWorkspaceListItemLocator(workspaceName)}//td[@data-key=5]//a[text()='Open']`);
213
- }
56
+ async waitWorkspaceListItem(
57
+ workspaceName: string,
58
+ timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT
59
+ ): Promise<void> {
60
+ Logger.debug(`"${workspaceName}"`);
61
+
62
+ await this.driverHelper.waitVisibility(this.getWorkspaceListItemLocator(workspaceName), timeout);
63
+ }
64
+
65
+ async waitWorkspaceWithRunningStatus(
66
+ workspaceName: string,
67
+ timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT
68
+ ): Promise<void> {
69
+ Logger.debug(`"${workspaceName}"`);
70
+
71
+ await this.driverHelper.waitVisibility(this.getWorkspaceStatusLocator(workspaceName, WorkspaceStatusUI.Running), timeout);
72
+ }
73
+
74
+ async waitWorkspaceWithStoppedStatus(
75
+ workspaceName: string,
76
+ timeout: number = TIMEOUT_CONSTANTS.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT
77
+ ): Promise<void> {
78
+ Logger.debug(`"${workspaceName}"`);
79
+
80
+ await this.driverHelper.waitVisibility(this.getWorkspaceStatusLocator(workspaceName, WorkspaceStatusUI.Stopped), timeout);
81
+ }
82
+
83
+ async clickWorkspaceListItem(
84
+ workspaceName: string,
85
+ timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT
86
+ ): Promise<void> {
87
+ Logger.debug(`"${workspaceName}"`);
88
+
89
+ await this.driverHelper.waitAndClick(this.getWorkspaceListItemLocator(workspaceName), timeout);
90
+ }
91
+
92
+ async clickActionsButton(workspaceName: string): Promise<void> {
93
+ Logger.debug(`of the '${workspaceName}' list item`);
94
+
95
+ await this.driverHelper.waitAndClick(this.getActionsLocator(workspaceName));
96
+ }
97
+
98
+ async waitActionsPopup(workspaceName: string, timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
99
+ Logger.debug(`of the '${workspaceName}' list item`);
100
+
101
+ await this.driverHelper.waitVisibility(this.getExpandedActionsLocator(workspaceName), timeout);
102
+ }
103
+
104
+ async openActionsPopup(workspaceName: string, timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
105
+ Logger.debug(`for the '${workspaceName}' list item`);
106
+
107
+ await this.clickActionsButton(workspaceName);
108
+ await this.waitActionsPopup(workspaceName, timeout);
109
+ }
110
+
111
+ async clickActionsDeleteButton(workspaceName: string): Promise<void> {
112
+ Logger.debug(`for the '${workspaceName}' list item`);
113
+
114
+ await this.driverHelper.waitAndClick(this.getActionsPopupButtonLocator(workspaceName, 'Delete Workspace'));
115
+ }
116
+
117
+ async clickActionsStopWorkspaceButton(workspaceName: string): Promise<void> {
118
+ Logger.debug(`for the '${workspaceName}' list item`);
119
+ // todo: workaround because of issue CRW-3649
120
+ try {
121
+ await this.driverHelper.waitAndClick(this.getActionsPopupButtonLocator(workspaceName, 'Stop Workspace'));
122
+ } catch (e) {
123
+ Logger.warn(`for the '${workspaceName}' list item - popup was missed, try to click one more time (issue CRW-3649).`);
124
+
125
+ await this.driverHelper.waitAndClick(this.getActionsLocator(workspaceName));
126
+ await this.driverHelper.waitAndClick(this.getActionsPopupButtonLocator(workspaceName, 'Stop Workspace'));
127
+ }
128
+ }
129
+
130
+ async waitDeleteWorkspaceConfirmationWindow(timeout: number = TIMEOUT_CONSTANTS.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise<void> {
131
+ Logger.debug();
132
+
133
+ await this.driverHelper.waitVisibility(Workspaces.CONFIRMATION_WINDOW, timeout);
134
+ }
135
+
136
+ async clickToDeleteConfirmationCheckbox(timeout: number = TIMEOUT_CONSTANTS.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT): Promise<void> {
137
+ Logger.debug();
138
+
139
+ await this.driverHelper.waitAndClick(Workspaces.DELETE_CONFIRMATION_CHECKBOX, timeout);
140
+ }
141
+
142
+ async waitAndClickEnabledConfirmationWindowDeleteButton(
143
+ timeout: number = TIMEOUT_CONSTANTS.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT
144
+ ): Promise<void> {
145
+ Logger.debug();
146
+
147
+ await this.driverHelper.waitAndClick(Workspaces.DELETE_WORKSPACE_BUTTON_ENABLED, timeout);
148
+ }
149
+
150
+ async deleteWorkspaceByActionsButton(
151
+ workspaceName: string,
152
+ timeout: number = TIMEOUT_CONSTANTS.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT
153
+ ): Promise<void> {
154
+ Logger.debug();
155
+
156
+ await this.waitWorkspaceListItem(workspaceName, timeout);
157
+ await this.openActionsPopup(workspaceName, timeout);
158
+ await this.clickActionsDeleteButton(workspaceName);
159
+ await this.waitDeleteWorkspaceConfirmationWindow(timeout);
160
+ await this.clickToDeleteConfirmationCheckbox(timeout);
161
+ await this.waitAndClickEnabledConfirmationWindowDeleteButton(timeout);
162
+ }
163
+
164
+ async stopWorkspaceByActionsButton(
165
+ workspaceName: string,
166
+ timeout: number = TIMEOUT_CONSTANTS.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT
167
+ ): Promise<void> {
168
+ Logger.debug();
169
+
170
+ await this.waitWorkspaceListItem(workspaceName, timeout);
171
+ await this.openActionsPopup(workspaceName, timeout);
172
+ await this.clickActionsStopWorkspaceButton(workspaceName);
173
+ }
174
+
175
+ async waitWorkspaceListItemAbsence(
176
+ workspaceName: string,
177
+ timeout: number = TIMEOUT_CONSTANTS.TS_DASHBOARD_WORKSPACE_STOP_TIMEOUT
178
+ ): Promise<void> {
179
+ Logger.debug(`"${workspaceName}"`);
180
+
181
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
182
+ const attempts: number = Math.ceil(timeout / polling);
183
+
184
+ await this.driverHelper.waitDisappearance(this.getWorkspaceListItemLocator(workspaceName), attempts, polling);
185
+ }
186
+
187
+ async getAllCreatedWorkspacesNames(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<string[]> {
188
+ Logger.debug();
189
+
190
+ const workspaceNames: string[] = [];
191
+ try {
192
+ const workspaceItems: WebElement[] = await this.driverHelper.waitAllPresence(
193
+ Workspaces.WORKSPACE_ITEM_TABLE_NAME_SECTION,
194
+ timeout
195
+ );
196
+ for (const item of workspaceItems) {
197
+ Logger.debug(`try to get ${workspaceItems.indexOf(item)} items name`);
198
+ workspaceNames.push(await item.getText());
199
+ Logger.debug(`workspace name is "${workspaceNames[workspaceNames.length - 1]}"`);
200
+ }
201
+ } catch (e) {
202
+ Logger.debug(`${e}`);
203
+ }
204
+
205
+ Logger.debug(`${workspaceNames.length} workspaces have been created in DevSpaces`);
206
+ return workspaceNames;
207
+ }
208
+
209
+ private getWorkspaceListItemLocator(workspaceName: string): By {
210
+ return By.xpath(`//tr[td//a[text()='${workspaceName}']]`);
211
+ }
212
+
213
+ private getWorkspaceStatusLocator(workspaceName: string, workspaceStatus: WorkspaceStatusUI): By {
214
+ return By.xpath(
215
+ `${
216
+ this.getWorkspaceListItemLocator(workspaceName).value
217
+ }//span[@data-testid='workspace-status-indicator']//*[local-name()='svg' and @fill='${workspaceStatus}']`
218
+ );
219
+ }
220
+
221
+ private getActionsLocator(workspaceName: string): By {
222
+ return By.xpath(`${this.getWorkspaceListItemLocator(workspaceName).value}/td/div/button[@aria-label='Actions']`);
223
+ }
224
+
225
+ private getExpandedActionsLocator(workspaceName: string): By {
226
+ return By.xpath(
227
+ `${this.getWorkspaceListItemLocator(workspaceName).value}//button[@aria-label='Actions' and @aria-expanded='true']`
228
+ );
229
+ }
230
+
231
+ private getActionsPopupButtonLocator(workspaceName: string, buttonText: string): By {
232
+ return By.xpath(`${this.getWorkspaceListItemLocator(workspaceName).value}//li//button[text()='${buttonText}']`);
233
+ }
234
+
235
+ private getOpenButtonLocator(workspaceName: string): By {
236
+ return By.xpath(`${this.getWorkspaceListItemLocator(workspaceName).value}//td[@data-key=5]//a[text()='Open']`);
237
+ }
214
238
  }