@eclipse-che/che-e2e 7.68.0 → 7.69.0-dev-ac76de0

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 (139) hide show
  1. package/configs/inversify.config.ts +2 -2
  2. package/configs/inversify.types.ts +1 -2
  3. package/configs/mocharc.ts +2 -2
  4. package/constants/TestConstants.ts +10 -13
  5. package/index.ts +5 -5
  6. package/package.json +4 -3
  7. package/specs/api/DevfileAcceptanceTestAPI.spec.ts +90 -33
  8. package/specs/api/EmptyWorkspaceAPI.spec.ts +3 -3
  9. package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +2 -2
  10. package/specs/factory/Factory.spec.ts +2 -2
  11. package/specs/factory/NoSetupRepoFactory.spec.ts +2 -2
  12. package/specs/factory/RefusedOAuthFactory.spec.ts +2 -2
  13. package/utils/CheReporter.ts +3 -4
  14. package/utils/DevfilesRegistryHelper.ts +77 -0
  15. package/utils/KubernetesCommandLineToolsExecutor.ts +20 -7
  16. package/utils/ScreenCatcher.ts +3 -4
  17. package/utils/{vsc/GitUtil.ts → StringUtil.ts} +19 -15
  18. package/constants/DevfilesRegistryConstants.ts +0 -26
  19. package/dist/configs/inversify.config.js +0 -70
  20. package/dist/configs/inversify.config.js.map +0 -1
  21. package/dist/configs/inversify.types.js +0 -45
  22. package/dist/configs/inversify.types.js.map +0 -1
  23. package/dist/configs/mocharc.js +0 -27
  24. package/dist/configs/mocharc.js.map +0 -1
  25. package/dist/constants/DevfilesRegistryConstants.js +0 -32
  26. package/dist/constants/DevfilesRegistryConstants.js.map +0 -1
  27. package/dist/constants/TestConstants.js +0 -207
  28. package/dist/constants/TestConstants.js.map +0 -1
  29. package/dist/constants/TimeoutConstants.js +0 -184
  30. package/dist/constants/TimeoutConstants.js.map +0 -1
  31. package/dist/driver/ChromeDriver.js +0 -79
  32. package/dist/driver/ChromeDriver.js.map +0 -1
  33. package/dist/driver/IDriver.js +0 -3
  34. package/dist/driver/IDriver.js.map +0 -1
  35. package/dist/index.js +0 -69
  36. package/dist/index.js.map +0 -1
  37. package/dist/pageobjects/dashboard/CreateWorkspace.js +0 -98
  38. package/dist/pageobjects/dashboard/CreateWorkspace.js.map +0 -1
  39. package/dist/pageobjects/dashboard/Dashboard.js +0 -135
  40. package/dist/pageobjects/dashboard/Dashboard.js.map +0 -1
  41. package/dist/pageobjects/dashboard/Workspaces.js +0 -184
  42. package/dist/pageobjects/dashboard/Workspaces.js.map +0 -1
  43. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +0 -140
  44. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +0 -1
  45. package/dist/pageobjects/git-providers/OauthPage.js +0 -150
  46. package/dist/pageobjects/git-providers/OauthPage.js.map +0 -1
  47. package/dist/pageobjects/ide/CheCodeLocatorLoader.js +0 -70
  48. package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +0 -1
  49. package/dist/pageobjects/login/ICheLoginPage.js +0 -12
  50. package/dist/pageobjects/login/ICheLoginPage.js.map +0 -1
  51. package/dist/pageobjects/login/IOcpLoginPage.js +0 -12
  52. package/dist/pageobjects/login/IOcpLoginPage.js.map +0 -1
  53. package/dist/pageobjects/login/OcpRedHatLoginPage.js +0 -67
  54. package/dist/pageobjects/login/OcpRedHatLoginPage.js.map +0 -1
  55. package/dist/pageobjects/login/OcpUserLoginPage.js +0 -53
  56. package/dist/pageobjects/login/OcpUserLoginPage.js.map +0 -1
  57. package/dist/pageobjects/login/RedHatLoginPage.js +0 -77
  58. package/dist/pageobjects/login/RedHatLoginPage.js.map +0 -1
  59. package/dist/pageobjects/login/RegularUserOcpCheLoginPage.js +0 -68
  60. package/dist/pageobjects/login/RegularUserOcpCheLoginPage.js.map +0 -1
  61. package/dist/pageobjects/openshift/CheLoginPage.js +0 -55
  62. package/dist/pageobjects/openshift/CheLoginPage.js.map +0 -1
  63. package/dist/pageobjects/openshift/OcpApplicationPage.js +0 -60
  64. package/dist/pageobjects/openshift/OcpApplicationPage.js.map +0 -1
  65. package/dist/pageobjects/openshift/OcpImportFromGitPage.js +0 -91
  66. package/dist/pageobjects/openshift/OcpImportFromGitPage.js.map +0 -1
  67. package/dist/pageobjects/openshift/OcpLoginPage.js +0 -92
  68. package/dist/pageobjects/openshift/OcpLoginPage.js.map +0 -1
  69. package/dist/pageobjects/openshift/OcpMainPage.js +0 -108
  70. package/dist/pageobjects/openshift/OcpMainPage.js.map +0 -1
  71. package/dist/specs/MochaHooks.js +0 -89
  72. package/dist/specs/MochaHooks.js.map +0 -1
  73. package/dist/specs/SmokeTest.spec.js +0 -49
  74. package/dist/specs/SmokeTest.spec.js.map +0 -1
  75. package/dist/specs/api/ContainerOverridesAPI.spec.js +0 -37
  76. package/dist/specs/api/ContainerOverridesAPI.spec.js.map +0 -1
  77. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +0 -40
  78. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +0 -1
  79. package/dist/specs/api/EmptyWorkspaceAPI.spec.js +0 -61
  80. package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +0 -1
  81. package/dist/specs/api/PodOverridesAPI.spec.js +0 -43
  82. package/dist/specs/api/PodOverridesAPI.spec.js.map +0 -1
  83. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js +0 -48
  84. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js.map +0 -1
  85. package/dist/specs/dashboard-samples/Quarkus.spec.js +0 -50
  86. package/dist/specs/dashboard-samples/Quarkus.spec.js.map +0 -1
  87. package/dist/specs/dashboard-samples/RecomendedExtentions.spec.js +0 -161
  88. package/dist/specs/dashboard-samples/RecomendedExtentions.spec.js.map +0 -1
  89. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +0 -75
  90. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +0 -1
  91. package/dist/specs/factory/Factory.spec.js +0 -160
  92. package/dist/specs/factory/Factory.spec.js.map +0 -1
  93. package/dist/specs/factory/NoSetupRepoFactory.spec.js +0 -228
  94. package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +0 -1
  95. package/dist/specs/factory/RefusedOAuthFactory.spec.js +0 -220
  96. package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +0 -1
  97. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +0 -66
  98. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +0 -1
  99. package/dist/tests-library/LoginTests.js +0 -70
  100. package/dist/tests-library/LoginTests.js.map +0 -1
  101. package/dist/tests-library/ProjectAndFileTests.js +0 -56
  102. package/dist/tests-library/ProjectAndFileTests.js.map +0 -1
  103. package/dist/tests-library/WorkspaceHandlingTests.js +0 -160
  104. package/dist/tests-library/WorkspaceHandlingTests.js.map +0 -1
  105. package/dist/utils/BrowserTabsUtil.js +0 -111
  106. package/dist/utils/BrowserTabsUtil.js.map +0 -1
  107. package/dist/utils/CheReporter.js +0 -172
  108. package/dist/utils/CheReporter.js.map +0 -1
  109. package/dist/utils/DevWorkspaceConfigurationHelper.js +0 -72
  110. package/dist/utils/DevWorkspaceConfigurationHelper.js.map +0 -1
  111. package/dist/utils/DriverHelper.js +0 -591
  112. package/dist/utils/DriverHelper.js.map +0 -1
  113. package/dist/utils/KubernetesCommandLineToolsExecutor.js +0 -162
  114. package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +0 -1
  115. package/dist/utils/Logger.js +0 -89
  116. package/dist/utils/Logger.js.map +0 -1
  117. package/dist/utils/Sanitizer.js +0 -29
  118. package/dist/utils/Sanitizer.js.map +0 -1
  119. package/dist/utils/ScreenCatcher.js +0 -107
  120. package/dist/utils/ScreenCatcher.js.map +0 -1
  121. package/dist/utils/ShellExecutor.js +0 -18
  122. package/dist/utils/ShellExecutor.js.map +0 -1
  123. package/dist/utils/request-handlers/CheApiRequestHandler.js +0 -126
  124. package/dist/utils/request-handlers/CheApiRequestHandler.js.map +0 -1
  125. package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js +0 -49
  126. package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +0 -1
  127. package/dist/utils/request-handlers/headers/IAuthorizationHeaderHandler.js +0 -12
  128. package/dist/utils/request-handlers/headers/IAuthorizationHeaderHandler.js.map +0 -1
  129. package/dist/utils/vsc/GitUtil.js +0 -57
  130. package/dist/utils/vsc/GitUtil.js.map +0 -1
  131. package/dist/utils/workspace/ApiUrlResolver.js +0 -64
  132. package/dist/utils/workspace/ApiUrlResolver.js.map +0 -1
  133. package/dist/utils/workspace/ITestWorkspaceUtil.js +0 -12
  134. package/dist/utils/workspace/ITestWorkspaceUtil.js.map +0 -1
  135. package/dist/utils/workspace/TestWorkspaceUtil.js +0 -167
  136. package/dist/utils/workspace/TestWorkspaceUtil.js.map +0 -1
  137. package/dist/utils/workspace/WorkspaceStatus.js +0 -19
  138. package/dist/utils/workspace/WorkspaceStatus.js.map +0 -1
  139. package/utils/Sanitizer.ts +0 -19
