@eclipse-che/che-e2e 7.115.0-next-c2e9cd1 → 7.115.0-next-0acf8c1
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.
- package/.claude/commands/run-e2e-test.md +573 -0
- package/.claude/settings.local.json +13 -0
- package/.claude/skills/e2e-test-developer/SKILL.md +456 -0
- package/CLAUDE.md +150 -0
- package/README.md +1 -1
- package/constants/TIMEOUT_CONSTANTS.ts +6 -0
- package/dist/constants/TIMEOUT_CONSTANTS.js +4 -0
- package/dist/constants/TIMEOUT_CONSTANTS.js.map +1 -1
- package/dist/pageobjects/dashboard/Dashboard.js +9 -1
- package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
- package/dist/specs/dashboard-samples/StartWorkspaceUsingVSCodeDesktopSshEditor.spec.js +123 -0
- package/dist/specs/dashboard-samples/StartWorkspaceUsingVSCodeDesktopSshEditor.spec.js.map +1 -0
- package/dist/tests-library/ProjectAndFileTests.js +1 -1
- package/dist/tests-library/ProjectAndFileTests.js.map +1 -1
- package/dist/tests-library/WorkspaceHandlingTests.js +26 -0
- package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
- package/package.json +1 -1
- package/pageobjects/dashboard/Dashboard.ts +13 -1
- package/specs/dashboard-samples/StartWorkspaceUsingVSCodeDesktopSshEditor.spec.ts +143 -0
- package/tests-library/ProjectAndFileTests.ts +1 -1
- package/tests-library/WorkspaceHandlingTests.ts +32 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: e2e-test-developer
|
|
3
|
+
description: Comprehensive E2E test development guidance for Eclipse Che / Red Hat OpenShift Dev Spaces. Use this skill when writing, modifying, or reviewing TypeScript Mocha Selenium tests, page objects, utilities, or test infrastructure. Provides code style rules, patterns, dependency injection setup, and best practices.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Eclipse Che E2E TypeScript Mocha Selenium Test Development Skill
|
|
7
|
+
|
|
8
|
+
You are a Software Quality Engineer, who is an expert developer for Eclipse Che / Red Hat OpenShift Dev Spaces E2E tests. This skill provides comprehensive guidance for developing and maintaining E2E TypeScript Mocha Selenium tests.
|
|
9
|
+
|
|
10
|
+
## Project Overview
|
|
11
|
+
|
|
12
|
+
This is the E2E test suite for Eclipse Che / Red Hat OpenShift Dev Spaces. It uses:
|
|
13
|
+
|
|
14
|
+
- **Selenium WebDriver** with Chrome browser
|
|
15
|
+
- **Mocha** (TDD style - `suite()`, `test()`, `suiteSetup()`, `suiteTeardown()`)
|
|
16
|
+
- **TypeScript** with strict type checking
|
|
17
|
+
- **Inversify** for dependency injection
|
|
18
|
+
- **Chai** for assertions
|
|
19
|
+
- **Allure** for test reporting
|
|
20
|
+
|
|
21
|
+
## Directory Structure
|
|
22
|
+
|
|
23
|
+
| Directory | Purpose |
|
|
24
|
+
| -------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| `specs/` | Test specifications organized by category (api/, factory/, dashboard-samples/, miscellaneous/) |
|
|
26
|
+
| `pageobjects/` | Page Object classes for UI elements (dashboard/, ide/, login/, openshift/, git-providers/, webterminal/) |
|
|
27
|
+
| `utils/` | Utilities (DriverHelper, BrowserTabsUtil, Logger, API handlers, KubernetesCommandLineToolsExecutor) |
|
|
28
|
+
| `tests-library/` | Reusable test helpers (WorkspaceHandlingTests, LoginTests, ProjectAndFileTests) |
|
|
29
|
+
| `constants/` | Environment variable mappings (BASE_TEST_CONSTANTS, TIMEOUT_CONSTANTS, FACTORY_TEST_CONSTANTS, etc.) |
|
|
30
|
+
| `configs/` | Mocha config, Inversify container (inversify.config.ts), shell scripts |
|
|
31
|
+
| `suites/` | Test suite configurations for different environments |
|
|
32
|
+
| `driver/` | Chrome driver configuration |
|
|
33
|
+
| `build/dockerfiles/` | Docker image for running tests |
|
|
34
|
+
|
|
35
|
+
## Essential Commands
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Install dependencies
|
|
39
|
+
npm ci
|
|
40
|
+
|
|
41
|
+
# Lint and format
|
|
42
|
+
npm run lint
|
|
43
|
+
npm run prettier
|
|
44
|
+
|
|
45
|
+
# Build TypeScript only
|
|
46
|
+
npm run tsc
|
|
47
|
+
|
|
48
|
+
# Run all tests (requires environment variables)
|
|
49
|
+
export TS_SELENIUM_BASE_URL=<che-url>
|
|
50
|
+
export TS_SELENIUM_OCP_USERNAME=<username>
|
|
51
|
+
export TS_SELENIUM_OCP_PASSWORD=<password>
|
|
52
|
+
npm run test
|
|
53
|
+
|
|
54
|
+
# Run a single test file (without .spec.ts extension)
|
|
55
|
+
export USERSTORY=SmokeTest
|
|
56
|
+
npm run test
|
|
57
|
+
|
|
58
|
+
# Run API-only tests (no browser)
|
|
59
|
+
export USERSTORY=EmptyWorkspaceAPI
|
|
60
|
+
npm run driver-less-test
|
|
61
|
+
|
|
62
|
+
# View Allure test report
|
|
63
|
+
npm run open-allure-dasboard
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## CODE STYLE REQUIREMENTS (CRITICAL)
|
|
67
|
+
|
|
68
|
+
### File Header (Required for ALL .ts files)
|
|
69
|
+
|
|
70
|
+
Every TypeScript file MUST start with this exact header:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
/** *******************************************************************
|
|
74
|
+
* copyright (c) 2026 Red Hat, Inc.
|
|
75
|
+
*
|
|
76
|
+
* This program and the accompanying materials are made
|
|
77
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
78
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
79
|
+
*
|
|
80
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
81
|
+
**********************************************************************/
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Page Object and Utility Classes
|
|
85
|
+
|
|
86
|
+
1. **Class Declaration with Dependency Injection**
|
|
87
|
+
- Use `@injectable()` decorator on ALL page objects and utilities
|
|
88
|
+
- Use constructor injection with `@inject()` decorators
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { inject, injectable } from 'inversify';
|
|
92
|
+
import 'reflect-metadata';
|
|
93
|
+
import { CLASSES } from '../../configs/inversify.types';
|
|
94
|
+
|
|
95
|
+
@injectable()
|
|
96
|
+
export class MyPageObject {
|
|
97
|
+
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) {}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
2. **Public Methods**
|
|
102
|
+
- Declare public methods WITHOUT the `public` keyword
|
|
103
|
+
- Add `Logger.debug()` at the START of every public method
|
|
104
|
+
- Always specify explicit return types
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
async clickButton(timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise<void> {
|
|
108
|
+
Logger.debug();
|
|
109
|
+
await this.driverHelper.waitAndClick(MyPage.BUTTON_LOCATOR, timeout);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
3. **Locators**
|
|
114
|
+
- Static locators: `private static readonly` fields of type `By`
|
|
115
|
+
- Dynamic locators: `private` methods that return `By`
|
|
116
|
+
- NEVER declare locators as constants inside methods
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
// Static locators (correct)
|
|
120
|
+
private static readonly SUBMIT_BUTTON: By = By.xpath('//button[@type="submit"]');
|
|
121
|
+
private static readonly INPUT_FIELD: By = By.id('input-field');
|
|
122
|
+
|
|
123
|
+
// Dynamic locators (correct)
|
|
124
|
+
private getItemLocator(itemName: string): By {
|
|
125
|
+
return By.xpath(`//div[text()="${itemName}"]`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// WRONG - Never do this inside a method
|
|
129
|
+
async wrongMethod(): Promise<void> {
|
|
130
|
+
const locator: By = By.xpath('//button'); // AVOID THIS
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Member Ordering (Enforced by ESLint)
|
|
135
|
+
|
|
136
|
+
Classes must follow this order:
|
|
137
|
+
|
|
138
|
+
1. Static fields
|
|
139
|
+
2. Public fields
|
|
140
|
+
3. Instance fields
|
|
141
|
+
4. Protected fields
|
|
142
|
+
5. Private fields
|
|
143
|
+
6. Abstract fields
|
|
144
|
+
7. Constructor
|
|
145
|
+
8. Public static methods
|
|
146
|
+
9. Protected static methods
|
|
147
|
+
10. Private static methods
|
|
148
|
+
11. Public methods
|
|
149
|
+
12. Protected methods
|
|
150
|
+
13. Private methods
|
|
151
|
+
|
|
152
|
+
### Test File Conventions
|
|
153
|
+
|
|
154
|
+
1. **Naming**
|
|
155
|
+
|
|
156
|
+
- UI tests: `*.spec.ts` (e.g., `Factory.spec.ts`)
|
|
157
|
+
- API-only tests: `*API.spec.ts` (e.g., `EmptyWorkspaceAPI.spec.ts`)
|
|
158
|
+
|
|
159
|
+
2. **Mocha TDD Style (Required)**
|
|
160
|
+
- Use `suite()`, `test()`, `suiteSetup()`, `suiteTeardown()`
|
|
161
|
+
- NEVER use arrow functions in test declarations (Mocha context issue)
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
suite('My Test Suite', function (): void {
|
|
165
|
+
// Inject dependencies inside suite() to avoid unnecessary execution
|
|
166
|
+
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
|
|
167
|
+
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
|
|
168
|
+
|
|
169
|
+
suiteSetup('Login to application', async function (): Promise<void> {
|
|
170
|
+
await loginTests.loginIntoChe();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('Verify dashboard is visible', async function (): Promise<void> {
|
|
174
|
+
await dashboard.waitPage();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
suiteTeardown('Cleanup', async function (): Promise<void> {
|
|
178
|
+
// cleanup code
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
3. **Dependency Injection in Tests**
|
|
184
|
+
- Import container: `import { e2eContainer } from '../../configs/inversify.config';`
|
|
185
|
+
- Import types: `import { CLASSES, TYPES } from '../../configs/inversify.types';`
|
|
186
|
+
- Get instances inside suite() function
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import { e2eContainer } from '../../configs/inversify.config';
|
|
190
|
+
import { CLASSES, TYPES } from '../../configs/inversify.types';
|
|
191
|
+
|
|
192
|
+
suite('Test Suite', function (): void {
|
|
193
|
+
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
194
|
+
const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
|
|
195
|
+
// ... test implementation
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### TypeScript Requirements
|
|
200
|
+
|
|
201
|
+
1. **Explicit Type Annotations Required**
|
|
202
|
+
- All parameters must have type annotations
|
|
203
|
+
- All property declarations must have type annotations
|
|
204
|
+
- All variable declarations must have type annotations
|
|
205
|
+
- All functions must have explicit return types
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
// Correct
|
|
209
|
+
async function doSomething(param: string, timeout: number): Promise<void> {
|
|
210
|
+
const result: string = await someOperation();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Wrong - missing types
|
|
214
|
+
async function doSomething(param, timeout) {
|
|
215
|
+
const result = await someOperation();
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
2. **Naming Conventions**
|
|
220
|
+
|
|
221
|
+
- Variables: camelCase or UPPER_CASE
|
|
222
|
+
- No leading/trailing underscores
|
|
223
|
+
|
|
224
|
+
3. **String Quotes**
|
|
225
|
+
|
|
226
|
+
- Use single quotes for strings
|
|
227
|
+
|
|
228
|
+
4. **Comments**
|
|
229
|
+
- Comments must start with lowercase (capitalized-comments: never)
|
|
230
|
+
- Mark workarounds with `// todo` and issue number: `// todo commented due to issue crw-1010`
|
|
231
|
+
|
|
232
|
+
### Prettier and ESLint
|
|
233
|
+
|
|
234
|
+
- Pre-commit hooks run automatically via Husky
|
|
235
|
+
- Run `npm run prettier` to fix formatting
|
|
236
|
+
- Run `npm run lint` to fix linting issues
|
|
237
|
+
|
|
238
|
+
## Environment Variables
|
|
239
|
+
|
|
240
|
+
Core variables (defined in `constants/` directory):
|
|
241
|
+
|
|
242
|
+
| Variable | Description |
|
|
243
|
+
| ------------------------------------- | -------------------------------------------- |
|
|
244
|
+
| `TS_SELENIUM_BASE_URL` | Che/DevSpaces dashboard URL |
|
|
245
|
+
| `TS_SELENIUM_OCP_USERNAME` | OpenShift username |
|
|
246
|
+
| `TS_SELENIUM_OCP_PASSWORD` | OpenShift password |
|
|
247
|
+
| `USERSTORY` | Specific test file to run (without .spec.ts) |
|
|
248
|
+
| `TS_PLATFORM` | `openshift` (default) or `kubernetes` |
|
|
249
|
+
| `TS_SELENIUM_FACTORY_GIT_REPO_URL` | Git repo for factory tests |
|
|
250
|
+
| `TS_SELENIUM_VALUE_OPENSHIFT_OAUTH` | Enable OAuth (true/false) |
|
|
251
|
+
| `TS_SELENIUM_LOG_LEVEL` | Logging level (TRACE, DEBUG, INFO, etc.) |
|
|
252
|
+
| `DELETE_WORKSPACE_ON_SUCCESSFUL_TEST` | Delete workspace on success |
|
|
253
|
+
|
|
254
|
+
## Adding New Page Objects
|
|
255
|
+
|
|
256
|
+
1. Create file in appropriate `pageobjects/` subdirectory
|
|
257
|
+
2. Add `@injectable()` decorator
|
|
258
|
+
3. Register in `configs/inversify.config.ts`
|
|
259
|
+
4. Add class identifier in `configs/inversify.types.ts`
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
// 1. Create pageobjects/dashboard/NewPage.ts
|
|
263
|
+
@injectable()
|
|
264
|
+
export class NewPage {
|
|
265
|
+
private static readonly ELEMENT_LOCATOR: By = By.id('element');
|
|
266
|
+
|
|
267
|
+
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) {}
|
|
268
|
+
|
|
269
|
+
async waitForElement(): Promise<void> {
|
|
270
|
+
Logger.debug();
|
|
271
|
+
await this.driverHelper.waitVisibility(NewPage.ELEMENT_LOCATOR);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// 2. Add to configs/inversify.types.ts
|
|
276
|
+
const CLASSES: any = {
|
|
277
|
+
// ... existing classes
|
|
278
|
+
NewPage: 'NewPage'
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
// 3. Add to configs/inversify.config.ts
|
|
282
|
+
import { NewPage } from '../pageobjects/dashboard/NewPage';
|
|
283
|
+
e2eContainer.bind<NewPage>(CLASSES.NewPage).to(NewPage);
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Adding New Tests
|
|
287
|
+
|
|
288
|
+
1. Create file in appropriate `specs/` subdirectory
|
|
289
|
+
2. Follow naming convention (*.spec.ts for UI, *API.spec.ts for API)
|
|
290
|
+
3. Use TDD style (suite, test, suiteSetup, suiteTeardown)
|
|
291
|
+
4. Run with `export USERSTORY=<filename-without-extension> && npm run test`
|
|
292
|
+
|
|
293
|
+
## Common Utilities
|
|
294
|
+
|
|
295
|
+
### DriverHelper (utils/DriverHelper.ts)
|
|
296
|
+
|
|
297
|
+
- `waitVisibility(locator, timeout)` - Wait for element to be visible
|
|
298
|
+
- `waitAndClick(locator, timeout)` - Wait and click element
|
|
299
|
+
- `waitAndGetText(locator, timeout)` - Wait and get text
|
|
300
|
+
- `waitDisappearance(locator, timeout)` - Wait for element to disappear
|
|
301
|
+
- `navigateToUrl(url)` - Navigate to URL
|
|
302
|
+
- `wait(ms)` - Wait for specified milliseconds
|
|
303
|
+
|
|
304
|
+
### BrowserTabsUtil (utils/BrowserTabsUtil.ts)
|
|
305
|
+
|
|
306
|
+
- `navigateTo(url)` - Navigate to URL
|
|
307
|
+
- `getCurrentUrl()` - Get current URL
|
|
308
|
+
- `maximize()` - Maximize browser window
|
|
309
|
+
- `closeAllTabsExceptCurrent()` - Close extra tabs
|
|
310
|
+
|
|
311
|
+
### Logger (utils/Logger.ts)
|
|
312
|
+
|
|
313
|
+
- `Logger.debug()` - Log method name (use at start of public methods)
|
|
314
|
+
- `Logger.info(message)` - Log info message
|
|
315
|
+
- `Logger.error(message)` - Log error message
|
|
316
|
+
|
|
317
|
+
## GitHub Actions Maintenance
|
|
318
|
+
|
|
319
|
+
### PR Check Workflow (.github/workflows/pr-check.yml)
|
|
320
|
+
|
|
321
|
+
Triggers on:
|
|
322
|
+
|
|
323
|
+
- Pull requests to main or 7.\*\*.x branches
|
|
324
|
+
- Changes in `tests/e2e/**` or the workflow file
|
|
325
|
+
|
|
326
|
+
Steps performed:
|
|
327
|
+
|
|
328
|
+
1. Prettier check - Fails if formatting issues found
|
|
329
|
+
2. TypeScript compilation - `npm run tsc`
|
|
330
|
+
3. ESLint check - `npm run lint`
|
|
331
|
+
4. Deploy Che on minikube
|
|
332
|
+
5. Run Empty Workspace API test
|
|
333
|
+
6. Build E2E Docker image
|
|
334
|
+
7. Run Empty Workspace UI test
|
|
335
|
+
|
|
336
|
+
When modifying tests:
|
|
337
|
+
|
|
338
|
+
- Ensure `npm run prettier` passes locally
|
|
339
|
+
- Ensure `npm run tsc` compiles without errors
|
|
340
|
+
- Ensure `npm run lint` passes
|
|
341
|
+
- Test locally if possible before pushing
|
|
342
|
+
|
|
343
|
+
## Test Patterns
|
|
344
|
+
|
|
345
|
+
### Workspace Lifecycle Pattern
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
suite('Workspace Test', function (): void {
|
|
349
|
+
const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests);
|
|
350
|
+
const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil);
|
|
351
|
+
const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests);
|
|
352
|
+
|
|
353
|
+
suiteSetup('Login', async function (): Promise<void> {
|
|
354
|
+
await loginTests.loginIntoChe();
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
test('Create workspace', async function (): Promise<void> {
|
|
358
|
+
await workspaceHandlingTests.createAndStartWorkspace();
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
test('Obtain workspace name', async function (): Promise<void> {
|
|
362
|
+
await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage();
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
test('Register running workspace', function (): void {
|
|
366
|
+
registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName());
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
suiteTeardown('Stop and delete workspace', async function (): Promise<void> {
|
|
370
|
+
await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName());
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### API Test Pattern (No Browser)
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
suite('API Test', function (): void {
|
|
379
|
+
const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get(
|
|
380
|
+
CLASSES.KubernetesCommandLineToolsExecutor
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
suiteSetup('Setup', async function (): Promise<void> {
|
|
384
|
+
kubernetesCommandLineToolsExecutor.loginToOcp();
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
test('Execute API operation', function (): void {
|
|
388
|
+
const output: ShellString = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(yaml);
|
|
389
|
+
expect(output.stdout).contains('condition met');
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
suiteTeardown('Cleanup', function (): void {
|
|
393
|
+
kubernetesCommandLineToolsExecutor.deleteDevWorkspace();
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
## Package Management
|
|
399
|
+
|
|
400
|
+
- Add packages as **dev dependencies**: `npm install --save-dev <package>`
|
|
401
|
+
- After any changes to package.json, regenerate lock file: `npm install`
|
|
402
|
+
- Run `npm ci` for clean install from lock file
|
|
403
|
+
|
|
404
|
+
## Debugging
|
|
405
|
+
|
|
406
|
+
- Set `TS_SELENIUM_LOG_LEVEL=TRACE` for verbose logging
|
|
407
|
+
- Use VNC on port 5920 when running in Docker
|
|
408
|
+
- View test results with `npm run open-allure-dasboard`
|
|
409
|
+
- Screenshots are captured on test failures by CheReporter
|
|
410
|
+
|
|
411
|
+
## Common Issues and Solutions
|
|
412
|
+
|
|
413
|
+
1. **Flaky Tests**: Increase timeout or add explicit waits with `DriverHelper.wait()`
|
|
414
|
+
2. **Element Not Found**: Verify locator with browser dev tools, check for dynamic loading
|
|
415
|
+
3. **Stale Element**: Re-fetch element after page navigation
|
|
416
|
+
4. **Timeout Errors**: Use appropriate timeout constants from `TIMEOUT_CONSTANTS`
|
|
417
|
+
|
|
418
|
+
## Maintenance Guidelines
|
|
419
|
+
|
|
420
|
+
When helping with E2E test development and maintenance:
|
|
421
|
+
|
|
422
|
+
1. **Keep command files up to date** - When test infrastructure changes (new environment variables, test patterns, or execution methods), update the command file `.claude/commands/run-e2e-test.md`.
|
|
423
|
+
|
|
424
|
+
2. **Review test-specific parameters** - When adding or modifying tests that require new environment variables, update the "Test-Specific Parameters" section in the command files.
|
|
425
|
+
|
|
426
|
+
3. **Validate examples** - Ensure code examples and commands in documentation match current implementation patterns.
|
|
427
|
+
|
|
428
|
+
4. **Check for deprecated patterns** - When refactoring, search for outdated patterns across both test code and documentation.
|
|
429
|
+
|
|
430
|
+
5. **Update inversify configuration** - When adding new page objects or utilities, ensure both `inversify.types.ts` and `inversify.config.ts` are updated.
|
|
431
|
+
|
|
432
|
+
## Related Commands
|
|
433
|
+
|
|
434
|
+
### `/run-e2e-test` - Unified E2E Test Runner
|
|
435
|
+
|
|
436
|
+
Run E2E tests against **Eclipse Che** or **Red Hat OpenShift Dev Spaces** using either a **local Chrome browser** or **Podman container**.
|
|
437
|
+
|
|
438
|
+
**Usage:** `/run-e2e-test [URL USERNAME PASSWORD [TESTNAME] [METHOD]]`
|
|
439
|
+
|
|
440
|
+
**Features:**
|
|
441
|
+
|
|
442
|
+
- **Interactive mode**: Run without arguments to be prompted for all parameters
|
|
443
|
+
- **Auto-detect platform**: Determines Eclipse Che vs Dev Spaces from URL
|
|
444
|
+
- **Smart rebuild**: Detects local code changes vs `origin/main` and rebuilds only when needed
|
|
445
|
+
- **Test-specific parameters**: Prompts for additional env vars based on selected test type
|
|
446
|
+
|
|
447
|
+
**Examples:**
|
|
448
|
+
|
|
449
|
+
- `/run-e2e-test` - Interactive mode (recommended)
|
|
450
|
+
- `/run-e2e-test https://devspaces.apps.example.com/ admin password SmokeTest npm`
|
|
451
|
+
- `/run-e2e-test https://che.apps.example.com/ admin password EmptyWorkspace podman`
|
|
452
|
+
|
|
453
|
+
**Run methods:**
|
|
454
|
+
|
|
455
|
+
- `npm` - Local Chrome browser (faster, see browser in real-time)
|
|
456
|
+
- `podman` - Isolated container with VNC support at `localhost:5920`
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
**Available skills:**
|
|
6
|
+
|
|
7
|
+
- `/e2e-test-developer` - Comprehensive E2E test development guidance (code style, patterns, architecture)
|
|
8
|
+
|
|
9
|
+
**Available custom commands:**
|
|
10
|
+
|
|
11
|
+
- `/run-e2e-test` - Run E2E tests against Eclipse Che or Red Hat OpenShift Dev Spaces using local browser or Podman container
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
This is the E2E test suite for Eclipse Che / Red Hat OpenShift Dev Spaces. It uses Selenium WebDriver with Chrome, Mocha (TDD style), and TypeScript to test workspace creation, IDE functionality, and platform integrations.
|
|
16
|
+
|
|
17
|
+
## Quick Reference
|
|
18
|
+
|
|
19
|
+
### Essential Commands
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm ci # Install dependencies
|
|
23
|
+
npm run test # Run all tests
|
|
24
|
+
npm run lint # Fix linting issues
|
|
25
|
+
npm run prettier # Fix formatting
|
|
26
|
+
npm run tsc # Compile TypeScript
|
|
27
|
+
export USERSTORY=TestName && npm run test # Run single test
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Key Files to Read
|
|
31
|
+
|
|
32
|
+
- `CODE_STYLE.md` - **CRITICAL**: Coding standards (read before writing any code)
|
|
33
|
+
- `README.md` - Setup and launch instructions
|
|
34
|
+
- `configs/inversify.config.ts` - Dependency injection container
|
|
35
|
+
- `configs/inversify.types.ts` - Class and type identifiers
|
|
36
|
+
- `constants/TIMEOUT_CONSTANTS.ts` - Timeout values for waits
|
|
37
|
+
|
|
38
|
+
## Code Style Requirements (CRITICAL)
|
|
39
|
+
|
|
40
|
+
**Always read `CODE_STYLE.md` before modifying code.**
|
|
41
|
+
|
|
42
|
+
### Required File Header
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
/** *******************************************************************
|
|
46
|
+
* copyright (c) 2023 Red Hat, Inc.
|
|
47
|
+
*
|
|
48
|
+
* This program and the accompanying materials are made
|
|
49
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
50
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
51
|
+
*
|
|
52
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
53
|
+
**********************************************************************/
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Page Object Pattern
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
@injectable()
|
|
60
|
+
export class MyPage {
|
|
61
|
+
private static readonly BUTTON: By = By.xpath('//button');
|
|
62
|
+
|
|
63
|
+
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) {}
|
|
64
|
+
|
|
65
|
+
async clickButton(): Promise<void> {
|
|
66
|
+
Logger.debug();
|
|
67
|
+
await this.driverHelper.waitAndClick(MyPage.BUTTON);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private getDynamicLocator(name: string): By {
|
|
71
|
+
return By.xpath(`//div[text()="${name}"]`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Test Structure (TDD Style - No Arrow Functions)
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
suite('Suite Name', function (): void {
|
|
80
|
+
const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard);
|
|
81
|
+
|
|
82
|
+
suiteSetup('Setup', async function (): Promise<void> {
|
|
83
|
+
// setup code
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('Test case', async function (): Promise<void> {
|
|
87
|
+
// test code
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
suiteTeardown('Cleanup', async function (): Promise<void> {
|
|
91
|
+
// cleanup code
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Key Rules
|
|
97
|
+
|
|
98
|
+
- `@injectable()` on all page objects and utilities
|
|
99
|
+
- `Logger.debug()` at start of every public method
|
|
100
|
+
- Static locators: `private static readonly NAME: By`
|
|
101
|
+
- Dynamic locators: private methods returning `By`
|
|
102
|
+
- NO arrow functions in Mocha declarations
|
|
103
|
+
- Explicit return types on ALL functions
|
|
104
|
+
- Single quotes for strings
|
|
105
|
+
- Comments start lowercase: `// todo issue crw-1010`
|
|
106
|
+
|
|
107
|
+
## Directory Structure
|
|
108
|
+
|
|
109
|
+
| Directory | Purpose |
|
|
110
|
+
| ---------------- | ----------------------------------------------------- |
|
|
111
|
+
| `specs/` | Test files (api/, factory/, miscellaneous/) |
|
|
112
|
+
| `pageobjects/` | Page Object classes |
|
|
113
|
+
| `utils/` | DriverHelper, Logger, API handlers |
|
|
114
|
+
| `tests-library/` | Reusable helpers (LoginTests, WorkspaceHandlingTests) |
|
|
115
|
+
| `constants/` | Environment variables and timeouts |
|
|
116
|
+
| `configs/` | Inversify DI, Mocha config |
|
|
117
|
+
|
|
118
|
+
## Adding New Components
|
|
119
|
+
|
|
120
|
+
### New Page Object
|
|
121
|
+
|
|
122
|
+
1. Create in `pageobjects/<category>/NewPage.ts`
|
|
123
|
+
2. Add to `inversify.types.ts`: `NewPage: 'NewPage'`
|
|
124
|
+
3. Add to `inversify.config.ts`: `e2eContainer.bind<NewPage>(CLASSES.NewPage).to(NewPage)`
|
|
125
|
+
|
|
126
|
+
### New Test
|
|
127
|
+
|
|
128
|
+
1. Create `specs/<category>/TestName.spec.ts`
|
|
129
|
+
2. Run: `export USERSTORY=TestName && npm run test`
|
|
130
|
+
|
|
131
|
+
## GitHub Actions
|
|
132
|
+
|
|
133
|
+
PR checks run on changes to `tests/e2e/**`:
|
|
134
|
+
|
|
135
|
+
1. Prettier formatting check
|
|
136
|
+
2. TypeScript compilation
|
|
137
|
+
3. ESLint linting
|
|
138
|
+
4. API and UI tests on minikube
|
|
139
|
+
|
|
140
|
+
**Before pushing**: Run `npm run prettier && npm run tsc && npm run lint`
|
|
141
|
+
|
|
142
|
+
## Environment Variables
|
|
143
|
+
|
|
144
|
+
| Variable | Description |
|
|
145
|
+
| -------------------------- | ----------------------------------- |
|
|
146
|
+
| `TS_SELENIUM_BASE_URL` | Che dashboard URL |
|
|
147
|
+
| `TS_SELENIUM_OCP_USERNAME` | OpenShift username |
|
|
148
|
+
| `TS_SELENIUM_OCP_PASSWORD` | OpenShift password |
|
|
149
|
+
| `USERSTORY` | Test file to run (without .spec.ts) |
|
|
150
|
+
| `TS_PLATFORM` | `openshift` or `kubernetes` |
|
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ Note: If there is any modifications in package.json, manually execute the `npm i
|
|
|
55
55
|
|
|
56
56
|
## Debug docker launch
|
|
57
57
|
|
|
58
|
-
The `'eclipse/che-e2e'` docker image has VNC server installed inside. For connecting use `'0.0.0.0:5920'` address.
|
|
58
|
+
The `'quay.io/eclipse/che-e2e'` docker image has VNC server installed inside. For connecting use `'0.0.0.0:5920'` address.
|
|
59
59
|
|
|
60
60
|
## The "Happy Path" scenario launching
|
|
61
61
|
|
|
@@ -17,6 +17,7 @@ export const TIMEOUT_CONSTANTS: {
|
|
|
17
17
|
TS_EXPAND_PROJECT_TREE_ITEM_TIMEOUT: number;
|
|
18
18
|
TS_FIND_EXTENSION_TEST_TIMEOUT: number;
|
|
19
19
|
TS_IDE_LOAD_TIMEOUT: number;
|
|
20
|
+
TS_IDE_START_TIMEOUT: number;
|
|
20
21
|
TS_NOTIFICATION_WAIT_TIMEOUT: number;
|
|
21
22
|
TS_SELENIUM_CLICK_ON_VISIBLE_ITEM: number;
|
|
22
23
|
TS_SELENIUM_DEFAULT_ATTEMPTS: number;
|
|
@@ -49,6 +50,11 @@ export const TIMEOUT_CONSTANTS: {
|
|
|
49
50
|
*/
|
|
50
51
|
TS_IDE_LOAD_TIMEOUT: Number(process.env.TS_IDE_LOAD_TIMEOUT) || 20_000,
|
|
51
52
|
|
|
53
|
+
/**
|
|
54
|
+
* timeout for waiting for IDE to start during workspace startup, "310 000" by default.
|
|
55
|
+
*/
|
|
56
|
+
TS_IDE_START_TIMEOUT: Number(process.env.TS_IDE_START_TIMEOUT) || 310_000,
|
|
57
|
+
|
|
52
58
|
/**
|
|
53
59
|
* timeout in milliseconds waiting for workspace start, "360 000" by default.
|
|
54
60
|
*/
|
|
@@ -28,6 +28,10 @@ exports.TIMEOUT_CONSTANTS = {
|
|
|
28
28
|
* wait between workspace started and IDE ready to be used, "20 000" by default.
|
|
29
29
|
*/
|
|
30
30
|
TS_IDE_LOAD_TIMEOUT: Number(process.env.TS_IDE_LOAD_TIMEOUT) || 20000,
|
|
31
|
+
/**
|
|
32
|
+
* timeout for waiting for IDE to start during workspace startup, "310 000" by default.
|
|
33
|
+
*/
|
|
34
|
+
TS_IDE_START_TIMEOUT: Number(process.env.TS_IDE_START_TIMEOUT) || 310000,
|
|
31
35
|
/**
|
|
32
36
|
* timeout in milliseconds waiting for workspace start, "360 000" by default.
|
|
33
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TIMEOUT_CONSTANTS.js","sourceRoot":"","sources":["../../constants/TIMEOUT_CONSTANTS.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;wEAQwE;AAC3D,QAAA,iBAAiB,
|
|
1
|
+
{"version":3,"file":"TIMEOUT_CONSTANTS.js","sourceRoot":"","sources":["../../constants/TIMEOUT_CONSTANTS.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;wEAQwE;AAC3D,QAAA,iBAAiB,GAoB1B;IACH;;OAEG;IACH,4BAA4B,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,IAAI,CAAC;IAEnF;;OAEG;IACH,2BAA2B,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,IAAI,IAAI;IAEpF,mHAAmH;IAEnH;;OAEG;IACH,wBAAwB,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,KAAM;IAEhF;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,KAAM;IAEtE;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,MAAO;IAEzE;;OAEG;IACH,mCAAmC,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,IAAI,MAAO;IAEvG;;OAEG;IACH,6BAA6B,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,IAAI,KAAM;IAE1F;;OAEG;IACH,8BAA8B,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,IAAI,KAAM;IAE5F;;OAEG;IACH,+BAA+B,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,IAAI,KAAM;IAE9F,sGAAsG;IAEtG;;OAEG;IACH,gCAAgC,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,IAAI,IAAK;IAE/F;;OAEG;IACH,+BAA+B,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,IAAI,IAAK;IAE7F;;OAEG;IACH,mCAAmC,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,IAAI,KAAM;IAEtG,yGAAyG;IAEzG;;OAEG;IACH,mCAAmC,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,IAAI,IAAK;IAErG,mGAAmG;IAEnG;;OAEG;IACH,iCAAiC,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,IAAI,KAAM;IAE7F,gGAAgG;IAEhG;;OAEG;IACH,gCAAgC,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,IAAI,KAAM;IAEhG;;OAEG;IACH,iCAAiC,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,IAAI,IAAK;IAEjG;;OAEG;IACH,4BAA4B,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,IAAI,KAAM;IAExF,8FAA8F;IAE9F;;OAEG;IACH,6BAA6B,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,IAAI,KAAM;IAE1F;;OAEG;IACH,8BAA8B,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,IAAI,KAAM;CAC5F,CAAC"}
|
|
@@ -42,7 +42,6 @@ let Dashboard = Dashboard_1 = class Dashboard {
|
|
|
42
42
|
await this.clickWorkspacesButton();
|
|
43
43
|
await this.workspaces.waitPage();
|
|
44
44
|
await this.workspaces.waitWorkspaceListItem(workspaceName);
|
|
45
|
-
await this.workspaces.waitWorkspaceWithRunningStatus(workspaceName);
|
|
46
45
|
await this.workspaces.stopWorkspaceByActionsButton(workspaceName);
|
|
47
46
|
await this.workspaces.waitWorkspaceWithStoppedStatus(workspaceName);
|
|
48
47
|
}
|
|
@@ -160,6 +159,14 @@ let Dashboard = Dashboard_1 = class Dashboard {
|
|
|
160
159
|
Logger_1.Logger.debug();
|
|
161
160
|
await this.driverHelper.waitAndClick(Dashboard_1.CONTINUE_WITH_DEFAULT_DEVFILE_BUTTON, timeout);
|
|
162
161
|
}
|
|
162
|
+
async openChooseEditorMenu(timeout = TIMEOUT_CONSTANTS_1.TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT) {
|
|
163
|
+
Logger_1.Logger.debug('open "choose Editor" menu');
|
|
164
|
+
await this.driverHelper.waitAndClick(Dashboard_1.CHOOSE_EDITOR_MENU, timeout);
|
|
165
|
+
}
|
|
166
|
+
async chooseEditor(editor, timeout = TIMEOUT_CONSTANTS_1.TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT) {
|
|
167
|
+
Logger_1.Logger.debug('select Editor. Editor: ' + editor);
|
|
168
|
+
await this.driverHelper.waitAndClick(selenium_webdriver_1.By.xpath(editor), timeout);
|
|
169
|
+
}
|
|
163
170
|
getAboutMenuItemButtonLocator(text) {
|
|
164
171
|
return selenium_webdriver_1.By.xpath(`//li/button[text()="${text}"]`);
|
|
165
172
|
}
|
|
@@ -190,6 +197,7 @@ Dashboard.ABOUT_DIALOG_ITEM_DATA_TEST_IDS = {
|
|
|
190
197
|
};
|
|
191
198
|
Dashboard.CONTINUE_WITH_DEFAULT_DEVFILE_BUTTON = selenium_webdriver_1.By.xpath('//button[text()="Continue with default devfile"]');
|
|
192
199
|
Dashboard.OPEN_EXISTING_WORKSPACE_LINK = selenium_webdriver_1.By.xpath('//button[text()="Open the existing workspace"]');
|
|
200
|
+
Dashboard.CHOOSE_EDITOR_MENU = selenium_webdriver_1.By.xpath('//*[@id="accordion-item-selector"]');
|
|
193
201
|
Dashboard = Dashboard_1 = __decorate([
|
|
194
202
|
(0, inversify_1.injectable)(),
|
|
195
203
|
__param(0, (0, inversify_1.inject)(inversify_types_1.CLASSES.DriverHelper)),
|