Skip to content

Commit 1b2592f

Browse files
authored
[Test] Update 'Factory' E2E test (#23311)
* Update 'Factory' e2e test * Add new constants * Add new method to Dashboard page object * Update files according to 'prettier' command
1 parent 49bdfa2 commit 1b2592f

File tree

5 files changed

+78
-47
lines changed

5 files changed

+78
-47
lines changed

tests/e2e/CODE_STYLE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ Automated lint checking and code format performs with ESLint and Prettier tools
3333
pre-commit hook.
3434
Full set of rules can be found:
3535

36-
- [.eslintrc](.eslintrc.js)
37-
- [.prettierrc](.prettierrc.json)
36+
- [.eslintrc](.eslintrc.js)
37+
- [.prettierrc](.prettierrc.json)
3838

3939
### Preferable code style
4040

tests/e2e/README.md

+37-37
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,33 @@
22

33
## Requirements
44

5-
- node 16.x
6-
- "Chrome" browser 114.x or later
7-
- deployed Che 7 with accessible URL
5+
- node 16.x
6+
- "Chrome" browser 114.x or later
7+
- deployed Che 7 with accessible URL
88

99
## Before launch
1010

1111
**Perform commands:**
1212

13-
- `export TS_SELENIUM_BASE_URL=<Che7 URL>`
14-
- `npm ci`
13+
- `export TS_SELENIUM_BASE_URL=<Che7 URL>`
14+
- `npm ci`
1515

1616
Note: If there is any modifications in package.json, manually execute the `npm install` to update the package-lock.json. So that errors can be avoided while executing npm ci
1717

1818
## Default launch
1919

20-
- Provide connection credentials:
21-
- `export TS_SELENIUM_OCP_USERNAME=<username>`
22-
- `export TS_SELENIUM_OCP_PASSWORD=<password>`
23-
- `npm run test`
20+
- Provide connection credentials:
21+
- `export TS_SELENIUM_OCP_USERNAME=<username>`
22+
- `export TS_SELENIUM_OCP_PASSWORD=<password>`
23+
- `npm run test`
2424

2525
## Custom launch
2626

27-
- Use environment variables which described in the "constants" folder
28-
- Use environment variables for setting timeouts if needed. You can see the list in **`'TimeoutConstants.ts'`**. You can see the list of those variables and their value if you set the `'TS_SELENIUM_PRINT_TIMEOUT_VARIABLES = true'`
29-
- To test one specification export file name as `export USERSTORY=<spec-file-name-without-extension> && npm run test` (example: `-e USERSTORY=Quarkus`)
30-
- To run test without Selenium WebDriver (API tests etc.) use `export USERSTORY=<spec-file-name-without-extension> && npm run driver-less-test` (example: `-e USERSTORY=CloneGitRepoAPI`)
31-
- This project support application testing deployed on Kubernetes or Openshift platform. Openshift is default value. To switch into Kubernetes, please, use `TS_PLATFORM=kubernetes` environmental variable and `TS_SELENIUM_K8S_PASSWORD`, `TS_SELENIUM_K8S_USERNAME` to provide credentials. The sample of test command in this case:
27+
- Use environment variables which described in the "constants" folder
28+
- Use environment variables for setting timeouts if needed. You can see the list in **`'TimeoutConstants.ts'`**. You can see the list of those variables and their value if you set the `'TS_SELENIUM_PRINT_TIMEOUT_VARIABLES = true'`
29+
- To test one specification export file name as `export USERSTORY=<spec-file-name-without-extension> && npm run test` (example: `-e USERSTORY=Quarkus`)
30+
- To run test without Selenium WebDriver (API tests etc.) use `export USERSTORY=<spec-file-name-without-extension> && npm run driver-less-test` (example: `-e USERSTORY=CloneGitRepoAPI`)
31+
- This project support application testing deployed on Kubernetes or Openshift platform. Openshift is default value. To switch into Kubernetes, please, use `TS_PLATFORM=kubernetes` environmental variable and `TS_SELENIUM_K8S_PASSWORD`, `TS_SELENIUM_K8S_USERNAME` to provide credentials. The sample of test command in this case:
3232
```
3333
export TS_PLATFORM=kubernetes && \
3434
export TS_SELENIUM_K8S_USERNAME=<username> && \
@@ -37,21 +37,21 @@ Note: If there is any modifications in package.json, manually execute the `npm i
3737
npm run test
3838
```
3939
Also, environmental variables can be set in files in "constants" folder.
40-
- Local test results can be represented with Allure reporter `npm run open-allure-dasboard`
40+
- Local test results can be represented with Allure reporter `npm run open-allure-dasboard`
4141
4242
## Docker launch
4343
44-
- open terminal and go to the "e2e" directory
45-
- export the `"TS_SELENIUM_BASE_URL"` variable with "Che" url
46-
- run command `"npm run test-docker"`
44+
- open terminal and go to the "e2e" directory
45+
- export the `"TS_SELENIUM_BASE_URL"` variable with "Che" url
46+
- run command `"npm run test-docker"`
4747
4848
## Docker launch with changed tests
4949
5050
**For launching tests with local changes perform next steps:**
5151
52-
- open terminal and go to the "e2e" directory
53-
- export the `"TS_SELENIUM_BASE_URL"` variable with "Che" url
54-
- run command `"npm run test-docker-mount-e2e"`
52+
- open terminal and go to the "e2e" directory
53+
- export the `"TS_SELENIUM_BASE_URL"` variable with "Che" url
54+
- run command `"npm run test-docker-mount-e2e"`
5555
5656
## Debug docker launch
5757
@@ -62,27 +62,27 @@ The `'eclipse/che-e2e'` docker image has VNC server installed inside. For connec
6262
**The easiest way to do that is to perform steps which are described in the "Docker launch" paragraph.
6363
For running tests without docker, please perform next steps:**
6464
65-
- Deploy Che on Kubernetes infrastructure by using 'Minikube' and 'Chectl' <https://github.com/eclipse-che/che-server/blob/HEAD/deploy/kubernetes/README.md>
66-
- Create workspace by using 'Chectl' and devfile
67-
- link to 'Chectl' manual <https://github.com/che-incubator/chectl#chectl-workspacestart>
68-
- link to devfile ( **`For successfull test passing, exactly provided devfile should be used`** )
69-
<https://gist.githubusercontent.com/Ohrimenko1988/93f5426f4ebc1705c55feb8ff0396a49/raw/cbea89ad145ba33ed34a151a12c50f045f9f3b78/yaml-ls-bug.yaml>
70-
- Provide the **`'TS_SELENIUM_BASE_URL'`** environment variable as described above
71-
- export TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME=EmptyWorkspace (default value, see BASE_TEST_CONSTANTS.ts)
72-
- perform command **`export USERSTORY=$TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME && npm run test-all-devfiles`**
65+
- Deploy Che on Kubernetes infrastructure by using 'Minikube' and 'Chectl' <https://github.com/eclipse-che/che-server/blob/HEAD/deploy/kubernetes/README.md>
66+
- Create workspace by using 'Chectl' and devfile
67+
- link to 'Chectl' manual <https://github.com/che-incubator/chectl#chectl-workspacestart>
68+
- link to devfile ( **`For successfull test passing, exactly provided devfile should be used`** )
69+
<https://gist.githubusercontent.com/Ohrimenko1988/93f5426f4ebc1705c55feb8ff0396a49/raw/cbea89ad145ba33ed34a151a12c50f045f9f3b78/yaml-ls-bug.yaml>
70+
- Provide the **`'TS_SELENIUM_BASE_URL'`** environment variable as described above
71+
- export TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME=EmptyWorkspace (default value, see BASE_TEST_CONSTANTS.ts)
72+
- perform command **`export USERSTORY=$TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME && npm run test-all-devfiles`**
7373
7474
## Launching the DevWorkspaceHappyPath spec file using Che with oauth authentication
7575
7676
**Setup next environment variables:**
7777
78-
- export TS_SELENIUM_BASE_URL=\<Che-URL\>
79-
- export TS_SELENIUM_OCP_USERNAME=\<cluster-username\>
80-
- export TS_SELENIUM_OCP_PASSWORD=\<cluster-password\>
81-
- export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH="true"
82-
- export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=\<login-provide-title\>
83-
- export TS_SELENIUM_DEVWORKSPACE_URL=\<devworkspace-url\>
84-
- export TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME=EmptyWorkspace (default value, see BASE_TEST_CONSTANTS.ts)
78+
- export TS_SELENIUM_BASE_URL=\<Che-URL\>
79+
- export TS_SELENIUM_OCP_USERNAME=\<cluster-username\>
80+
- export TS_SELENIUM_OCP_PASSWORD=\<cluster-password\>
81+
- export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH="true"
82+
- export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=\<login-provide-title\>
83+
- export TS_SELENIUM_DEVWORKSPACE_URL=\<devworkspace-url\>
84+
- export TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME=EmptyWorkspace (default value, see BASE_TEST_CONSTANTS.ts)
8585
8686
**Execute the npm command:**
8787
88-
- perform command `export USERSTORY=$TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME && npm run test-all-devfiles`
88+
- perform command `export USERSTORY=$TS_SELENIUM_HAPPY_PATH_WORKSPACE_NAME && npm run test-all-devfiles`

tests/e2e/constants/BASE_TEST_CONSTANTS.ts

+15
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export enum Platform {
1515
export const BASE_TEST_CONSTANTS: {
1616
OCP_INFRA: string;
1717
DELETE_WORKSPACE_ON_FAILED_TEST: boolean;
18+
DELETE_WORKSPACE_ON_SUCCESSFUL_TEST: boolean;
19+
SELECT_OPENING_EXISTING_WORKSPACE_INSTEAD_OF_CREATION_NEW: boolean;
1820
IS_CLUSTER_DISCONNECTED: () => boolean;
1921
IS_PRODUCT_DOCUMENTATION_RELEASED: any;
2022
OCP_VERSION: string;
@@ -130,6 +132,19 @@ export const BASE_TEST_CONSTANTS: {
130132
*/
131133
DELETE_WORKSPACE_ON_FAILED_TEST: process.env.DELETE_WORKSPACE_ON_FAILED_TEST === 'true',
132134

135+
/**
136+
* stop and remove workspace if a test is successful.
137+
* true by default.
138+
*/
139+
DELETE_WORKSPACE_ON_SUCCESSFUL_TEST: process.env.DELETE_WORKSPACE_ON_SUCCESSFUL_TEST !== 'false',
140+
141+
/**
142+
* select opening an existing workspace instead of creating a new one, if a duplicate workspace is created from the factory or sample list.
143+
* this option is false by default.
144+
*/
145+
SELECT_OPENING_EXISTING_WORKSPACE_INSTEAD_OF_CREATION_NEW:
146+
process.env.SELECT_OPENING_EXISTING_WORKSPACE_INSTEAD_OF_CREATION_NEW === 'true',
147+
133148
/**
134149
* constant, which prolong timeout constants for local debug.
135150
*/

tests/e2e/pageobjects/dashboard/Dashboard.ts

+7
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export class Dashboard {
3939
username: 'username'
4040
};
4141
private static readonly CONTINUE_WITH_DEFAULT_DEVFILE_BUTTON: By = By.xpath('//button[text()="Continue with default devfile"]');
42+
private static readonly OPEN_EXISTING_WORKSPACE_LINK: By = By.xpath('//button[text()="Open the existing workspace"]');
4243

4344
constructor(
4445
@inject(CLASSES.DriverHelper)
@@ -176,6 +177,12 @@ export class Dashboard {
176177
await this.driverHelper.waitAndClick(Dashboard.CREATE_NEW_WORKSPACE_LINK, timeout);
177178
}
178179

180+
async clickOpenExistingWorkspaceButton(timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
181+
Logger.debug();
182+
183+
await this.driverHelper.waitAndClick(Dashboard.OPEN_EXISTING_WORKSPACE_LINK, timeout);
184+
}
185+
179186
async logout(timeout: number = TIMEOUT_CONSTANTS.TS_COMMON_DASHBOARD_WAIT_TIMEOUT): Promise<void> {
180187
Logger.debug();
181188

tests/e2e/specs/factory/Factory.spec.ts

+17-8
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ suite(
8888
});
8989
}
9090

91+
if (BASE_TEST_CONSTANTS.SELECT_OPENING_EXISTING_WORKSPACE_INSTEAD_OF_CREATION_NEW) {
92+
test('Select opening an existing workspace instead of creating a new one', async function (): Promise<void> {
93+
await dashboard.waitExistingWorkspaceFoundAlert();
94+
await dashboard.clickOpenExistingWorkspaceButton();
95+
});
96+
}
97+
9198
test('Obtain workspace name from workspace loader page', async function (): Promise<void> {
9299
await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
93100
});
@@ -209,14 +216,16 @@ suite(
209216
await browserTabsUtil.closeAllTabsExceptCurrent();
210217
});
211218

212-
suiteTeardown('Stop and delete the workspace by API', async function (): Promise<void> {
213-
// to avoid a possible creating workspace which is not appeared on Dashboard yet. TODO: implement a better solution.
214-
await driverHelper.wait(30000);
215-
await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
216-
});
219+
if (BASE_TEST_CONSTANTS.DELETE_WORKSPACE_ON_SUCCESSFUL_TEST) {
220+
suiteTeardown('Stop and delete the workspace by API', async function (): Promise<void> {
221+
// to avoid a possible creating workspace which is not appeared on Dashboard yet. TODO: implement a better solution.
222+
await driverHelper.wait(30000);
223+
await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
224+
});
217225

218-
suiteTeardown('Unregister running workspace', function (): void {
219-
registerRunningWorkspace('');
220-
});
226+
suiteTeardown('Unregister running workspace', function (): void {
227+
registerRunningWorkspace('');
228+
});
229+
}
221230
}
222231
);

0 commit comments

Comments
 (0)