@@ -32,7 +32,6 @@ import { CheApiRequestHandler } from '../utils/request-handlers/CheApiRequestHan
32
32
  import { CreateWorkspace } from '../pageobjects/dashboard/CreateWorkspace';
33
33
  import { BrowserTabsUtil } from '../utils/BrowserTabsUtil';
34
34
  import { WorkspaceHandlingTests } from '../tests-library/WorkspaceHandlingTests';
35
- import { Sanitizer } from '../utils/Sanitizer';
36
35
  import { ApiUrlResolver } from '../utils/workspace/ApiUrlResolver';
37
36
  import { ITestWorkspaceUtil } from '../utils/workspace/ITestWorkspaceUtil';
38
37
  import { ProjectAndFileTests } from '../tests-library/ProjectAndFileTests';
@@ -42,6 +41,7 @@ import { OcpRedHatLoginPage } from '../pageobjects/login/OcpRedHatLoginPage';
42
41
  import { OcpMainPage } from '../pageobjects/openshift/OcpMainPage';
43
42
  import { OcpImportFromGitPage } from '../pageobjects/openshift/OcpImportFromGitPage';
44
43
  import { OcpApplicationPage } from '../pageobjects/openshift/OcpApplicationPage';
44
+ import { StringUtil } from '../utils/StringUtil';
45
45
 
46
46
  const e2eContainer: Container = new Container({defaultScope: 'Transient'});
47
47
 
@@ -67,7 +67,7 @@ e2eContainer.bind<CheApiRequestHandler>(CLASSES.CheApiRequestHandler).to(CheApiR
67
67
  e2eContainer.bind<CreateWorkspace>(CLASSES.CreateWorkspace).to(CreateWorkspace);
68
68
  e2eContainer.bind<ProjectAndFileTests>(CLASSES.ProjectAndFileTests).to(ProjectAndFileTests);
69
69
  e2eContainer.bind<LoginTests>(CLASSES.LoginTests).to(LoginTests);
70
- e2eContainer.bind<Sanitizer>(CLASSES.Sanitizer).to(Sanitizer);
70
+ e2eContainer.bind<StringUtil>(CLASSES.StringUtil).to(StringUtil);
71
71
  e2eContainer.bind<ApiUrlResolver>(CLASSES.ApiUrlResolver).to(ApiUrlResolver);
72
72
  e2eContainer.bind<WorkspaceHandlingTests>(CLASSES.WorkspaceHandlingTests).to(WorkspaceHandlingTests);
73
73
  e2eContainer.bind<RedHatLoginPage>(CLASSES.RedHatLoginPage).to(RedHatLoginPage);
@@ -8,7 +8,6 @@
8
8
  * SPDX-License-Identifier: EPL-2.0
9
9
  **********************************************************************/
10
10
 
11
-
12
11
  const TYPES: any = {
13
12
  Driver: Symbol.for('Driver'),
14
13
  CheLogin: Symbol.for('CheLogin'),
@@ -30,7 +29,7 @@ const CLASSES: any = {
30
29
  CreateWorkspace: 'CreateWorkspace',
31
30
  BrowserTabsUtil: 'BrowserTabsUtil',
32
31
  ProjectAndFileTests: 'ProjectAndFileTests',
33
- Sanitizer: 'Sanitizer',
32
+ StringUtil: 'StringUtil',
34
33
  ApiUrlResolver: 'ApiUrlResolver',
35
34
  LoginTests: 'LoginTests',
36
35
  WorkspaceHandlingTests: 'WorkspaceHandlingTests',
@@ -4,10 +4,10 @@ import { TestConstants } from '../constants/TestConstants';
4
4
 
5
5
  module.exports = {
6
6
  timeout: 1200000,
7
- reporter: './dist/utils/CheReporter.js',
7
+ reporter: 'dist/utils/CheReporter.js',
8
8
  ui: 'tdd',
9
9
  require: [
10
- './dist/specs/MochaHooks.js',
10
+ 'dist/specs/MochaHooks.js',
11
11
  'ts-node/register',
12
12
  ],
13
13
  bail: true,
@@ -7,32 +7,27 @@
7
7
  *
8
8
  * SPDX-License-Identifier: EPL-2.0
9
9
  **********************************************************************/
10
-
11
- function getBaseUrl(): string {
12
- const baseUrl: string | undefined = process.env.TS_SELENIUM_BASE_URL;
13
- if (!baseUrl) {
14
- return 'http://sample-url';
15
- }
16
-
17
- return baseUrl.replace(/\/$/, '');
18
- }
19
-
20
10
  export enum GitProviderType {
21
11
  GITHUB = 'github',
22
12
  GITLAB = 'gitlab',
23
13
  BITBUCKET = 'bitbucket'
24
14
  }
25
15
 
16
+
26
17
  export enum KubernetesCommandLineTool {
27
18
  OC = 'oc',
28
19
  KUBECTL = 'kubectl',
29
20
  }
30
21
 
22
+ export const SupportedDevfilesRegistries: any = {
23
+ INBUILT_APPLICATION_DEVFILE_REGISTRY_URL: () => `${TestConstants.TS_SELENIUM_BASE_URL}/devfile-registry/devfiles/`,
24
+ GIT_HUB_CHE_DEVFILE_REGISTRY_URL: `https://api.github.com/repos/eclipse-che/che-devfile-registry/contents/devfiles/`,
25
+ };
31
26
  export const TestConstants: any = {
32
27
  /**
33
28
  * Base URL of the application which should be checked
34
29
  */
35
- TS_SELENIUM_BASE_URL: getBaseUrl(),
30
+ TS_SELENIUM_BASE_URL: !process.env.TS_SELENIUM_BASE_URL ? 'http://sample-url' : process.env.TS_SELENIUM_BASE_URL.replace(/\/$/, ''),
36
31
 
37
32
  /**
38
33
  * Run browser in "Headless" (hidden) mode, "false" by default.
@@ -253,6 +248,8 @@ export const TestConstants: any = {
253
248
 
254
249
  TS_API_TEST_NAMESPACE: process.env.TS_API_TEST_NAMESPACE || undefined,
255
250
 
256
- // choose from repo https://github.com/eclipse-che/che-devfile-registry/tree/main/devfiles file as raw
257
- TS_API_TEST_LINK_TO_META_YAML: process.env.TS_API_TEST_LINK_TO_META_YAML || 'https://raw.githubusercontent.com/eclipse-che/che-devfile-registry/main/devfiles/java-web-spring/meta.yaml'
251
+ // to run all devfile from registry. used in DevfileAcceptanceTestAPI.suite.ts
252
+ TS_API_ACCEPTANCE_TEST_REGISTRY_URL(): string {
253
+ return process.env.TS_API_ACCEPTANCE_TEST_REGISTRY_URL || SupportedDevfilesRegistries.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL();
254
+ },
258
255
  };
package/index.ts CHANGED
@@ -6,25 +6,25 @@ export * from './constants/TimeoutConstants';
6
6
  export * from './driver/ChromeDriver';
7
7
  export * from './driver/IDriver';
8
8
  export * from './utils/BrowserTabsUtil';
9
+ export * from './utils/DevfilesRegistryHelper';
9
10
  export * from './utils/DevWorkspaceConfigurationHelper';
10
11
  export * from './utils/DriverHelper';
11
12
  export * from './utils/KubernetesCommandLineToolsExecutor';
12
13
  export * from './utils/Logger';
13
- export * from './utils/Sanitizer';
14
- export * from './utils/ScreenCatcher';
15
- export * from './utils/ShellExecutor';
16
14
  export * from './utils/request-handlers/CheApiRequestHandler';
17
15
  export * from './utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler';
18
16
  export * from './utils/request-handlers/headers/IAuthorizationHeaderHandler';
19
- export * from './utils/vsc/GitUtil';
17
+ export * from './utils/ScreenCatcher';
18
+ export * from './utils/ShellExecutor';
19
+ export * from './utils/StringUtil';
20
20
  export * from './utils/workspace/ApiUrlResolver';
21
21
  export * from './utils/workspace/ITestWorkspaceUtil';
22
22
  export * from './utils/workspace/TestWorkspaceUtil';
23
23
  export * from './utils/workspace/WorkspaceStatus';
24
24
  export * from './pageobjects/dashboard/CreateWorkspace';
25
25
  export * from './pageobjects/dashboard/Dashboard';
26
- export * from './pageobjects/dashboard/Workspaces';
27
26
  export * from './pageobjects/dashboard/workspace-details/WorkspaceDetails';
27
+ export * from './pageobjects/dashboard/Workspaces';
28
28
  export * from './pageobjects/git-providers/OauthPage';
29
29
  export * from './pageobjects/ide/CheCodeLocatorLoader';
30
30
  export * from './pageobjects/login/ICheLoginPage';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-che/che-e2e",
3
- "version": "7.68.0",
3
+ "version": "7.69.0-dev-ac76de0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -11,12 +11,13 @@
11
11
  "cleanup-docker": "if [ $(docker ps -a | grep -c selenium-e2e) -gt 0 ]; then docker rm -f $(docker ps --filter \"name=selenium-e2e\" -aq); fi;",
12
12
  "test-docker": "npm run cleanup-docker && docker run -it --shm-size=2g -p 5920:5920 --name selenium-e2e -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL eclipse/che-e2e:nightly",
13
13
  "test-docker-mount-e2e": "npm run cleanup-docker && docker run -it --shm-size=2g -p 5920:5920 --name selenium-e2e -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL -v $(pwd):/tmp/e2e:Z eclipse/che-e2e:nightly",
14
- "test-all-devfiles": " ./configs/sh-scripts/initDefaultValues.sh && ./configs/sh-scripts/initDevfileTests.sh"
14
+ "test-all-devfiles": " ./configs/sh-scripts/initDefaultValues.sh && ./configs/sh-scripts/initDevfileTests.sh",
15
+ "devfile-acceptance-test-suite": "./configs/sh-scripts/initDefaultValues.sh npm run lint && npm run tsc && export TS_USE_WEB_DRIVER_FOR_TEST=false && mocha 'dist/specs/api/*.js' --config dist/configs/mocharc.js --delay --grep 'Devfile acceptance test suite'"
15
16
  },
16
17
  "author": "Ihor Okhrimenko (iokhrime@redhat.com)",
17
18
  "license": "ISC",
18
19
  "devDependencies": {
19
- "@eclipse-che/che-devworkspace-generator": "next",
20
+ "@eclipse-che/che-devworkspace-generator": "7.68.0",
20
21
  "@types/chai": "^4.3.4",
21
22
  "@types/clone-deep": "^4.0.1",
22
23
  "@types/mocha": "5.2.6",
@@ -3,47 +3,104 @@ import { DevWorkspaceConfigurationHelper } from '../../utils/DevWorkspaceConfigu
3
3
  import { ShellString } from 'shelljs';
4
4
  import { expect } from 'chai';
5
5
  import { DevfileContext } from '@eclipse-che/che-devworkspace-generator/lib/api/devfile-context';
6
- import { TestConstants } from '../../constants/TestConstants';
7
- import { GitUtil } from '../../utils/vsc/GitUtil';
6
+ import { StringUtil } from '../../utils/StringUtil';
7
+ import { DevfilesRegistryHelper } from '../../utils/DevfilesRegistryHelper';
8
+ import { Logger } from '../../utils/Logger';
8
9
 
9
- suite(`Devfile acceptance test`, async function (): Promise<void> {
10
- let devfileUrl: string;
11
- let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
12
- let kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor;
13
- let devfileContext: DevfileContext;
14
- let devWorkspaceName: string | undefined;
10
+ /**
11
+ * Dynamically generating tests
12
+ * info: https://mochajs.org/#delayed-root-suite
13
+ */
15
14
 
16
- suiteSetup('Get DevWorkspace configuration from meta.yaml', async function (): Promise<void> {
17
- devfileUrl = await GitUtil.getProjectGitLinkFromLinkToMetaYaml(TestConstants.TS_API_TEST_LINK_TO_META_YAML);
15
+ (async function (): Promise<void> {
18
16
 
19
- devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
20
- devfileUrl,
21
- });
22
- devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
23
- devWorkspaceName = devfileContext?.devWorkspace?.metadata?.name;
17
+ const devfilesRegistryHelper: DevfilesRegistryHelper = new DevfilesRegistryHelper();
18
+ const devfileSamples: any = await devfilesRegistryHelper.collectPathsToDevfilesFromRegistry();
19
+
20
+ for (const devfileSample of devfileSamples) {
21
+ suite(`Devfile acceptance test suite for ${devfileSample.name}`, async function (): Promise<void> {
22
+ this.bail(false);
23
+ this.timeout(1500000); // 25 minutes because build of Quarkus sample takes 20+ minutes
24
+ let devWorkspaceConfigurationHelper: DevWorkspaceConfigurationHelper;
25
+ let kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor;
26
+ let containerTerminal: KubernetesCommandLineToolsExecutor.ContainerTerminal;
27
+ let devfileContext: DevfileContext;
28
+ let devWorkspaceName: string | undefined;
29
+ let clonedProjectName: string;
30
+ let containerWorkDir: string;
31
+ let devfilesBuildCommands: any[] = [];
32
+
33
+ test('Get DevWorkspace configuration', async function (): Promise<void> {
34
+ devWorkspaceConfigurationHelper = new DevWorkspaceConfigurationHelper({
35
+ devfileUrl: devfileSample.link,
36
+ });
37
+ devfileContext = await devWorkspaceConfigurationHelper.generateDevfileContext();
38
+ devWorkspaceName = devfileContext?.devWorkspace?.metadata?.name;
39
+
40
+ kubernetesCommandLineToolsExecutor = new KubernetesCommandLineToolsExecutor(devWorkspaceName);
41
+ containerTerminal = new KubernetesCommandLineToolsExecutor.ContainerTerminal(kubernetesCommandLineToolsExecutor);
42
+ kubernetesCommandLineToolsExecutor.loginToOcp();
43
+ });
44
+
45
+ test('Collect build commands from the devfile', async function (): Promise<void> {
46
+ if (devfileContext.devfile.commands === undefined) {
47
+ Logger.info(`Devfile does not contains any commands.`);
48
+ } else {
49
+ devfileContext.devfile.commands.forEach((command: any) => {
50
+ if (command.exec?.group?.kind === 'build') {
51
+ Logger.debug(`Build command found: ${command.exec.commandLine}`);
52
+ devfilesBuildCommands.push(command);
53
+ }
54
+ });
55
+ }
56
+ });
24
57
 
25
- kubernetesCommandLineToolsExecutor = new KubernetesCommandLineToolsExecutor(devWorkspaceName);
26
- kubernetesCommandLineToolsExecutor.loginToOcp();
27
- });
58
+ test('Create DevWorkspace', async function (): Promise<void> {
59
+ const devWorkspaceConfigurationYamlString: string = await devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
60
+ const applyOutput: ShellString = kubernetesCommandLineToolsExecutor.applyYamlConfigurationAsStringOutput(devWorkspaceConfigurationYamlString);
28
61
 
29
- test('Create DevWorkspace', async function (): Promise<void> {
30
- const devWorkspaceConfigurationYamlString: string = await devWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString(devfileContext);
31
- const applyOutput: ShellString = kubernetesCommandLineToolsExecutor.applyYamlConfigurationAsStringOutput(devWorkspaceConfigurationYamlString);
62
+ expect(applyOutput.stdout)
63
+ .contains('devworkspacetemplate')
64
+ .and.contains('devworkspace')
65
+ .and.contains.oneOf(['created', 'configured']);
32
66
 
33
- expect(applyOutput.stdout)
34
- .contains('devworkspacetemplate')
35
- .and.contains('devworkspace')
36
- .and.contains.oneOf(['created', 'configured']);
67
+ });
37
68
 
38
- });
69
+ test('Wait until DevWorkspace has status "ready"', async function (): Promise<void> {
70
+ expect(kubernetesCommandLineToolsExecutor.waitDevWorkspace().stdout).contains('condition met');
71
+ });
39
72
 
40
- test('Wait until DevWorkspace has status "ready"', async function (): Promise<void> {
41
- expect(kubernetesCommandLineToolsExecutor.waitDevWorkspace().stdout).contains('condition met');
42
- });
73
+ test('Check if project was created', function (): void {
74
+ clonedProjectName = StringUtil.getProjectNameFromGitUrl(devfileSample.link);
75
+ expect(containerTerminal.ls().stdout).includes(clonedProjectName);
76
+ });
43
77
 
44
- suiteTeardown('Delete DevWorkspace', async function (): Promise<void> {
45
- kubernetesCommandLineToolsExecutor.deleteDevWorkspace();
46
- });
47
- });
78
+ test('Check if project files are imported', function (): void {
79
+ containerWorkDir = containerTerminal.pwd().stdout.replace('\n', '');
80
+ expect(containerTerminal.ls(`${containerWorkDir}/${clonedProjectName}`).stdout).includes(`devfile.yaml`);
81
+ });
48
82
 
83
+ test(`Check if build commands returns success`, function (): void {
84
+ if (devfilesBuildCommands.length === 0) {
85
+ Logger.info(`Devfile does not contains build commands.`);
86
+ } else {
87
+ devfilesBuildCommands.forEach((command) => {
88
+ Logger.info(`command.exec: ${JSON.stringify(command.exec)}`);
89
+
90
+ const commandString: string = StringUtil.updateCommandEnvsToShStyle(`cd ${command.exec.workingDir} && ${command.exec.commandLine}`);
91
+ Logger.info(`Full build command to be executed: ${commandString}`);
92
+
93
+ const output: ShellString = containerTerminal.executeCommand(commandString, command.exec.component);
94
+ expect(output.code).eqls(0);
95
+ });
96
+ }
97
+ });
98
+
99
+ test('Delete DevWorkspace', async function (): Promise<void> {
100
+ kubernetesCommandLineToolsExecutor.deleteDevWorkspace();
101
+ });
102
+ });
103
+ }
49
104
 
105
+ run();
106
+ })();
@@ -1,7 +1,7 @@
1
1
  import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor';
2
2
  import { expect } from 'chai';
3
3
  import { ShellString } from 'shelljs';
4
- import { GitUtil } from '../../utils/vsc/GitUtil';
4
+ import { StringUtil } from '../../utils/StringUtil';
5
5
  import { TestConstants } from '../../constants/TestConstants';
6
6
  import { DevWorkspaceConfigurationHelper } from '../../utils/DevWorkspaceConfigurationHelper';
7
7
  import { DevfileContext } from '@eclipse-che/che-devworkspace-generator/lib/api/devfile-context';
@@ -51,11 +51,11 @@ suite(`Empty workspace API test`, async function (): Promise<void> {
51
51
  });
52
52
 
53
53
  test('Check if project was created', function (): void {
54
- clonedProjectName = GitUtil.getProjectNameFromGitUrl(gitRepository);
54
+ clonedProjectName = StringUtil.getProjectNameFromGitUrl(gitRepository);
55
55
  expect(containerTerminal.ls().stdout).includes(clonedProjectName);
56
56
  });
57
57
 
58
- test('Check if files were imported ', function (): void {
58
+ test('Check if project files are imported', function (): void {
59
59
  expect(containerTerminal.ls(`${containerWorkDir}/${clonedProjectName}`).stdout)
60
60
  .includes(TestConstants.TS_SELENIUM_PROJECT_ROOT_FILE_NAME);
61
61
  });
@@ -24,7 +24,7 @@ import { TestConstants } from '../../constants/TestConstants';
24
24
  import { OcpMainPage } from '../../pageobjects/openshift/OcpMainPage';
25
25
  import { OcpImportFromGitPage } from '../../pageobjects/openshift/OcpImportFromGitPage';
26
26
  import { KubernetesCommandLineToolsExecutor } from '../../utils/KubernetesCommandLineToolsExecutor';
27
- import { GitUtil } from '../../utils/vsc/GitUtil';
27
+ import { StringUtil } from '../../utils/StringUtil';
28
28
  import { OcpApplicationPage } from '../../pageobjects/openshift/OcpApplicationPage';
29
29
 
30
30
  const projectAndFileTests: ProjectAndFileTests = e2eContainer.get(CLASSES.ProjectAndFileTests);
@@ -84,7 +84,7 @@ suite(`DevConsole Integration`, async function (): Promise<void> {
84
84
  });
85
85
 
86
86
  test('Check if project and files imported', async function (): Promise<void> {
87
- const applicationSourceProjectName: string = GitUtil.getProjectNameFromGitUrl(gitImportRepo);
87
+ const applicationSourceProjectName: string = StringUtil.getProjectNameFromGitUrl(gitImportRepo);
88
88
  const projectSection: ViewSection = await new SideBarView().getContent().getSection(applicationSourceProjectName);
89
89
  const isFileImported: ViewItem | undefined = await projectSection.findItem(TestConstants.TS_SELENIUM_PROJECT_ROOT_FILE_NAME);
90
90
  expect(isFileImported).not.eqls(undefined);
@@ -28,7 +28,7 @@ import {
28
28
  import { TestConstants } from '../../constants/TestConstants';
29
29
  import { expect } from 'chai';
30
30
  import { OauthPage } from '../../pageobjects/git-providers/OauthPage';
31
- import { GitUtil } from '../../utils/vsc/GitUtil';
31
+ import { StringUtil } from '../../utils/StringUtil';
32
32
  import { CheCodeLocatorLoader } from '../../pageobjects/ide/CheCodeLocatorLoader';
33
33
  import { registerRunningWorkspace } from '../MochaHooks';
34
34
  import { BrowserTabsUtil } from '../../utils/BrowserTabsUtil';
@@ -88,7 +88,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE
88
88
  });
89
89
 
90
90
  test('Check if a project folder has been created', async function (): Promise<void> {
91
- testRepoProjectName = GitUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
91
+ testRepoProjectName = StringUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
92
92
  Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`);
93
93
  projectSection = await new SideBarView().getContent().getSection(testRepoProjectName);
94
94
  });
@@ -27,7 +27,7 @@ import {
27
27
  ViewSection
28
28
  } from 'monaco-page-objects';
29
29
  import { expect } from 'chai';
30
- import { GitUtil } from '../../utils/vsc/GitUtil';
30
+ import { StringUtil } from '../../utils/StringUtil';
31
31
  import { CheCodeLocatorLoader } from '../../pageobjects/ide/CheCodeLocatorLoader';
32
32
  import WebDriverError = error.WebDriverError;
33
33
  import { registerRunningWorkspace } from '../MochaHooks';
@@ -114,7 +114,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE
114
114
  });
115
115
 
116
116
  test('Check if a project folder has been created', async function (): Promise<void> {
117
- testRepoProjectName = GitUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
117
+ testRepoProjectName = StringUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
118
118
  Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`);
119
119
  projectSection = await new SideBarView().getContent().getSection(testRepoProjectName);
120
120
  });
@@ -37,7 +37,7 @@ import { ProjectAndFileTests } from '../../tests-library/ProjectAndFileTests';
37
37
  import { DriverHelper } from '../../utils/DriverHelper';
38
38
  import { TestConstants } from '../../constants/TestConstants';
39
39
  import { OauthPage } from '../../pageobjects/git-providers/OauthPage';
40
- import { GitUtil } from '../../utils/vsc/GitUtil';
40
+ import { StringUtil } from '../../utils/StringUtil';
41
41
  import { Logger } from '../../utils/Logger';
42
42
  import { TimeoutConstants } from '../../constants/TimeoutConstants';
43
43
  import { LoginTests } from '../../tests-library/LoginTests';
@@ -97,7 +97,7 @@ suite(`Create a workspace via launching a factory from the ${TestConstants.TS_SE
97
97
  });
98
98
 
99
99
  test('Check if a project folder has been created', async function (): Promise<void> {
100
- testRepoProjectName = GitUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
100
+ testRepoProjectName = StringUtil.getProjectNameFromGitUrl(TestConstants.TS_SELENIUM_FACTORY_GIT_REPO_URL);
101
101
  Logger.debug(`new SideBarView().getContent().getSection: get ${testRepoProjectName}`);
102
102
  projectSection = await new SideBarView().getContent().getSection(testRepoProjectName);
103
103
  });
@@ -18,13 +18,12 @@ import { ScreenCatcher } from './ScreenCatcher';
18
18
  import { ITestWorkspaceUtil } from './workspace/ITestWorkspaceUtil';
19
19
  import { TimeoutConstants } from '../constants/TimeoutConstants';
20
20
  import { Logger } from './Logger';
21
- import { Sanitizer } from './Sanitizer';
22
21
  import { e2eContainer } from '../configs/inversify.config';
23
22
  import { WriteStream } from 'fs';
23
+ import { StringUtil } from './StringUtil';
24
24
 
25
25
  const driverHelper: DriverHelper = e2eContainer.get(CLASSES.DriverHelper);
26
26
  const screenCatcher: ScreenCatcher = e2eContainer.get(CLASSES.ScreenCatcher);
27
- const sanitizer: Sanitizer = e2eContainer.get(CLASSES.Sanitizer);
28
27
  let methodIndex: number = 0;
29
28
  let deleteScreencast: boolean = true;
30
29
  let testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
@@ -129,10 +128,10 @@ class CheReporter extends mocha.reporters.Spec {
129
128
  deleteScreencast = false;
130
129
 
131
130
  Logger.trace(`FullTitle:${test.fullTitle()}`);
132
- const testFullTitle: string = sanitizer.sanitize(test.fullTitle());
131
+ const testFullTitle: string = StringUtil.sanitizeTitle(test.fullTitle());
133
132
  Logger.trace(`FullTitleSanitized:${testFullTitle}`);
134
133
  Logger.trace(`TestTitle:${test.title}`);
135
- const testTitle: string = sanitizer.sanitize(test.title);
134
+ const testTitle: string = StringUtil.sanitizeTitle(test.title);
136
135
  Logger.trace(`TestTitleSanitized:${testTitle}`);
137
136
 
138
137
  const testReportDirPath: string = `${TestConstants.TS_SELENIUM_REPORT_FOLDER}/${testFullTitle}`;
@@ -0,0 +1,77 @@
1
+ /*********************************************************************
2
+ * Copyright (c) 2023 Red Hat, Inc.
3
+ *
4
+ * This program and the accompanying materials are made
5
+ * available under the terms of the Eclipse Public License 2.0
6
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
7
+ *
8
+ * SPDX-License-Identifier: EPL-2.0
9
+ **********************************************************************/
10
+ import { SupportedDevfilesRegistries, TestConstants } from '../constants/TestConstants';
11
+ import axios, { AxiosResponse } from 'axios';
12
+ import { Logger } from './Logger';
13
+ import YAML from 'yaml';
14
+
15
+ export class DevfilesRegistryHelper {
16
+
17
+ async getInbuiltDevfilesRegistryContent(): Promise<AxiosResponse> {
18
+ Logger.debug(`${this.constructor.name}.${this.getInbuiltDevfilesRegistryContent.name}`);
19
+ return await this.getContent(SupportedDevfilesRegistries.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL());
20
+ }
21
+
22
+ async getGitHubCheDevfileRegistryContent(): Promise<AxiosResponse> {
23
+ Logger.debug(`${this.constructor.name}.${this.getGitHubCheDevfileRegistryContent.name}`);
24
+ return await this.getContent(SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL);
25
+ }
26
+
27
+ async collectPathsToDevfilesFromRegistry(): Promise<object[]> {
28
+ Logger.debug(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}`);
29
+ const devfileSamples: object[] = [];
30
+ const sampleNames: string[] = [];
31
+ switch (TestConstants.TS_API_ACCEPTANCE_TEST_REGISTRY_URL()) {
32
+ case (SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL): {
33
+ const content: any[any] = await this.getGitHubCheDevfileRegistryContent();
34
+ content.forEach((e: any) => {
35
+ if (e.name[0] !== '.') { sampleNames.push(e.name); }
36
+ });
37
+
38
+ for (const sample of sampleNames) {
39
+ const sampleEndpoint: string = `${SupportedDevfilesRegistries.GIT_HUB_CHE_DEVFILE_REGISTRY_URL}${sample}/meta.yaml`;
40
+ const sampleEndpointContent: AxiosResponse = await this.getContent(sampleEndpoint);
41
+ const decodedFileContent: string = Buffer.from((sampleEndpointContent as any).content, 'base64').toString();
42
+ const metaYamlContent: any = YAML.parse(decodedFileContent);
43
+ devfileSamples.push({name: sample, link: metaYamlContent.links.v2});
44
+ }
45
+ Logger.debug(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}: samples list: ${JSON.stringify(devfileSamples)}`);
46
+ }
47
+ break;
48
+ case (SupportedDevfilesRegistries.INBUILT_APPLICATION_DEVFILE_REGISTRY_URL()): {
49
+ const content: any[any] = await this.getInbuiltDevfilesRegistryContent();
50
+
51
+ for (const sample of content) {
52
+ devfileSamples.push({name: sample.displayName, link: sample.links.v2});
53
+ }
54
+ Logger.debug(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}: samples list: ${JSON.stringify(devfileSamples)}`);
55
+ }
56
+ break;
57
+ default: {
58
+ Logger.error(`${this.constructor.name}.${this.collectPathsToDevfilesFromRegistry.name}: unsupported registry url - ${TestConstants.TS_API_ACCEPTANCE_TEST_REGISTRY_URL()}\n
59
+ supported registries: ${JSON.stringify(SupportedDevfilesRegistries)}`);
60
+ }
61
+ }
62
+ return devfileSamples;
63
+ }
64
+
65
+ private async getContent(url: string, headers?: object): Promise<AxiosResponse> {
66
+ Logger.debug(`${this.constructor.name}.${this.getContent.name}: ${url}`);
67
+
68
+ let response: AxiosResponse | undefined;
69
+ try {
70
+ response = await axios.get(url, headers);
71
+ } catch (error) {
72
+ Logger.error(`${error} + ${url}`);
73
+ throw error;
74
+ }
75
+ return response?.data;
76
+ }
77
+ }
@@ -66,15 +66,12 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
66
66
  this.createNamespace();
67
67
  }
68
68
  this.applyYamlConfigurationAsStringOutput(yamlConfiguration);
69
- const output: ShellString = this.waitDevWorkspace();
70
- KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
71
- KubernetesCommandLineToolsExecutor.container = this.getContainerName();
72
- return output;
69
+ return this.waitDevWorkspace();
73
70
  }
74
71
 
75
- executeCommand(commandToExecute: string): ShellString {
72
+ executeCommand(commandToExecute: string, container: string = KubernetesCommandLineToolsExecutor.container): ShellString {
76
73
  Logger.debug(`${this.getLoggingName(this.executeCommand.name)}:`);
77
- return ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${KubernetesCommandLineToolsExecutor.container} -- sh -c "${commandToExecute}"`);
74
+ return ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} exec -i ${KubernetesCommandLineToolsExecutor.pod} -n ${this.namespace} -c ${container} -- sh -c '${commandToExecute}'`);
78
75
  }
79
76
 
80
77
  applyYamlConfigurationAsStringOutput(yamlConfiguration: string): ShellString {
@@ -96,7 +93,9 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
96
93
 
97
94
  waitDevWorkspace(timeout: number = 360): ShellString {
98
95
  Logger.debug(`${this.getLoggingName(this.waitDevWorkspace.name)}: Wait till workspace ready.`);
99
- return ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`);
96
+ const output: ShellString = ShellExecutor.execWithLog(`${(this.KUBERNETES_COMMAND_LINE_TOOL)} wait -n ${this.namespace} --for=condition=Ready dw ${this.workspaceName} --timeout=${timeout}s`);
97
+ this.getPodAndContainerNames();
98
+ return output;
100
99
  }
101
100
 
102
101
  createNamespace(): void {
@@ -114,6 +113,11 @@ export class KubernetesCommandLineToolsExecutor extends ShellExecutor {
114
113
  ShellExecutor.execWithLog(`${this.KUBERNETES_COMMAND_LINE_TOOL} delete project ${projectName} -n ${this.namespace}`);
115
114
  }
116
115
 
116
+ private getPodAndContainerNames(): void {
117
+ KubernetesCommandLineToolsExecutor.pod = this.getWorkspacePodName();
118
+ KubernetesCommandLineToolsExecutor.container = this.getContainerName();
119
+ }
120
+
117
121
  private isUserLoggedIn(): boolean {
118
122
  const whoamiCommandOutput: ShellString = ShellExecutor.execWithLog('oc whoami && oc whoami --show-server=true');
119
123
 
@@ -163,5 +167,14 @@ export namespace KubernetesCommandLineToolsExecutor {
163
167
  removeFolder(path: string): ShellString {
164
168
  return this.executeCommand('rm -rf ' + path);
165
169
  }
170
+
171
+ getEnvValue(envName: string): string {
172
+ envName = envName.replace(/[${}]/g, '');
173
+ const output: ShellString = this.executeCommand(`env | grep ${envName}`);
174
+ return output.stderr ? output.stderr :
175
+ output.stdout
176
+ .substring(output.stdout.lastIndexOf('=') + 1)
177
+ .replace('\n', '');
178
+ }
166
179
  }
167
180
  }
@@ -11,15 +11,14 @@ import * as fs from 'fs';
11
11
  import { injectable, inject } from 'inversify';
12
12
  import { CLASSES } from '../configs/inversify.types';
13
13
  import { DriverHelper } from './DriverHelper';
14
- import { Sanitizer } from './Sanitizer';
15
14
  import { error } from 'selenium-webdriver';
16
15
  import { TestConstants } from '../constants/TestConstants';
17
16
  import { WriteStream } from 'fs';
17
+ import { StringUtil } from './StringUtil';
18
18
 
19
19
  @injectable()
20
20
  export class ScreenCatcher {
21
- constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper,
22
- @inject(CLASSES.Sanitizer) private readonly sanitizer: Sanitizer) { }
21
+ constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }
23
22
 
24
23
  async catchMethodScreen(methodName: string, methodIndex: number, screenshotIndex: number): Promise<void> {
25
24
  const executionScreenCastDir: string = `${TestConstants.TS_SELENIUM_REPORT_FOLDER}/executionScreencast`;
@@ -38,7 +37,7 @@ export class ScreenCatcher {
38
37
  const date: Date = new Date();
39
38
  const timeStr: string = date.toLocaleTimeString('en-us', { hour12: false }) + '.' + new Intl.NumberFormat('en-us', { minimumIntegerDigits: 3 }).format(date.getMilliseconds());
40
39
 
41
- const screenshotPath: string = `${executionScreenCastDir}/${formattedMethodIndex}-${formattedScreenshotIndex}--(${this.sanitizer.sanitize(timeStr)})_${this.sanitizer.sanitize(methodName)}.png`;
40
+ const screenshotPath: string = `${executionScreenCastDir}/${formattedMethodIndex}-${formattedScreenshotIndex}--(${StringUtil.sanitizeTitle(timeStr)})_${StringUtil.sanitizeTitle(methodName)}.png`;
42
41
 
43
42
  try {
44
43
  await this.catchScreen(screenshotPath);