From f62822560cedb26cbdc4e839fa43d7b1f072084c Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Mon, 15 Dec 2025 01:44:47 +0200 Subject: [PATCH 1/8] Add claude commands and skill for E2E test development --- .../commands/run-che-e2e-test-locally.md | 286 ++++++++++++ .../commands/run-che-e2e-test-using-podman.md | 216 +++++++++ .../run-devspaces-e2e-test-locally.md | 323 +++++++++++++ .../run-devspaces-e2e-test-using-podman.md | 259 +++++++++++ .../.claude/skills/e2e-test-development.md | 425 ++++++++++++++++++ tests/e2e/CLAUDE.md | 146 ++++++ 6 files changed, 1655 insertions(+) create mode 100644 tests/e2e/.claude/commands/run-che-e2e-test-locally.md create mode 100644 tests/e2e/.claude/commands/run-che-e2e-test-using-podman.md create mode 100644 tests/e2e/.claude/commands/run-devspaces-e2e-test-locally.md create mode 100644 tests/e2e/.claude/commands/run-devspaces-e2e-test-using-podman.md create mode 100644 tests/e2e/.claude/skills/e2e-test-development.md create mode 100644 tests/e2e/CLAUDE.md diff --git a/tests/e2e/.claude/commands/run-che-e2e-test-locally.md b/tests/e2e/.claude/commands/run-che-e2e-test-locally.md new file mode 100644 index 00000000000..0bc4330eb44 --- /dev/null +++ b/tests/e2e/.claude/commands/run-che-e2e-test-locally.md @@ -0,0 +1,286 @@ +# Run E2E Tests Using Local Browser + +Run E2E tests against Eclipse Che using a local Chrome browser. This is useful for development and debugging as you can see the browser in real-time. + +## Execution Mode - ASK USER FIRST + +Before proceeding, ask the user which execution mode they prefer using AskUserQuestion: + +1. **Just bash command** - Provide only the bash command to run the test (assumes dependencies installed and code already compiled) +2. **Build and run** - Check for changes in the working directory (`git status`), rebuild if there are modifications, then run the test +3. **Check staged changes only** - Only rebuild if there are git staged changes, otherwise just run the test + +Based on the user's choice: +- **Just bash command**: Skip build steps, provide `export USERSTORY= && npm run test` command +- **Build and run**: Run `npm ci && npm run tsc` before the test if `git status` shows any changes +- **Check staged changes only**: Run `git diff --cached --name-only` to check for staged changes; rebuild only if staged files exist in the e2e directory + +## Required Parameters - ASK USER + +Before running tests, you MUST ask the user for these required parameters using AskUserQuestion: + +1. **Eclipse Che URL** (`TS_SELENIUM_BASE_URL`) - The Che dashboard URL + + - Example: `https://che.apps.ocp.crw-qe.com/` + +2. **Test Name** (`USERSTORY`) - Which test to run + + - Common options: `EmptyWorkspace`, `Factory`, `SmokeTest`, `EmptyWorkspaceAPI` + +3. **Username** (`TS_SELENIUM_OCP_USERNAME`) - OpenShift/Kubernetes username + + - Example: `admin`, `developer`, `che@eclipse.org` + +4. **Password** (`TS_SELENIUM_OCP_PASSWORD`) - OpenShift/Kubernetes password + +5. **Platform** (`TS_PLATFORM`) - Optional, deployment platform + - Options: `openshift` (default), `kubernetes` + +## Test-Specific Parameters - ASK BASED ON TEST NAME + +After getting the test name, read the test spec file to identify additional required parameters. +Use `cat specs/**/${USERSTORY}.spec.ts` to find the test file and look for environment variables used. + +### Factory URL Tests (Factory, RefusedOAuthFactory, NoSetupRepoFactory, etc.) +These tests navigate directly to a factory URL to create a workspace. +Ask for these additional parameters: +- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository to clone (used to construct the factory URL) +- **Git Provider** (`TS_SELENIUM_FACTORY_GIT_PROVIDER`) - `github`, `gitlab`, `bitbucket`, `azure-devops` +- **OAuth Enabled** (`TS_SELENIUM_GIT_PROVIDER_OAUTH`) - `true` or `false` + +### Git Repo Import Form Tests (FactoryWithGitRepoOptions, CreateWorkspaceWithExistingNameFromGitUrl, etc.) +These tests use the Dashboard's "Create Workspace" form to import a git repository. +Ask for these additional parameters: +- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository URL to enter in the form +- **Branch Name** (`TS_SELENIUM_FACTORY_GIT_REPO_BRANCH`) - Optional, branch to checkout (default: `main`) +- **Project Name** (`TS_SELENIUM_PROJECT_NAME`) - Optional, expected project folder name + +### API Tests (EmptyWorkspaceAPI, ContainerOverridesAPI, etc.) +Ask for: +- **Namespace** (`TS_API_TEST_NAMESPACE`) - Optional, for specific namespace testing +- **UDI Image** (`TS_API_TEST_UDI_IMAGE`) - Optional, custom Universal Developer Image + +### Sample/Devfile Tests +Ask for: +- **Sample List** (`TS_SAMPLE_LIST`) - Which samples to test, e.g., `Node.js Express` + +### SSH/PAT Tests (SshUrlNoOauthPatFactory, etc.) +Ask for: +- **SSH Private Key Path** or **Personal Access Token** details as needed by the test + +## Prerequisites + +1. **Node.js 22.x** (use nvm to manage versions) +2. **Chrome browser** version 114.x or later +3. **ChromeDriver** matching your Chrome version (installed via npm) +4. Environment variables configured + +## Full Test Run (Recommended) + +Complete workflow with clean build and all checks: + +```bash +cd tests/e2e + +# Use correct Node.js version +nvm use v22.10.0 + +# Set environment variables +export TS_SELENIUM_LOG_LEVEL="TRACE" +export TS_SELENIUM_BASE_URL=https://che.apps.cluster.example.com/ +export TS_SELENIUM_OCP_USERNAME=admin +export TS_SELENIUM_OCP_PASSWORD=password +export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 +export VIDEO_RECORDING=true +export TS_DEBUG_MODE=true +export NODE_TLS_REJECT_UNAUTHORIZED=0 +export TS_DELETE_WORKSPACE_ON_FAILED_TEST=true +export USERSTORY=EmptyWorkspace + +# Clean build and run tests +rm -rf node_modules dist && npm ci && npm run lint && npm run prettier && npm run tsc && npm test +``` + +## Quick Setup + +```bash +cd tests/e2e + +# Use correct Node.js version +nvm use v22.10.0 + +# Install dependencies +npm ci + +# Export required environment variables +export TS_SELENIUM_BASE_URL= +export TS_SELENIUM_OCP_USERNAME= +export TS_SELENIUM_OCP_PASSWORD= +export NODE_TLS_REJECT_UNAUTHORIZED=0 +``` + +## Running Tests + +### Run Specific Test File + +```bash +# UI test +export USERSTORY=SmokeTest && npm run test + +# Factory test +export USERSTORY=Factory && npm run test + +# API-only test (no browser) +export USERSTORY=EmptyWorkspaceAPI && npm run driver-less-test +``` + +### Run with Verbose Logging + +```bash +export TS_SELENIUM_LOG_LEVEL=TRACE +export USERSTORY=SmokeTest && npm run test +``` + +## Common Test Configurations + +### OpenShift with OAuth + +```bash +export TS_SELENIUM_BASE_URL=https://che.apps.cluster.example.com +export TS_SELENIUM_OCP_USERNAME=admin +export TS_SELENIUM_OCP_PASSWORD=password +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true +export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd +export NODE_TLS_REJECT_UNAUTHORIZED=0 +export USERSTORY=Factory && npm run test +``` + +### OpenShift without OAuth + +```bash +export TS_SELENIUM_BASE_URL=https://che.apps.cluster.example.com +export TS_SELENIUM_OCP_USERNAME=admin +export TS_SELENIUM_OCP_PASSWORD=password +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=false +export NODE_TLS_REJECT_UNAUTHORIZED=0 +export USERSTORY=EmptyWorkspace && npm run test +``` + +### Kubernetes Platform + +```bash +export TS_PLATFORM=kubernetes +export TS_SELENIUM_BASE_URL=https://che.192.168.99.100.nip.io +export TS_SELENIUM_K8S_USERNAME=che@eclipse.org +export TS_SELENIUM_K8S_PASSWORD=admin +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=false +export NODE_TLS_REJECT_UNAUTHORIZED=0 +export USERSTORY=EmptyWorkspace && npm run test +``` + +### Factory Tests with Git Provider + +```bash +export TS_SELENIUM_BASE_URL=https://devspaces.example.com +export TS_SELENIUM_OCP_USERNAME=user +export TS_SELENIUM_OCP_PASSWORD=password +export TS_SELENIUM_FACTORY_GIT_REPO_URL=https://github.com/user/repo +export TS_SELENIUM_FACTORY_GIT_PROVIDER=github +export TS_SELENIUM_GIT_PROVIDER_OAUTH=true +export USERSTORY=Factory && npm run test +``` + +## Timeout Configuration + +Adjust timeouts for slower environments: + +```bash +export TS_SELENIUM_LOAD_PAGE_TIMEOUT=60000 +export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 +export TS_COMMON_DASHBOARD_WAIT_TIMEOUT=30000 +export MOCHA_DEFAULT_TIMEOUT=420000 +``` + +## Headless Mode + +For CI environments or when you don't need to see the browser: + +```bash +export TS_SELENIUM_HEADLESS=true +export USERSTORY=SmokeTest && npm run test +``` + +## Debug Mode + +Enable detailed logging for troubleshooting: + +```bash +export TS_SELENIUM_LOG_LEVEL=TRACE +export TS_SELENIUM_PRINT_TIMEOUT_VARIABLES=true +export USERSTORY=SmokeTest && npm run test +``` + +## View Test Reports + +After test execution, view Allure reports: + +```bash +npm run open-allure-dasboard +``` + +## Pre-flight Checks + +Before running tests, verify your setup: + +```bash +# Check TypeScript compiles +npm run tsc + +# Check linting passes +npm run lint + +# Check formatting +npm run prettier -- --check . +``` + +## Delayed/Dynamic Test Suites + +For tests that require dynamic configuration: + +```bash +export USERSTORY=DevfileAcceptanceTestAPI && npm run delayed-test +``` + +## Available Test Files + +Common test specifications: + +- `EmptyWorkspace` - Basic workspace creation UI test +- `EmptyWorkspaceAPI` - Workspace creation via API (no browser) +- `Factory` - Factory URL workspace creation with git operations +- `SmokeTest` - Quick validation test +- `UserPreferencesTest` - User preferences functionality + +Run `ls specs/` to see all available test categories. + +## Troubleshooting + +### ChromeDriver Version Mismatch + +```bash +# Update chromedriver to match Chrome version +npm install chromedriver@ +``` + +### Certificate Errors + +```bash +export NODE_TLS_REJECT_UNAUTHORIZED=0 +``` + +### Slow Workspace Start + +```bash +export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 +export TS_SELENIUM_DEFAULT_ATTEMPTS=3 +``` diff --git a/tests/e2e/.claude/commands/run-che-e2e-test-using-podman.md b/tests/e2e/.claude/commands/run-che-e2e-test-using-podman.md new file mode 100644 index 00000000000..8171d584bea --- /dev/null +++ b/tests/e2e/.claude/commands/run-che-e2e-test-using-podman.md @@ -0,0 +1,216 @@ +# Run E2E Tests Using Podman/Container Image + +Run E2E tests against Eclipse Che using the che-e2e container image with Podman. This provides a consistent, isolated test environment with Chrome browser and VNC support. + +## Execution Mode - ASK USER FIRST + +Before proceeding, ask the user which execution mode they prefer using AskUserQuestion: + +1. **Just bash command** - Provide only the podman run command (uses published image, no rebuild) +2. **Build and run** - Check for changes in the working directory (`git status`), rebuild container image if there are modifications, then run the test +3. **Check staged changes only** - Only rebuild container if there are git staged changes, otherwise use published image + +Based on the user's choice: +- **Just bash command**: Skip build steps, provide podman run command with `eclipse/che-e2e:nightly` image +- **Build and run**: Run `podman build` before the test if `git status` shows any changes in e2e directory +- **Check staged changes only**: Run `git diff --cached --name-only` to check for staged changes; rebuild container only if staged files exist in the e2e directory + +## Required Parameters - ASK USER + +Before running tests, you MUST ask the user for these required parameters using AskUserQuestion: + +1. **Eclipse Che URL** (`TS_SELENIUM_BASE_URL`) - The Che dashboard URL + + - Example: `https://che.apps.ocp.crw-qe.com/` + +2. **Test Name** (`USERSTORY`) - Which test to run + + - Common options: `EmptyWorkspace`, `Factory`, `SmokeTest`, `EmptyWorkspaceAPI` + +3. **Username** (`TS_SELENIUM_OCP_USERNAME`) - OpenShift/Kubernetes username + + - Example: `admin`, `developer`, `che@eclipse.org` + +4. **Password** (`TS_SELENIUM_OCP_PASSWORD`) - OpenShift/Kubernetes password + +5. **Platform** (`TS_PLATFORM`) - Optional, deployment platform + - Options: `openshift` (default), `kubernetes` + +## Test-Specific Parameters - ASK BASED ON TEST NAME + +After getting the test name, read the test spec file to identify additional required parameters. +Use `cat specs/**/${USERSTORY}.spec.ts` to find the test file and look for environment variables used. + +### Factory URL Tests (Factory, RefusedOAuthFactory, NoSetupRepoFactory, etc.) +These tests navigate directly to a factory URL to create a workspace. +Ask for these additional parameters: +- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository to clone (used to construct the factory URL) +- **Git Provider** (`TS_SELENIUM_FACTORY_GIT_PROVIDER`) - `github`, `gitlab`, `bitbucket`, `azure-devops` +- **OAuth Enabled** (`TS_SELENIUM_GIT_PROVIDER_OAUTH`) - `true` or `false` + +### Git Repo Import Form Tests (FactoryWithGitRepoOptions, CreateWorkspaceWithExistingNameFromGitUrl, etc.) +These tests use the Dashboard's "Create Workspace" form to import a git repository. +Ask for these additional parameters: +- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository URL to enter in the form +- **Branch Name** (`TS_SELENIUM_FACTORY_GIT_REPO_BRANCH`) - Optional, branch to checkout (default: `main`) +- **Project Name** (`TS_SELENIUM_PROJECT_NAME`) - Optional, expected project folder name + +### API Tests (EmptyWorkspaceAPI, ContainerOverridesAPI, etc.) +Ask for: +- **Namespace** (`TS_API_TEST_NAMESPACE`) - Optional, for specific namespace testing +- **UDI Image** (`TS_API_TEST_UDI_IMAGE`) - Optional, custom Universal Developer Image + +### Sample/Devfile Tests +Ask for: +- **Sample List** (`TS_SAMPLE_LIST`) - Which samples to test, e.g., `Node.js Express` + +### SSH/PAT Tests (SshUrlNoOauthPatFactory, etc.) +Ask for: +- **SSH Private Key Path** or **Personal Access Token** details as needed by the test + +## Auto-Rebuild on Local Changes + +Before running tests, check for local modifications and rebuild the container if needed: + +```bash +cd tests/e2e + +# Check for uncommitted changes and rebuild if found +if [[ -n $(git status --porcelain .) ]]; then + echo "Local changes detected, rebuilding container image..." + podman build -t quay.io/eclipse/che-e2e:local -f build/dockerfiles/Dockerfile . + E2E_IMAGE="quay.io/eclipse/che-e2e:local" +else + echo "No local changes, using published image..." + E2E_IMAGE="eclipse/che-e2e:nightly" +fi + +# Run tests with the appropriate image +podman rm -f selenium-e2e 2>/dev/null; \ +podman run -it --shm-size=2g -p 5920:5920 \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ + -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ + -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ + $E2E_IMAGE +``` + +## Podman Run Commands + +### Basic Podman Run (using published image) + +```bash +cd tests/e2e +podman rm -f selenium-e2e 2>/dev/null; \ +podman run -it --shm-size=2g -p 5920:5920 \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ + -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ + -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ + eclipse/che-e2e:nightly +``` + +### Podman Run with Local E2E Code Mounted + +Use this when testing local modifications to E2E tests: + +```bash +cd tests/e2e +podman rm -f selenium-e2e 2>/dev/null; \ +podman run -it --shm-size=2g -p 5920:5920 \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ + -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ + -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ + -v $(pwd):/tmp/e2e:Z \ + eclipse/che-e2e:nightly +``` + +### Running Specific Test in Podman + +```bash +podman run -it --shm-size=2g -p 5920:5920 \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ + -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ + -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ + -e USERSTORY=SmokeTest \ + eclipse/che-e2e:nightly +``` + +### Full Example with All Common Options (Recommended) + +```bash +podman rm -f selenium-e2e 2>/dev/null; \ +podman run -it --shm-size=2g -p 5920:5920 \ + --network="host" \ + --name selenium-e2e \ + -e TS_PLATFORM=openshift \ + -e TS_SELENIUM_BASE_URL=https://che.apps.ocp.crw-qe.com/ \ + -e TS_SELENIUM_OCP_USERNAME=admin \ + -e TS_SELENIUM_OCP_PASSWORD=password \ + -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ + -e TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd \ + -e TS_SELENIUM_LOG_LEVEL=TRACE \ + -e TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 \ + -e TS_DEBUG_MODE=true \ + -e NODE_TLS_REJECT_UNAUTHORIZED=0 \ + -e TS_DELETE_WORKSPACE_ON_FAILED_TEST=true \ + -e VIDEO_RECORDING=true \ + -e USERSTORY=EmptyWorkspace \ + -v /tmp/e2e/report:/tmp/e2e/report:Z \ + -v /tmp/e2e/video:/tmp/ffmpeg_report:Z \ + eclipse/che-e2e:nightly +``` + +### Kubernetes Platform Example + +```bash +podman run -it --shm-size=2g -p 5920:5920 \ + --network="host" \ + --name selenium-e2e \ + -e TS_PLATFORM=kubernetes \ + -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ + -e TS_SELENIUM_K8S_USERNAME=$TS_SELENIUM_K8S_USERNAME \ + -e TS_SELENIUM_K8S_PASSWORD=$TS_SELENIUM_K8S_PASSWORD \ + -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=false \ + -e NODE_TLS_REJECT_UNAUTHORIZED=0 \ + -e USERSTORY=EmptyWorkspace \ + eclipse/che-e2e:nightly +``` + +## VNC Access for Debugging + +Connect to VNC at `0.0.0.0:5920` to watch tests running in the container. + +## Build Local Container Image + +To build and use a local container image: + +```bash +cd tests/e2e +podman build -t quay.io/eclipse/che-e2e:local -f build/dockerfiles/Dockerfile . + +# Then run with local image +podman run -it --shm-size=2g -p 5920:5920 \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ + quay.io/eclipse/che-e2e:local +``` + +## Cleanup + +Remove existing container before running again: + +```bash +podman rm -f selenium-e2e +``` + +## Report Collection + +Mount volumes to collect test reports: + +```bash +-v /local/path/report:/tmp/e2e/report:Z \ +-v /local/path/video:/tmp/ffmpeg_report:Z +``` diff --git a/tests/e2e/.claude/commands/run-devspaces-e2e-test-locally.md b/tests/e2e/.claude/commands/run-devspaces-e2e-test-locally.md new file mode 100644 index 00000000000..6851b7c2b6d --- /dev/null +++ b/tests/e2e/.claude/commands/run-devspaces-e2e-test-locally.md @@ -0,0 +1,323 @@ +# Run E2E Tests Against Dev Spaces Using Local Browser + +Run E2E tests against Red Hat OpenShift Dev Spaces using a local Chrome browser. This is useful for development and debugging as you can see the browser in real-time. + +## Execution Mode - ASK USER FIRST + +Before proceeding, ask the user which execution mode they prefer using AskUserQuestion: + +1. **Just bash command** - Provide only the bash command to run the test (assumes dependencies installed and code already compiled) +2. **Build and run** - Check for changes in the working directory (`git status`), rebuild if there are modifications, then run the test +3. **Check staged changes only** - Only rebuild if there are git staged changes, otherwise just run the test + +Based on the user's choice: +- **Just bash command**: Skip build steps, provide `export USERSTORY= && npm run test` command +- **Build and run**: Run `npm ci && npm run tsc` before the test if `git status` shows any changes +- **Check staged changes only**: Run `git diff --cached --name-only` to check for staged changes; rebuild only if staged files exist in the e2e directory + +## Required Parameters - ASK USER + +Before running tests, you MUST ask the user for these required parameters using AskUserQuestion: + +1. **Dev Spaces URL** (`TS_SELENIUM_BASE_URL`) - The Dev Spaces dashboard URL + + - Example: `https://devspaces.apps.ocp.crw-qe.com/` + +2. **Test Name** (`USERSTORY`) - Which test to run + + - Common options: `EmptyWorkspace`, `Factory`, `SmokeTest`, `EmptyWorkspaceAPI` + +3. **Username** (`TS_SELENIUM_OCP_USERNAME`) - OpenShift username + + - Example: `admin`, `developer`, `user@example.com` + +4. **Password** (`TS_SELENIUM_OCP_PASSWORD`) - OpenShift password + +5. **Login Provider** (`TS_OCP_LOGIN_PAGE_PROVIDER_TITLE`) - Optional, for SSO + - Common options: `htpasswd`, `DevSandbox`, or leave empty for default + +## Test-Specific Parameters - ASK BASED ON TEST NAME + +After getting the test name, read the test spec file to identify additional required parameters. +Use `cat specs/**/${USERSTORY}.spec.ts` to find the test file and look for environment variables used. + +### Factory URL Tests (Factory, RefusedOAuthFactory, NoSetupRepoFactory, etc.) +These tests navigate directly to a factory URL to create a workspace. +Ask for these additional parameters: +- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository to clone (used to construct the factory URL) +- **Git Provider** (`TS_SELENIUM_FACTORY_GIT_PROVIDER`) - `github`, `gitlab`, `bitbucket`, `azure-devops` +- **OAuth Enabled** (`TS_SELENIUM_GIT_PROVIDER_OAUTH`) - `true` or `false` + +### Git Repo Import Form Tests (FactoryWithGitRepoOptions, CreateWorkspaceWithExistingNameFromGitUrl, etc.) +These tests use the Dashboard's "Create Workspace" form to import a git repository. +Ask for these additional parameters: +- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository URL to enter in the form +- **Branch Name** (`TS_SELENIUM_FACTORY_GIT_REPO_BRANCH`) - Optional, branch to checkout (default: `main`) +- **Project Name** (`TS_SELENIUM_PROJECT_NAME`) - Optional, expected project folder name + +### API Tests (EmptyWorkspaceAPI, ContainerOverridesAPI, etc.) +Ask for: +- **Namespace** (`TS_API_TEST_NAMESPACE`) - Optional, for specific namespace testing +- **UDI Image** (`TS_API_TEST_UDI_IMAGE`) - Optional, custom Universal Developer Image + +### Sample/Devfile Tests +Ask for: +- **Sample List** (`TS_SAMPLE_LIST`) - Which samples to test, e.g., `Node.js Express` + +### SSH/PAT Tests (SshUrlNoOauthPatFactory, etc.) +Ask for: +- **SSH Private Key Path** or **Personal Access Token** details as needed by the test + +## Prerequisites + +1. **Node.js 22.x** (use nvm to manage versions) +2. **Chrome browser** version 114.x or later +3. **ChromeDriver** matching your Chrome version (installed via npm) +4. Access to a Dev Spaces instance on OpenShift + +## Full Test Run (Recommended) + +Complete workflow with clean build and all checks: + +```bash +cd tests/e2e + +# Use correct Node.js version +nvm use v22.10.0 + +# Set environment variables +export TS_SELENIUM_LOG_LEVEL="TRACE" +export TS_SELENIUM_BASE_URL=https://devspaces.apps.ocp.crw-qe.com/ +export TS_SELENIUM_OCP_USERNAME=admin +export TS_SELENIUM_OCP_PASSWORD=password +export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd +export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 +export VIDEO_RECORDING=true +export TS_DEBUG_MODE=true +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true +export NODE_TLS_REJECT_UNAUTHORIZED=0 +export TESTING_APPLICATION_VERSION=3.23.0 +export TS_DELETE_WORKSPACE_ON_FAILED_TEST=true +export USERSTORY=EmptyWorkspace + +# Clean build and run tests +rm -rf node_modules dist && npm ci && npm run lint && npm run prettier && npm run tsc && npm test +``` + +## Quick Setup + +```bash +cd tests/e2e + +# Use correct Node.js version +nvm use v22.10.0 + +# Install dependencies +npm ci + +# Export required environment variables +export TS_SELENIUM_BASE_URL=https://devspaces.apps.cluster.example.com +export TS_SELENIUM_OCP_USERNAME= +export TS_SELENIUM_OCP_PASSWORD= +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true +export NODE_TLS_REJECT_UNAUTHORIZED=0 +``` + +## Running Tests + +### Run Specific Test File + +```bash +# UI test +export USERSTORY=EmptyWorkspace && npm run test + +# Factory test +export USERSTORY=Factory && npm run test + +# API-only test (no browser) +export USERSTORY=EmptyWorkspaceAPI && npm run driver-less-test +``` + +## Common Dev Spaces Test Configurations + +### Dev Spaces with htpasswd Authentication + +```bash +export TS_SELENIUM_BASE_URL=https://devspaces.apps.ocp.crw-qe.com/ +export TS_SELENIUM_OCP_USERNAME=admin +export TS_SELENIUM_OCP_PASSWORD=password +export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true +export NODE_TLS_REJECT_UNAUTHORIZED=0 +export USERSTORY=EmptyWorkspace && npm run test +``` + +### Dev Spaces with SSO Provider (e.g., Developer Sandbox) + +```bash +export TS_SELENIUM_BASE_URL=https://devspaces.apps.sandbox.x8i5.p1.openshiftapps.com +export TS_SELENIUM_OCP_USERNAME=user@redhat.com +export TS_SELENIUM_OCP_PASSWORD=password +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true +export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE="DevSandbox" +export NODE_TLS_REJECT_UNAUTHORIZED=0 +export USERSTORY=EmptyWorkspace && npm run test +``` + +### Dev Spaces Factory Test with GitHub OAuth + +```bash +export TS_SELENIUM_BASE_URL=https://devspaces.apps.cluster.example.com +export TS_SELENIUM_OCP_USERNAME=user@example.com +export TS_SELENIUM_OCP_PASSWORD=password +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true +export TS_SELENIUM_FACTORY_GIT_REPO_URL=https://github.com/user/repo +export TS_SELENIUM_FACTORY_GIT_PROVIDER=github +export TS_SELENIUM_GIT_PROVIDER_OAUTH=true +export USERSTORY=Factory && npm run test +``` + +### Dev Spaces Factory Test with GitLab OAuth + +```bash +export TS_SELENIUM_BASE_URL=https://devspaces.apps.cluster.example.com +export TS_SELENIUM_OCP_USERNAME=user@example.com +export TS_SELENIUM_OCP_PASSWORD=password +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true +export TS_SELENIUM_FACTORY_GIT_REPO_URL=https://gitlab.com/user/repo +export TS_SELENIUM_FACTORY_GIT_PROVIDER=gitlab +export TS_SELENIUM_GIT_PROVIDER_OAUTH=true +export USERSTORY=Factory && npm run test +``` + +### Dev Spaces with Bitbucket OAuth + +```bash +export TS_SELENIUM_BASE_URL=https://devspaces.apps.cluster.example.com +export TS_SELENIUM_OCP_USERNAME=user@example.com +export TS_SELENIUM_OCP_PASSWORD=password +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true +export TS_SELENIUM_FACTORY_GIT_REPO_URL=https://bitbucket.org/user/repo +export TS_SELENIUM_FACTORY_GIT_PROVIDER=bitbucket +export TS_SELENIUM_GIT_PROVIDER_OAUTH=true +export USERSTORY=Factory && npm run test +``` + +### Dev Spaces with Azure DevOps + +```bash +export TS_SELENIUM_BASE_URL=https://devspaces.apps.cluster.example.com +export TS_SELENIUM_OCP_USERNAME=user@example.com +export TS_SELENIUM_OCP_PASSWORD=password +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true +export TS_SELENIUM_FACTORY_GIT_REPO_URL=https://dev.azure.com/org/project/_git/repo +export TS_SELENIUM_FACTORY_GIT_PROVIDER=azure-devops +export TS_SELENIUM_GIT_PROVIDER_OAUTH=true +export USERSTORY=Factory && npm run test +``` + +## Timeout Configuration + +Adjust timeouts for slower environments or large workspaces: + +```bash +export TS_SELENIUM_LOAD_PAGE_TIMEOUT=60000 +export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 +export TS_COMMON_DASHBOARD_WAIT_TIMEOUT=30000 +export MOCHA_DEFAULT_TIMEOUT=420000 +``` + +## Verbose Logging + +Enable detailed logging for troubleshooting: + +```bash +export TS_SELENIUM_LOG_LEVEL=TRACE +export TS_SELENIUM_PRINT_TIMEOUT_VARIABLES=true +export USERSTORY=Factory && npm run test +``` + +## Headless Mode + +For CI environments or when you don't need to see the browser: + +```bash +export TS_SELENIUM_HEADLESS=true +export USERSTORY=EmptyWorkspace && npm run test +``` + +## View Test Reports + +After test execution, view Allure reports: + +```bash +npm run open-allure-dasboard +``` + +## Pre-flight Checks + +Before running tests, verify your setup: + +```bash +# Check TypeScript compiles +npm run tsc + +# Check linting passes +npm run lint + +# Check formatting +npm run prettier -- --check . +``` + +## Available Test Specifications + +Common tests for Dev Spaces: + +- `EmptyWorkspace` - Basic workspace creation UI test +- `EmptyWorkspaceAPI` - Workspace creation via API (no browser) +- `Factory` - Factory URL workspace creation with git operations +- `SmokeTest` - Quick validation test +- `UserPreferencesTest` - User preferences functionality +- `CustomOpenVSXRegistry` - Custom plugin registry tests +- `WorkspaceIdleTimeout` - Workspace timeout behavior + +Run `ls specs/` to see all available test categories. + +## Key Differences from Eclipse Che + +When testing Dev Spaces vs Eclipse Che: + +- Always set `TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true` +- May need `TS_OCP_LOGIN_PAGE_PROVIDER_TITLE` for SSO provider selection +- Base URL format is typically `https://devspaces.apps.` +- Dev Spaces always runs on OpenShift (`TS_PLATFORM=openshift` is default) + +## Troubleshooting + +### ChromeDriver Version Mismatch + +```bash +npm install chromedriver@ +``` + +### Certificate Errors + +```bash +export NODE_TLS_REJECT_UNAUTHORIZED=0 +``` + +### Slow Workspace Start + +```bash +export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 +export TS_SELENIUM_DEFAULT_ATTEMPTS=3 +``` + +### OAuth Login Issues + +Verify the login provider title matches exactly: + +```bash +# Check the login page for the provider button text +export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE="DevSandbox" +``` diff --git a/tests/e2e/.claude/commands/run-devspaces-e2e-test-using-podman.md b/tests/e2e/.claude/commands/run-devspaces-e2e-test-using-podman.md new file mode 100644 index 00000000000..21d78beafcb --- /dev/null +++ b/tests/e2e/.claude/commands/run-devspaces-e2e-test-using-podman.md @@ -0,0 +1,259 @@ +# Run E2E Tests Against Dev Spaces Using Podman/Container Image + +Run E2E tests against Red Hat OpenShift Dev Spaces using the che-e2e container image with Podman. This provides a consistent, isolated test environment with Chrome browser and VNC support. + +## Execution Mode - ASK USER FIRST + +Before proceeding, ask the user which execution mode they prefer using AskUserQuestion: + +1. **Just bash command** - Provide only the podman run command (uses published image, no rebuild) +2. **Build and run** - Check for changes in the working directory (`git status`), rebuild container image if there are modifications, then run the test +3. **Check staged changes only** - Only rebuild container if there are git staged changes, otherwise use published image + +Based on the user's choice: +- **Just bash command**: Skip build steps, provide podman run command with `eclipse/che-e2e:nightly` image +- **Build and run**: Run `podman build` before the test if `git status` shows any changes in e2e directory +- **Check staged changes only**: Run `git diff --cached --name-only` to check for staged changes; rebuild container only if staged files exist in the e2e directory + +## Required Parameters - ASK USER + +Before running tests, you MUST ask the user for these required parameters using AskUserQuestion: + +1. **Dev Spaces URL** (`TS_SELENIUM_BASE_URL`) - The Dev Spaces dashboard URL + - Example: `https://devspaces.apps.ocp.crw-qe.com/` + +2. **Test Name** (`USERSTORY`) - Which test to run + - Common options: `EmptyWorkspace`, `Factory`, `SmokeTest`, `EmptyWorkspaceAPI` + +3. **Username** (`TS_SELENIUM_OCP_USERNAME`) - OpenShift username + - Example: `admin`, `developer`, `user@example.com` + +4. **Password** (`TS_SELENIUM_OCP_PASSWORD`) - OpenShift password + +5. **Login Provider** (`TS_OCP_LOGIN_PAGE_PROVIDER_TITLE`) - Optional, for SSO + - Common options: `htpasswd`, `DevSandbox`, or leave empty for default + +## Test-Specific Parameters - ASK BASED ON TEST NAME + +After getting the test name, read the test spec file to identify additional required parameters. +Use `cat specs/**/${USERSTORY}.spec.ts` to find the test file and look for environment variables used. + +### Factory URL Tests (Factory, RefusedOAuthFactory, NoSetupRepoFactory, etc.) +These tests navigate directly to a factory URL to create a workspace. +Ask for these additional parameters: +- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository to clone (used to construct the factory URL) +- **Git Provider** (`TS_SELENIUM_FACTORY_GIT_PROVIDER`) - `github`, `gitlab`, `bitbucket`, `azure-devops` +- **OAuth Enabled** (`TS_SELENIUM_GIT_PROVIDER_OAUTH`) - `true` or `false` + +### Git Repo Import Form Tests (FactoryWithGitRepoOptions, CreateWorkspaceWithExistingNameFromGitUrl, etc.) +These tests use the Dashboard's "Create Workspace" form to import a git repository. +Ask for these additional parameters: +- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository URL to enter in the form +- **Branch Name** (`TS_SELENIUM_FACTORY_GIT_REPO_BRANCH`) - Optional, branch to checkout (default: `main`) +- **Project Name** (`TS_SELENIUM_PROJECT_NAME`) - Optional, expected project folder name + +### API Tests (EmptyWorkspaceAPI, ContainerOverridesAPI, etc.) +Ask for: +- **Namespace** (`TS_API_TEST_NAMESPACE`) - Optional, for specific namespace testing +- **UDI Image** (`TS_API_TEST_UDI_IMAGE`) - Optional, custom Universal Developer Image + +### Sample/Devfile Tests +Ask for: +- **Sample List** (`TS_SAMPLE_LIST`) - Which samples to test, e.g., `Node.js Express` + +### SSH/PAT Tests (SshUrlNoOauthPatFactory, etc.) +Ask for: +- **SSH Private Key Path** or **Personal Access Token** details as needed by the test + +## Auto-Rebuild on Local Changes + +Before running tests, check for local modifications and rebuild the container if needed: + +```bash +cd tests/e2e + +# Check for uncommitted changes and rebuild if found +if [[ -n $(git status --porcelain .) ]]; then + echo "Local changes detected, rebuilding container image..." + podman build -t quay.io/eclipse/che-e2e:local -f build/dockerfiles/Dockerfile . + E2E_IMAGE="quay.io/eclipse/che-e2e:local" +else + echo "No local changes, using published image..." + E2E_IMAGE="eclipse/che-e2e:nightly" +fi + +# Run tests with the appropriate image +podman rm -f selenium-e2e 2>/dev/null; \ +podman run -it --shm-size=2g -p 5920:5920 \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ + -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ + -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ + -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ + $E2E_IMAGE +``` + +## Podman Run Commands + +### Basic Dev Spaces Test (with OAuth) + +```bash +cd tests/e2e +podman rm -f selenium-e2e 2>/dev/null; \ +podman run -it --shm-size=2g -p 5920:5920 \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ + -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ + -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ + -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ + eclipse/che-e2e:nightly +``` + +### Dev Spaces with htpasswd Authentication + +```bash +podman rm -f selenium-e2e 2>/dev/null; \ +podman run -it --shm-size=2g -p 5920:5920 \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=https://devspaces.apps.ocp.crw-qe.com/ \ + -e TS_SELENIUM_OCP_USERNAME=admin \ + -e TS_SELENIUM_OCP_PASSWORD=password \ + -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ + -e TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd \ + -e NODE_TLS_REJECT_UNAUTHORIZED=0 \ + -e USERSTORY=EmptyWorkspace \ + eclipse/che-e2e:nightly +``` + +### Dev Spaces with Local E2E Code Mounted + +Use this when testing local modifications to E2E tests: + +```bash +cd tests/e2e +podman rm -f selenium-e2e 2>/dev/null; \ +podman run -it --shm-size=2g -p 5920:5920 \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ + -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ + -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ + -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ + -v $(pwd):/tmp/e2e:Z \ + eclipse/che-e2e:nightly +``` + +### Running Specific Test Against Dev Spaces + +```bash +podman run -it --shm-size=2g -p 5920:5920 \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ + -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ + -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ + -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ + -e USERSTORY=Factory \ + eclipse/che-e2e:nightly +``` + +### Full Dev Spaces Example with All Common Options (Recommended) + +```bash +podman rm -f selenium-e2e 2>/dev/null; \ +podman run -it --shm-size=2g -p 5920:5920 \ + --network="host" \ + --name selenium-e2e \ + -e TS_PLATFORM=openshift \ + -e TS_SELENIUM_BASE_URL=https://devspaces.apps.ocp.crw-qe.com/ \ + -e TS_SELENIUM_OCP_USERNAME=admin \ + -e TS_SELENIUM_OCP_PASSWORD=password \ + -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ + -e TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd \ + -e TS_SELENIUM_LOG_LEVEL=TRACE \ + -e TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 \ + -e TS_DEBUG_MODE=true \ + -e NODE_TLS_REJECT_UNAUTHORIZED=0 \ + -e TESTING_APPLICATION_VERSION=3.23.0 \ + -e TS_DELETE_WORKSPACE_ON_FAILED_TEST=true \ + -e VIDEO_RECORDING=true \ + -e USERSTORY=EmptyWorkspace \ + -v /tmp/e2e/report:/tmp/e2e/report:Z \ + -v /tmp/e2e/video:/tmp/ffmpeg_report:Z \ + eclipse/che-e2e:nightly +``` + +### Dev Spaces Factory Test with Git Provider OAuth + +```bash +podman run -it --shm-size=2g -p 5920:5920 \ + --network="host" \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=https://devspaces.apps.cluster.example.com \ + -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ + -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ + -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ + -e TS_SELENIUM_FACTORY_GIT_REPO_URL=https://github.com/user/repo \ + -e TS_SELENIUM_FACTORY_GIT_PROVIDER=github \ + -e TS_SELENIUM_GIT_PROVIDER_OAUTH=true \ + -e USERSTORY=Factory \ + eclipse/che-e2e:nightly +``` + +### Dev Spaces on Developer Sandbox + +```bash +podman run -it --shm-size=2g -p 5920:5920 \ + --network="host" \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=https://devspaces.apps.sandbox.x8i5.p1.openshiftapps.com \ + -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ + -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ + -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ + -e TS_OCP_LOGIN_PAGE_PROVIDER_TITLE="DevSandbox" \ + -e USERSTORY=EmptyWorkspace \ + eclipse/che-e2e:nightly +``` + +## VNC Access for Debugging + +Connect to VNC at `0.0.0.0:5920` to watch tests running in the container. + +## Build Local Container Image + +To build and use a local container image: + +```bash +cd tests/e2e +podman build -t quay.io/eclipse/che-e2e:local -f build/dockerfiles/Dockerfile . + +# Then run with local image +podman run -it --shm-size=2g -p 5920:5920 \ + --name selenium-e2e \ + -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ + -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ + quay.io/eclipse/che-e2e:local +``` + +## Cleanup + +Remove existing container before running again: + +```bash +podman rm -f selenium-e2e +``` + +## Report Collection + +Mount volumes to collect test reports: + +```bash +-v /local/path/report:/tmp/e2e/report:Z \ +-v /local/path/video:/tmp/ffmpeg_report:Z +``` + +## Key Differences from Eclipse Che + +When testing Dev Spaces vs Eclipse Che: + +- Always set `TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true` (Dev Spaces uses OpenShift OAuth) +- May need `TS_OCP_LOGIN_PAGE_PROVIDER_TITLE` for SSO provider selection +- Base URL format is typically `https://devspaces.apps.` diff --git a/tests/e2e/.claude/skills/e2e-test-development.md b/tests/e2e/.claude/skills/e2e-test-development.md new file mode 100644 index 00000000000..f8bb36529d5 --- /dev/null +++ b/tests/e2e/.claude/skills/e2e-test-development.md @@ -0,0 +1,425 @@ +# Eclipse Che E2E TypeScript Mocha Selenium Test Development Skill + +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. + +## Project Overview + +This is the E2E test suite for Eclipse Che / Red Hat OpenShift Dev Spaces. It uses: +- **Selenium WebDriver** with Chrome browser +- **Mocha** (TDD style - `suite()`, `test()`, `suiteSetup()`, `suiteTeardown()`) +- **TypeScript** with strict type checking +- **Inversify** for dependency injection +- **Chai** for assertions +- **Allure** for test reporting + +## Directory Structure + +| Directory | Purpose | +|-----------|---------| +| `specs/` | Test specifications organized by category (api/, factory/, dashboard-samples/, miscellaneous/) | +| `pageobjects/` | Page Object classes for UI elements (dashboard/, ide/, login/, openshift/, git-providers/, webterminal/) | +| `utils/` | Utilities (DriverHelper, BrowserTabsUtil, Logger, API handlers, KubernetesCommandLineToolsExecutor) | +| `tests-library/` | Reusable test helpers (WorkspaceHandlingTests, LoginTests, ProjectAndFileTests) | +| `constants/` | Environment variable mappings (BASE_TEST_CONSTANTS, TIMEOUT_CONSTANTS, FACTORY_TEST_CONSTANTS, etc.) | +| `configs/` | Mocha config, Inversify container (inversify.config.ts), shell scripts | +| `suites/` | Test suite configurations for different environments | +| `driver/` | Chrome driver configuration | +| `build/dockerfiles/` | Docker image for running tests | + +## Essential Commands + +```bash +# Install dependencies +npm ci + +# Run all tests (requires environment variables) +export TS_SELENIUM_BASE_URL= +export TS_SELENIUM_OCP_USERNAME= +export TS_SELENIUM_OCP_PASSWORD= +npm run test + +# Run a single test file (without .spec.ts extension) +export USERSTORY=SmokeTest && npm run test + +# Run API-only tests (no browser) +export USERSTORY=EmptyWorkspaceAPI && npm run driver-less-test + +# Lint and format +npm run lint +npm run prettier + +# Build TypeScript only +npm run tsc + +# View Allure test report +npm run open-allure-dasboard +``` + +## CODE STYLE REQUIREMENTS (CRITICAL) + +### File Header (Required for ALL .ts files) +Every TypeScript file MUST start with this exact header: +```typescript +/** ******************************************************************* + * copyright (c) 2023 Red Hat, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + **********************************************************************/ +``` + +### Page Object and Utility Classes + +1. **Class Declaration with Dependency Injection** + - Use `@injectable()` decorator on ALL page objects and utilities + - Use constructor injection with `@inject()` decorators + +```typescript +import { inject, injectable } from 'inversify'; +import 'reflect-metadata'; +import { CLASSES } from '../../configs/inversify.types'; + +@injectable() +export class MyPageObject { + constructor( + @inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper + ) {} +} +``` + +2. **Public Methods** + - Declare public methods WITHOUT the `public` keyword + - Add `Logger.debug()` at the START of every public method + - Always specify explicit return types + +```typescript +async clickButton(timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise { + Logger.debug(); + await this.driverHelper.waitAndClick(MyPage.BUTTON_LOCATOR, timeout); +} +``` + +3. **Locators** + - Static locators: `private static readonly` fields of type `By` + - Dynamic locators: `private` methods that return `By` + - NEVER declare locators as constants inside methods + +```typescript +// Static locators (correct) +private static readonly SUBMIT_BUTTON: By = By.xpath('//button[@type="submit"]'); +private static readonly INPUT_FIELD: By = By.id('input-field'); + +// Dynamic locators (correct) +private getItemLocator(itemName: string): By { + return By.xpath(`//div[text()="${itemName}"]`); +} + +// WRONG - Never do this inside a method +async wrongMethod(): Promise { + const locator: By = By.xpath('//button'); // AVOID THIS +} +``` + +### Member Ordering (Enforced by ESLint) +Classes must follow this order: +1. Static fields +2. Public fields +3. Instance fields +4. Protected fields +5. Private fields +6. Abstract fields +7. Constructor +8. Public static methods +9. Protected static methods +10. Private static methods +11. Public methods +12. Protected methods +13. Private methods + +### Test File Conventions + +1. **Naming** + - UI tests: `*.spec.ts` (e.g., `Factory.spec.ts`) + - API-only tests: `*API.spec.ts` (e.g., `EmptyWorkspaceAPI.spec.ts`) + +2. **Mocha TDD Style (Required)** + - Use `suite()`, `test()`, `suiteSetup()`, `suiteTeardown()` + - NEVER use arrow functions in test declarations (Mocha context issue) + +```typescript +suite('My Test Suite', function (): void { + // Inject dependencies inside suite() to avoid unnecessary execution + const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); + const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); + + suiteSetup('Login to application', async function (): Promise { + await loginTests.loginIntoChe(); + }); + + test('Verify dashboard is visible', async function (): Promise { + await dashboard.waitPage(); + }); + + suiteTeardown('Cleanup', async function (): Promise { + // cleanup code + }); +}); +``` + +3. **Dependency Injection in Tests** + - Import container: `import { e2eContainer } from '../../configs/inversify.config';` + - Import types: `import { CLASSES, TYPES } from '../../configs/inversify.types';` + - Get instances inside suite() function + +```typescript +import { e2eContainer } from '../../configs/inversify.config'; +import { CLASSES, TYPES } from '../../configs/inversify.types'; + +suite('Test Suite', function (): void { + const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); + const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); + // ... test implementation +}); +``` + +### TypeScript Requirements + +1. **Explicit Type Annotations Required** + - All parameters must have type annotations + - All property declarations must have type annotations + - All variable declarations must have type annotations + - All functions must have explicit return types + +```typescript +// Correct +async function doSomething(param: string, timeout: number): Promise { + const result: string = await someOperation(); +} + +// Wrong - missing types +async function doSomething(param, timeout) { + const result = await someOperation(); +} +``` + +2. **Naming Conventions** + - Variables: camelCase or UPPER_CASE + - No leading/trailing underscores + +3. **String Quotes** + - Use single quotes for strings + +4. **Comments** + - Comments must start with lowercase (capitalized-comments: never) + - Mark workarounds with `// todo` and issue number: `// todo commented due to issue crw-1010` + +### Prettier and ESLint + +- Pre-commit hooks run automatically via Husky +- Run `npm run prettier` to fix formatting +- Run `npm run lint` to fix linting issues + +## Environment Variables + +Core variables (defined in `constants/` directory): + +| Variable | Description | +|----------|-------------| +| `TS_SELENIUM_BASE_URL` | Che/DevSpaces dashboard URL | +| `TS_SELENIUM_OCP_USERNAME` | OpenShift username | +| `TS_SELENIUM_OCP_PASSWORD` | OpenShift password | +| `USERSTORY` | Specific test file to run (without .spec.ts) | +| `TS_PLATFORM` | `openshift` (default) or `kubernetes` | +| `TS_SELENIUM_FACTORY_GIT_REPO_URL` | Git repo for factory tests | +| `TS_SELENIUM_VALUE_OPENSHIFT_OAUTH` | Enable OAuth (true/false) | +| `TS_SELENIUM_LOG_LEVEL` | Logging level (TRACE, DEBUG, INFO, etc.) | +| `DELETE_WORKSPACE_ON_SUCCESSFUL_TEST` | Delete workspace on success | + +## Adding New Page Objects + +1. Create file in appropriate `pageobjects/` subdirectory +2. Add `@injectable()` decorator +3. Register in `configs/inversify.config.ts` +4. Add class identifier in `configs/inversify.types.ts` + +```typescript +// 1. Create pageobjects/dashboard/NewPage.ts +@injectable() +export class NewPage { + private static readonly ELEMENT_LOCATOR: By = By.id('element'); + + constructor( + @inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper + ) {} + + async waitForElement(): Promise { + Logger.debug(); + await this.driverHelper.waitVisibility(NewPage.ELEMENT_LOCATOR); + } +} + +// 2. Add to configs/inversify.types.ts +const CLASSES: any = { + // ... existing classes + NewPage: 'NewPage' +}; + +// 3. Add to configs/inversify.config.ts +import { NewPage } from '../pageobjects/dashboard/NewPage'; +e2eContainer.bind(CLASSES.NewPage).to(NewPage); +``` + +## Adding New Tests + +1. Create file in appropriate `specs/` subdirectory +2. Follow naming convention (*.spec.ts for UI, *API.spec.ts for API) +3. Use TDD style (suite, test, suiteSetup, suiteTeardown) +4. Run with `export USERSTORY= && npm run test` + +## Common Utilities + +### DriverHelper (utils/DriverHelper.ts) +- `waitVisibility(locator, timeout)` - Wait for element to be visible +- `waitAndClick(locator, timeout)` - Wait and click element +- `waitAndGetText(locator, timeout)` - Wait and get text +- `waitDisappearance(locator, timeout)` - Wait for element to disappear +- `navigateToUrl(url)` - Navigate to URL +- `wait(ms)` - Wait for specified milliseconds + +### BrowserTabsUtil (utils/BrowserTabsUtil.ts) +- `navigateTo(url)` - Navigate to URL +- `getCurrentUrl()` - Get current URL +- `maximize()` - Maximize browser window +- `closeAllTabsExceptCurrent()` - Close extra tabs + +### Logger (utils/Logger.ts) +- `Logger.debug()` - Log method name (use at start of public methods) +- `Logger.info(message)` - Log info message +- `Logger.error(message)` - Log error message + +## GitHub Actions Maintenance + +### PR Check Workflow (.github/workflows/pr-check.yml) +Triggers on: +- Pull requests to main or 7.**.x branches +- Changes in `tests/e2e/**` or the workflow file + +Steps performed: +1. Prettier check - Fails if formatting issues found +2. TypeScript compilation - `npm run tsc` +3. ESLint check - `npm run lint` +4. Deploy Che on minikube +5. Run Empty Workspace API test +6. Build E2E Docker image +7. Run Empty Workspace UI test + +When modifying tests: +- Ensure `npm run prettier` passes locally +- Ensure `npm run tsc` compiles without errors +- Ensure `npm run lint` passes +- Test locally if possible before pushing + +## Test Patterns + +### Workspace Lifecycle Pattern +```typescript +suite('Workspace Test', function (): void { + const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); + const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); + const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); + + suiteSetup('Login', async function (): Promise { + await loginTests.loginIntoChe(); + }); + + test('Create workspace', async function (): Promise { + await workspaceHandlingTests.createAndStartWorkspace(); + }); + + test('Obtain workspace name', async function (): Promise { + await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); + }); + + test('Register running workspace', function (): void { + registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName()); + }); + + suiteTeardown('Stop and delete workspace', async function (): Promise { + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + }); +}); +``` + +### API Test Pattern (No Browser) +```typescript +suite('API Test', function (): void { + const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = + e2eContainer.get(CLASSES.KubernetesCommandLineToolsExecutor); + + suiteSetup('Setup', async function (): Promise { + kubernetesCommandLineToolsExecutor.loginToOcp(); + }); + + test('Execute API operation', function (): void { + const output: ShellString = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(yaml); + expect(output.stdout).contains('condition met'); + }); + + suiteTeardown('Cleanup', function (): void { + kubernetesCommandLineToolsExecutor.deleteDevWorkspace(); + }); +}); +``` + +## Package Management + +- Add packages as **dev dependencies**: `npm install --save-dev ` +- After any changes to package.json, regenerate lock file: `npm install` +- Run `npm ci` for clean install from lock file + +## Debugging + +- Set `TS_SELENIUM_LOG_LEVEL=TRACE` for verbose logging +- Use VNC on port 5920 when running in Docker +- View test results with `npm run open-allure-dasboard` +- Screenshots are captured on test failures by CheReporter + +## Common Issues and Solutions + +1. **Flaky Tests**: Increase timeout or add explicit waits with `DriverHelper.wait()` +2. **Element Not Found**: Verify locator with browser dev tools, check for dynamic loading +3. **Stale Element**: Re-fetch element after page navigation +4. **Timeout Errors**: Use appropriate timeout constants from `TIMEOUT_CONSTANTS` + +## Maintenance Guidelines + +When helping with E2E test development and maintenance: + +1. **Keep command files up to date** - When test infrastructure changes (new environment variables, test patterns, or execution methods), update the related command files in `.claude/commands/`: + - `run-che-e2e-test-locally.md` + - `run-che-e2e-test-using-podman.md` + - `run-devspaces-e2e-test-locally.md` + - `run-devspaces-e2e-test-using-podman.md` + +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. + +3. **Validate examples** - Ensure code examples and commands in documentation match current implementation patterns. + +4. **Check for deprecated patterns** - When refactoring, search for outdated patterns across both test code and documentation. + +5. **Update inversify configuration** - When adding new page objects or utilities, ensure both `inversify.types.ts` and `inversify.config.ts` are updated. + +## Related Commands + +For running E2E tests, use these companion commands: + +### Eclipse Che +- **`/run-che-e2e-test-using-podman`** - Run E2E tests against Eclipse Che using the che-e2e container with Podman (isolated environment with VNC support) +- **`/run-che-e2e-test-locally`** - Run E2E tests against Eclipse Che using a local Chrome browser (for development and debugging) + +### Red Hat OpenShift Dev Spaces +- **`/run-devspaces-e2e-test-using-podman`** - Run E2E tests against Dev Spaces using the che-e2e container with Podman (includes OAuth configuration) +- **`/run-devspaces-e2e-test-locally`** - Run E2E tests against Dev Spaces using a local Chrome browser (includes SSO/OAuth setup) diff --git a/tests/e2e/CLAUDE.md b/tests/e2e/CLAUDE.md new file mode 100644 index 00000000000..0501fc3e0d9 --- /dev/null +++ b/tests/e2e/CLAUDE.md @@ -0,0 +1,146 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +**Available commands:** +- `/e2e-test-development` - Comprehensive E2E test development guidance (code style, patterns, architecture) + +**Eclipse Che:** +- `/run-che-e2e-test-using-podman` - Run E2E tests using che-e2e container with Podman +- `/run-che-e2e-test-locally` - Run E2E tests using local Chrome browser + +**Red Hat OpenShift Dev Spaces:** +- `/run-devspaces-e2e-test-using-podman` - Run E2E tests against Dev Spaces using Podman container +- `/run-devspaces-e2e-test-locally` - Run E2E tests against Dev Spaces using local browser + +## Overview + +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. + +## Quick Reference + +### Essential Commands + +```bash +npm ci # Install dependencies +npm run test # Run all tests +npm run lint # Fix linting issues +npm run prettier # Fix formatting +npm run tsc # Compile TypeScript +export USERSTORY=TestName && npm run test # Run single test +``` + +### Key Files to Read + +- `CODE_STYLE.md` - **CRITICAL**: Coding standards (read before writing any code) +- `README.md` - Setup and launch instructions +- `configs/inversify.config.ts` - Dependency injection container +- `configs/inversify.types.ts` - Class and type identifiers +- `constants/TIMEOUT_CONSTANTS.ts` - Timeout values for waits + +## Code Style Requirements (CRITICAL) + +**Always read `CODE_STYLE.md` before modifying code.** + +### Required File Header +```typescript +/** ******************************************************************* + * copyright (c) 2023 Red Hat, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + **********************************************************************/ +``` + +### Page Object Pattern +```typescript +@injectable() +export class MyPage { + private static readonly BUTTON: By = By.xpath('//button'); + + constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) {} + + async clickButton(): Promise { + Logger.debug(); + await this.driverHelper.waitAndClick(MyPage.BUTTON); + } + + private getDynamicLocator(name: string): By { + return By.xpath(`//div[text()="${name}"]`); + } +} +``` + +### Test Structure (TDD Style - No Arrow Functions) +```typescript +suite('Suite Name', function (): void { + const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); + + suiteSetup('Setup', async function (): Promise { + // setup code + }); + + test('Test case', async function (): Promise { + // test code + }); + + suiteTeardown('Cleanup', async function (): Promise { + // cleanup code + }); +}); +``` + +### Key Rules +- `@injectable()` on all page objects and utilities +- `Logger.debug()` at start of every public method +- Static locators: `private static readonly NAME: By` +- Dynamic locators: private methods returning `By` +- NO arrow functions in Mocha declarations +- Explicit return types on ALL functions +- Single quotes for strings +- Comments start lowercase: `// todo issue crw-1010` + +## Directory Structure + +| Directory | Purpose | +|-----------|---------| +| `specs/` | Test files (api/, factory/, miscellaneous/) | +| `pageobjects/` | Page Object classes | +| `utils/` | DriverHelper, Logger, API handlers | +| `tests-library/` | Reusable helpers (LoginTests, WorkspaceHandlingTests) | +| `constants/` | Environment variables and timeouts | +| `configs/` | Inversify DI, Mocha config | + +## Adding New Components + +### New Page Object +1. Create in `pageobjects//NewPage.ts` +2. Add to `inversify.types.ts`: `NewPage: 'NewPage'` +3. Add to `inversify.config.ts`: `e2eContainer.bind(CLASSES.NewPage).to(NewPage)` + +### New Test +1. Create `specs//TestName.spec.ts` +2. Run: `export USERSTORY=TestName && npm run test` + +## GitHub Actions + +PR checks run on changes to `tests/e2e/**`: +1. Prettier formatting check +2. TypeScript compilation +3. ESLint linting +4. API and UI tests on minikube + +**Before pushing**: Run `npm run prettier && npm run tsc && npm run lint` + +## Environment Variables + +| Variable | Description | +|----------|-------------| +| `TS_SELENIUM_BASE_URL` | Che dashboard URL | +| `TS_SELENIUM_OCP_USERNAME` | OpenShift username | +| `TS_SELENIUM_OCP_PASSWORD` | OpenShift password | +| `USERSTORY` | Test file to run (without .spec.ts) | +| `TS_PLATFORM` | `openshift` or `kubernetes` | From ca7093c8b6d52f2ba558d12fd40665c8ee688e15 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Tue, 13 Jan 2026 16:46:38 +0200 Subject: [PATCH 2/8] Move skill to the e2e-test-development directory Signed-off-by: Dmytro Nochevnov --- .../{e2e-test-development.md => e2e-test-development/SKILL.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/e2e/.claude/skills/{e2e-test-development.md => e2e-test-development/SKILL.md} (100%) diff --git a/tests/e2e/.claude/skills/e2e-test-development.md b/tests/e2e/.claude/skills/e2e-test-development/SKILL.md similarity index 100% rename from tests/e2e/.claude/skills/e2e-test-development.md rename to tests/e2e/.claude/skills/e2e-test-development/SKILL.md From 3fd6c0261c9a1be21f2c2c3b24e5069f0dc62805 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Wed, 28 Jan 2026 22:52:52 +0200 Subject: [PATCH 3/8] Don't use TS_IDE_LOAD_TIMEOUT to wait for trust dialog to appear --- tests/e2e/constants/TIMEOUT_CONSTANTS.ts | 6 ++++++ tests/e2e/tests-library/ProjectAndFileTests.ts | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/e2e/constants/TIMEOUT_CONSTANTS.ts b/tests/e2e/constants/TIMEOUT_CONSTANTS.ts index e4dc39b55e3..5f366a2752e 100644 --- a/tests/e2e/constants/TIMEOUT_CONSTANTS.ts +++ b/tests/e2e/constants/TIMEOUT_CONSTANTS.ts @@ -24,6 +24,7 @@ export const TIMEOUT_CONSTANTS: { TS_SELENIUM_LOAD_PAGE_TIMEOUT: number; TS_SELENIUM_START_WORKSPACE_TIMEOUT: number; TS_SELENIUM_WAIT_FOR_URL: number; + TS_TRUST_DIALOG_WAIT_TIMEOUT: number; TS_WAIT_LOADER_ABSENCE_TIMEOUT: number; TS_WAIT_LOADER_PRESENCE_TIMEOUT: number; } = { @@ -107,6 +108,11 @@ export const TIMEOUT_CONSTANTS: { */ TS_DIALOG_WINDOW_DEFAULT_TIMEOUT: Number(process.env.TS_DIALOG_WINDOW_DEFAULT_TIMEOUT) || 10_000, + /** + * timeout for waiting for trust dialog to appear, "20 000" by default. + */ + TS_TRUST_DIALOG_WAIT_TIMEOUT: Number(process.env.TS_TRUST_DIALOG_WAIT_TIMEOUT) || 20_000, + /** * timeout for clicking on visible item, "5 000" by default */ diff --git a/tests/e2e/tests-library/ProjectAndFileTests.ts b/tests/e2e/tests-library/ProjectAndFileTests.ts index a23fafe5888..2209cd5a1b3 100644 --- a/tests/e2e/tests-library/ProjectAndFileTests.ts +++ b/tests/e2e/tests-library/ProjectAndFileTests.ts @@ -66,8 +66,8 @@ export class ProjectAndFileTests { try { await workbench.click(); - // add TS_IDE_LOAD_TIMEOUT timeout for waiting for reloading the IDE - await this.driverHelper.wait(TIMEOUT_CONSTANTS.TS_IDE_LOAD_TIMEOUT); + // add timeout for waiting for trust dialog to appear + await this.driverHelper.wait(TIMEOUT_CONSTANTS.TS_TRUST_DIALOG_WAIT_TIMEOUT); await this.driverHelper.waitVisibility( this.cheCodeLocatorLoader.webCheCodeLocators.WelcomeContent.text, TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM @@ -101,8 +101,8 @@ export class ProjectAndFileTests { Logger.debug(); try { - // add TS_IDE_LOAD_TIMEOUT timeout for waiting for appearing the box - await this.driverHelper.wait(TIMEOUT_CONSTANTS.TS_IDE_LOAD_TIMEOUT); + // add timeout for waiting for trust publisher dialog to appear + await this.driverHelper.wait(TIMEOUT_CONSTANTS.TS_TRUST_DIALOG_WAIT_TIMEOUT); await this.driverHelper.waitVisibility( ProjectAndFileTests.TRUST_PUBLISHER_BOX, TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM From 7ebf697fe20e511b770119d2f4866bffdc4c3599 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Fri, 30 Jan 2026 20:05:37 +0200 Subject: [PATCH 4/8] Revert "Don't use TS_IDE_LOAD_TIMEOUT to wait for trust dialog to appear" This reverts commit 921f5cb9188bb73cce8642057f89aee2d7c8398a. --- tests/e2e/constants/TIMEOUT_CONSTANTS.ts | 6 ------ tests/e2e/tests-library/ProjectAndFileTests.ts | 8 ++++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/e2e/constants/TIMEOUT_CONSTANTS.ts b/tests/e2e/constants/TIMEOUT_CONSTANTS.ts index 5f366a2752e..e4dc39b55e3 100644 --- a/tests/e2e/constants/TIMEOUT_CONSTANTS.ts +++ b/tests/e2e/constants/TIMEOUT_CONSTANTS.ts @@ -24,7 +24,6 @@ export const TIMEOUT_CONSTANTS: { TS_SELENIUM_LOAD_PAGE_TIMEOUT: number; TS_SELENIUM_START_WORKSPACE_TIMEOUT: number; TS_SELENIUM_WAIT_FOR_URL: number; - TS_TRUST_DIALOG_WAIT_TIMEOUT: number; TS_WAIT_LOADER_ABSENCE_TIMEOUT: number; TS_WAIT_LOADER_PRESENCE_TIMEOUT: number; } = { @@ -108,11 +107,6 @@ export const TIMEOUT_CONSTANTS: { */ TS_DIALOG_WINDOW_DEFAULT_TIMEOUT: Number(process.env.TS_DIALOG_WINDOW_DEFAULT_TIMEOUT) || 10_000, - /** - * timeout for waiting for trust dialog to appear, "20 000" by default. - */ - TS_TRUST_DIALOG_WAIT_TIMEOUT: Number(process.env.TS_TRUST_DIALOG_WAIT_TIMEOUT) || 20_000, - /** * timeout for clicking on visible item, "5 000" by default */ diff --git a/tests/e2e/tests-library/ProjectAndFileTests.ts b/tests/e2e/tests-library/ProjectAndFileTests.ts index 2209cd5a1b3..a23fafe5888 100644 --- a/tests/e2e/tests-library/ProjectAndFileTests.ts +++ b/tests/e2e/tests-library/ProjectAndFileTests.ts @@ -66,8 +66,8 @@ export class ProjectAndFileTests { try { await workbench.click(); - // add timeout for waiting for trust dialog to appear - await this.driverHelper.wait(TIMEOUT_CONSTANTS.TS_TRUST_DIALOG_WAIT_TIMEOUT); + // add TS_IDE_LOAD_TIMEOUT timeout for waiting for reloading the IDE + await this.driverHelper.wait(TIMEOUT_CONSTANTS.TS_IDE_LOAD_TIMEOUT); await this.driverHelper.waitVisibility( this.cheCodeLocatorLoader.webCheCodeLocators.WelcomeContent.text, TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM @@ -101,8 +101,8 @@ export class ProjectAndFileTests { Logger.debug(); try { - // add timeout for waiting for trust publisher dialog to appear - await this.driverHelper.wait(TIMEOUT_CONSTANTS.TS_TRUST_DIALOG_WAIT_TIMEOUT); + // add TS_IDE_LOAD_TIMEOUT timeout for waiting for appearing the box + await this.driverHelper.wait(TIMEOUT_CONSTANTS.TS_IDE_LOAD_TIMEOUT); await this.driverHelper.waitVisibility( ProjectAndFileTests.TRUST_PUBLISHER_BOX, TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM From 3c2ac74e116a11bcead129a2e1c204c32f7f41b8 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Fri, 30 Jan 2026 20:20:14 +0200 Subject: [PATCH 5/8] Add TS_IDE_START_TIMEOUT constant Signed-off-by: Dmytro Nochevnov --- tests/e2e/constants/TIMEOUT_CONSTANTS.ts | 6 ++++++ tests/e2e/tests-library/ProjectAndFileTests.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/e2e/constants/TIMEOUT_CONSTANTS.ts b/tests/e2e/constants/TIMEOUT_CONSTANTS.ts index e4dc39b55e3..3fe433b498c 100644 --- a/tests/e2e/constants/TIMEOUT_CONSTANTS.ts +++ b/tests/e2e/constants/TIMEOUT_CONSTANTS.ts @@ -17,6 +17,7 @@ export const TIMEOUT_CONSTANTS: { TS_EXPAND_PROJECT_TREE_ITEM_TIMEOUT: number; TS_FIND_EXTENSION_TEST_TIMEOUT: number; TS_IDE_LOAD_TIMEOUT: number; + TS_IDE_START_TIMEOUT: number; TS_NOTIFICATION_WAIT_TIMEOUT: number; TS_SELENIUM_CLICK_ON_VISIBLE_ITEM: number; TS_SELENIUM_DEFAULT_ATTEMPTS: number; @@ -49,6 +50,11 @@ export const TIMEOUT_CONSTANTS: { */ TS_IDE_LOAD_TIMEOUT: Number(process.env.TS_IDE_LOAD_TIMEOUT) || 20_000, + /** + * timeout for waiting for IDE to start during workspace startup, "310 000" by default. + */ + TS_IDE_START_TIMEOUT: Number(process.env.TS_IDE_START_TIMEOUT) || 310_000, + /** * timeout in milliseconds waiting for workspace start, "360 000" by default. */ diff --git a/tests/e2e/tests-library/ProjectAndFileTests.ts b/tests/e2e/tests-library/ProjectAndFileTests.ts index a23fafe5888..a266441a9d1 100644 --- a/tests/e2e/tests-library/ProjectAndFileTests.ts +++ b/tests/e2e/tests-library/ProjectAndFileTests.ts @@ -41,7 +41,7 @@ export class ProjectAndFileTests { const start: number = new Date().getTime(); await this.driverHelper.waitVisibility( this.cheCodeLocatorLoader.webCheCodeLocators.Workbench.constructor, - TIMEOUT_CONSTANTS.TS_SELENIUM_START_WORKSPACE_TIMEOUT + TIMEOUT_CONSTANTS.TS_IDE_START_TIMEOUT ); const end: number = new Date().getTime(); Logger.debug(`editor was opened in ${end - start} seconds.`); From a9c4504e1c2dc39453b0fcfd38c6d0ea61392137 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Sun, 1 Feb 2026 01:09:28 +0200 Subject: [PATCH 6/8] Improve Claude Code command which runs E2E typescript tests Signed-off-by: Dmytro Nochevnov --- .../commands/run-che-e2e-test-locally.md | 286 --------- .../commands/run-che-e2e-test-using-podman.md | 216 ------- .../run-devspaces-e2e-test-locally.md | 323 ---------- .../run-devspaces-e2e-test-using-podman.md | 259 -------- tests/e2e/.claude/commands/run-e2e-test.md | 573 ++++++++++++++++++ tests/e2e/.claude/settings.local.json | 13 + .../skills/e2e-test-development/SKILL.md | 245 ++++---- tests/e2e/CLAUDE.md | 76 ++- tests/e2e/README.md | 2 +- 9 files changed, 761 insertions(+), 1232 deletions(-) delete mode 100644 tests/e2e/.claude/commands/run-che-e2e-test-locally.md delete mode 100644 tests/e2e/.claude/commands/run-che-e2e-test-using-podman.md delete mode 100644 tests/e2e/.claude/commands/run-devspaces-e2e-test-locally.md delete mode 100644 tests/e2e/.claude/commands/run-devspaces-e2e-test-using-podman.md create mode 100644 tests/e2e/.claude/commands/run-e2e-test.md create mode 100644 tests/e2e/.claude/settings.local.json diff --git a/tests/e2e/.claude/commands/run-che-e2e-test-locally.md b/tests/e2e/.claude/commands/run-che-e2e-test-locally.md deleted file mode 100644 index 0bc4330eb44..00000000000 --- a/tests/e2e/.claude/commands/run-che-e2e-test-locally.md +++ /dev/null @@ -1,286 +0,0 @@ -# Run E2E Tests Using Local Browser - -Run E2E tests against Eclipse Che using a local Chrome browser. This is useful for development and debugging as you can see the browser in real-time. - -## Execution Mode - ASK USER FIRST - -Before proceeding, ask the user which execution mode they prefer using AskUserQuestion: - -1. **Just bash command** - Provide only the bash command to run the test (assumes dependencies installed and code already compiled) -2. **Build and run** - Check for changes in the working directory (`git status`), rebuild if there are modifications, then run the test -3. **Check staged changes only** - Only rebuild if there are git staged changes, otherwise just run the test - -Based on the user's choice: -- **Just bash command**: Skip build steps, provide `export USERSTORY= && npm run test` command -- **Build and run**: Run `npm ci && npm run tsc` before the test if `git status` shows any changes -- **Check staged changes only**: Run `git diff --cached --name-only` to check for staged changes; rebuild only if staged files exist in the e2e directory - -## Required Parameters - ASK USER - -Before running tests, you MUST ask the user for these required parameters using AskUserQuestion: - -1. **Eclipse Che URL** (`TS_SELENIUM_BASE_URL`) - The Che dashboard URL - - - Example: `https://che.apps.ocp.crw-qe.com/` - -2. **Test Name** (`USERSTORY`) - Which test to run - - - Common options: `EmptyWorkspace`, `Factory`, `SmokeTest`, `EmptyWorkspaceAPI` - -3. **Username** (`TS_SELENIUM_OCP_USERNAME`) - OpenShift/Kubernetes username - - - Example: `admin`, `developer`, `che@eclipse.org` - -4. **Password** (`TS_SELENIUM_OCP_PASSWORD`) - OpenShift/Kubernetes password - -5. **Platform** (`TS_PLATFORM`) - Optional, deployment platform - - Options: `openshift` (default), `kubernetes` - -## Test-Specific Parameters - ASK BASED ON TEST NAME - -After getting the test name, read the test spec file to identify additional required parameters. -Use `cat specs/**/${USERSTORY}.spec.ts` to find the test file and look for environment variables used. - -### Factory URL Tests (Factory, RefusedOAuthFactory, NoSetupRepoFactory, etc.) -These tests navigate directly to a factory URL to create a workspace. -Ask for these additional parameters: -- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository to clone (used to construct the factory URL) -- **Git Provider** (`TS_SELENIUM_FACTORY_GIT_PROVIDER`) - `github`, `gitlab`, `bitbucket`, `azure-devops` -- **OAuth Enabled** (`TS_SELENIUM_GIT_PROVIDER_OAUTH`) - `true` or `false` - -### Git Repo Import Form Tests (FactoryWithGitRepoOptions, CreateWorkspaceWithExistingNameFromGitUrl, etc.) -These tests use the Dashboard's "Create Workspace" form to import a git repository. -Ask for these additional parameters: -- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository URL to enter in the form -- **Branch Name** (`TS_SELENIUM_FACTORY_GIT_REPO_BRANCH`) - Optional, branch to checkout (default: `main`) -- **Project Name** (`TS_SELENIUM_PROJECT_NAME`) - Optional, expected project folder name - -### API Tests (EmptyWorkspaceAPI, ContainerOverridesAPI, etc.) -Ask for: -- **Namespace** (`TS_API_TEST_NAMESPACE`) - Optional, for specific namespace testing -- **UDI Image** (`TS_API_TEST_UDI_IMAGE`) - Optional, custom Universal Developer Image - -### Sample/Devfile Tests -Ask for: -- **Sample List** (`TS_SAMPLE_LIST`) - Which samples to test, e.g., `Node.js Express` - -### SSH/PAT Tests (SshUrlNoOauthPatFactory, etc.) -Ask for: -- **SSH Private Key Path** or **Personal Access Token** details as needed by the test - -## Prerequisites - -1. **Node.js 22.x** (use nvm to manage versions) -2. **Chrome browser** version 114.x or later -3. **ChromeDriver** matching your Chrome version (installed via npm) -4. Environment variables configured - -## Full Test Run (Recommended) - -Complete workflow with clean build and all checks: - -```bash -cd tests/e2e - -# Use correct Node.js version -nvm use v22.10.0 - -# Set environment variables -export TS_SELENIUM_LOG_LEVEL="TRACE" -export TS_SELENIUM_BASE_URL=https://che.apps.cluster.example.com/ -export TS_SELENIUM_OCP_USERNAME=admin -export TS_SELENIUM_OCP_PASSWORD=password -export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 -export VIDEO_RECORDING=true -export TS_DEBUG_MODE=true -export NODE_TLS_REJECT_UNAUTHORIZED=0 -export TS_DELETE_WORKSPACE_ON_FAILED_TEST=true -export USERSTORY=EmptyWorkspace - -# Clean build and run tests -rm -rf node_modules dist && npm ci && npm run lint && npm run prettier && npm run tsc && npm test -``` - -## Quick Setup - -```bash -cd tests/e2e - -# Use correct Node.js version -nvm use v22.10.0 - -# Install dependencies -npm ci - -# Export required environment variables -export TS_SELENIUM_BASE_URL= -export TS_SELENIUM_OCP_USERNAME= -export TS_SELENIUM_OCP_PASSWORD= -export NODE_TLS_REJECT_UNAUTHORIZED=0 -``` - -## Running Tests - -### Run Specific Test File - -```bash -# UI test -export USERSTORY=SmokeTest && npm run test - -# Factory test -export USERSTORY=Factory && npm run test - -# API-only test (no browser) -export USERSTORY=EmptyWorkspaceAPI && npm run driver-less-test -``` - -### Run with Verbose Logging - -```bash -export TS_SELENIUM_LOG_LEVEL=TRACE -export USERSTORY=SmokeTest && npm run test -``` - -## Common Test Configurations - -### OpenShift with OAuth - -```bash -export TS_SELENIUM_BASE_URL=https://che.apps.cluster.example.com -export TS_SELENIUM_OCP_USERNAME=admin -export TS_SELENIUM_OCP_PASSWORD=password -export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true -export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd -export NODE_TLS_REJECT_UNAUTHORIZED=0 -export USERSTORY=Factory && npm run test -``` - -### OpenShift without OAuth - -```bash -export TS_SELENIUM_BASE_URL=https://che.apps.cluster.example.com -export TS_SELENIUM_OCP_USERNAME=admin -export TS_SELENIUM_OCP_PASSWORD=password -export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=false -export NODE_TLS_REJECT_UNAUTHORIZED=0 -export USERSTORY=EmptyWorkspace && npm run test -``` - -### Kubernetes Platform - -```bash -export TS_PLATFORM=kubernetes -export TS_SELENIUM_BASE_URL=https://che.192.168.99.100.nip.io -export TS_SELENIUM_K8S_USERNAME=che@eclipse.org -export TS_SELENIUM_K8S_PASSWORD=admin -export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=false -export NODE_TLS_REJECT_UNAUTHORIZED=0 -export USERSTORY=EmptyWorkspace && npm run test -``` - -### Factory Tests with Git Provider - -```bash -export TS_SELENIUM_BASE_URL=https://devspaces.example.com -export TS_SELENIUM_OCP_USERNAME=user -export TS_SELENIUM_OCP_PASSWORD=password -export TS_SELENIUM_FACTORY_GIT_REPO_URL=https://github.com/user/repo -export TS_SELENIUM_FACTORY_GIT_PROVIDER=github -export TS_SELENIUM_GIT_PROVIDER_OAUTH=true -export USERSTORY=Factory && npm run test -``` - -## Timeout Configuration - -Adjust timeouts for slower environments: - -```bash -export TS_SELENIUM_LOAD_PAGE_TIMEOUT=60000 -export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 -export TS_COMMON_DASHBOARD_WAIT_TIMEOUT=30000 -export MOCHA_DEFAULT_TIMEOUT=420000 -``` - -## Headless Mode - -For CI environments or when you don't need to see the browser: - -```bash -export TS_SELENIUM_HEADLESS=true -export USERSTORY=SmokeTest && npm run test -``` - -## Debug Mode - -Enable detailed logging for troubleshooting: - -```bash -export TS_SELENIUM_LOG_LEVEL=TRACE -export TS_SELENIUM_PRINT_TIMEOUT_VARIABLES=true -export USERSTORY=SmokeTest && npm run test -``` - -## View Test Reports - -After test execution, view Allure reports: - -```bash -npm run open-allure-dasboard -``` - -## Pre-flight Checks - -Before running tests, verify your setup: - -```bash -# Check TypeScript compiles -npm run tsc - -# Check linting passes -npm run lint - -# Check formatting -npm run prettier -- --check . -``` - -## Delayed/Dynamic Test Suites - -For tests that require dynamic configuration: - -```bash -export USERSTORY=DevfileAcceptanceTestAPI && npm run delayed-test -``` - -## Available Test Files - -Common test specifications: - -- `EmptyWorkspace` - Basic workspace creation UI test -- `EmptyWorkspaceAPI` - Workspace creation via API (no browser) -- `Factory` - Factory URL workspace creation with git operations -- `SmokeTest` - Quick validation test -- `UserPreferencesTest` - User preferences functionality - -Run `ls specs/` to see all available test categories. - -## Troubleshooting - -### ChromeDriver Version Mismatch - -```bash -# Update chromedriver to match Chrome version -npm install chromedriver@ -``` - -### Certificate Errors - -```bash -export NODE_TLS_REJECT_UNAUTHORIZED=0 -``` - -### Slow Workspace Start - -```bash -export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 -export TS_SELENIUM_DEFAULT_ATTEMPTS=3 -``` diff --git a/tests/e2e/.claude/commands/run-che-e2e-test-using-podman.md b/tests/e2e/.claude/commands/run-che-e2e-test-using-podman.md deleted file mode 100644 index 8171d584bea..00000000000 --- a/tests/e2e/.claude/commands/run-che-e2e-test-using-podman.md +++ /dev/null @@ -1,216 +0,0 @@ -# Run E2E Tests Using Podman/Container Image - -Run E2E tests against Eclipse Che using the che-e2e container image with Podman. This provides a consistent, isolated test environment with Chrome browser and VNC support. - -## Execution Mode - ASK USER FIRST - -Before proceeding, ask the user which execution mode they prefer using AskUserQuestion: - -1. **Just bash command** - Provide only the podman run command (uses published image, no rebuild) -2. **Build and run** - Check for changes in the working directory (`git status`), rebuild container image if there are modifications, then run the test -3. **Check staged changes only** - Only rebuild container if there are git staged changes, otherwise use published image - -Based on the user's choice: -- **Just bash command**: Skip build steps, provide podman run command with `eclipse/che-e2e:nightly` image -- **Build and run**: Run `podman build` before the test if `git status` shows any changes in e2e directory -- **Check staged changes only**: Run `git diff --cached --name-only` to check for staged changes; rebuild container only if staged files exist in the e2e directory - -## Required Parameters - ASK USER - -Before running tests, you MUST ask the user for these required parameters using AskUserQuestion: - -1. **Eclipse Che URL** (`TS_SELENIUM_BASE_URL`) - The Che dashboard URL - - - Example: `https://che.apps.ocp.crw-qe.com/` - -2. **Test Name** (`USERSTORY`) - Which test to run - - - Common options: `EmptyWorkspace`, `Factory`, `SmokeTest`, `EmptyWorkspaceAPI` - -3. **Username** (`TS_SELENIUM_OCP_USERNAME`) - OpenShift/Kubernetes username - - - Example: `admin`, `developer`, `che@eclipse.org` - -4. **Password** (`TS_SELENIUM_OCP_PASSWORD`) - OpenShift/Kubernetes password - -5. **Platform** (`TS_PLATFORM`) - Optional, deployment platform - - Options: `openshift` (default), `kubernetes` - -## Test-Specific Parameters - ASK BASED ON TEST NAME - -After getting the test name, read the test spec file to identify additional required parameters. -Use `cat specs/**/${USERSTORY}.spec.ts` to find the test file and look for environment variables used. - -### Factory URL Tests (Factory, RefusedOAuthFactory, NoSetupRepoFactory, etc.) -These tests navigate directly to a factory URL to create a workspace. -Ask for these additional parameters: -- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository to clone (used to construct the factory URL) -- **Git Provider** (`TS_SELENIUM_FACTORY_GIT_PROVIDER`) - `github`, `gitlab`, `bitbucket`, `azure-devops` -- **OAuth Enabled** (`TS_SELENIUM_GIT_PROVIDER_OAUTH`) - `true` or `false` - -### Git Repo Import Form Tests (FactoryWithGitRepoOptions, CreateWorkspaceWithExistingNameFromGitUrl, etc.) -These tests use the Dashboard's "Create Workspace" form to import a git repository. -Ask for these additional parameters: -- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository URL to enter in the form -- **Branch Name** (`TS_SELENIUM_FACTORY_GIT_REPO_BRANCH`) - Optional, branch to checkout (default: `main`) -- **Project Name** (`TS_SELENIUM_PROJECT_NAME`) - Optional, expected project folder name - -### API Tests (EmptyWorkspaceAPI, ContainerOverridesAPI, etc.) -Ask for: -- **Namespace** (`TS_API_TEST_NAMESPACE`) - Optional, for specific namespace testing -- **UDI Image** (`TS_API_TEST_UDI_IMAGE`) - Optional, custom Universal Developer Image - -### Sample/Devfile Tests -Ask for: -- **Sample List** (`TS_SAMPLE_LIST`) - Which samples to test, e.g., `Node.js Express` - -### SSH/PAT Tests (SshUrlNoOauthPatFactory, etc.) -Ask for: -- **SSH Private Key Path** or **Personal Access Token** details as needed by the test - -## Auto-Rebuild on Local Changes - -Before running tests, check for local modifications and rebuild the container if needed: - -```bash -cd tests/e2e - -# Check for uncommitted changes and rebuild if found -if [[ -n $(git status --porcelain .) ]]; then - echo "Local changes detected, rebuilding container image..." - podman build -t quay.io/eclipse/che-e2e:local -f build/dockerfiles/Dockerfile . - E2E_IMAGE="quay.io/eclipse/che-e2e:local" -else - echo "No local changes, using published image..." - E2E_IMAGE="eclipse/che-e2e:nightly" -fi - -# Run tests with the appropriate image -podman rm -f selenium-e2e 2>/dev/null; \ -podman run -it --shm-size=2g -p 5920:5920 \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ - -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ - -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ - $E2E_IMAGE -``` - -## Podman Run Commands - -### Basic Podman Run (using published image) - -```bash -cd tests/e2e -podman rm -f selenium-e2e 2>/dev/null; \ -podman run -it --shm-size=2g -p 5920:5920 \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ - -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ - -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ - eclipse/che-e2e:nightly -``` - -### Podman Run with Local E2E Code Mounted - -Use this when testing local modifications to E2E tests: - -```bash -cd tests/e2e -podman rm -f selenium-e2e 2>/dev/null; \ -podman run -it --shm-size=2g -p 5920:5920 \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ - -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ - -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ - -v $(pwd):/tmp/e2e:Z \ - eclipse/che-e2e:nightly -``` - -### Running Specific Test in Podman - -```bash -podman run -it --shm-size=2g -p 5920:5920 \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ - -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ - -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ - -e USERSTORY=SmokeTest \ - eclipse/che-e2e:nightly -``` - -### Full Example with All Common Options (Recommended) - -```bash -podman rm -f selenium-e2e 2>/dev/null; \ -podman run -it --shm-size=2g -p 5920:5920 \ - --network="host" \ - --name selenium-e2e \ - -e TS_PLATFORM=openshift \ - -e TS_SELENIUM_BASE_URL=https://che.apps.ocp.crw-qe.com/ \ - -e TS_SELENIUM_OCP_USERNAME=admin \ - -e TS_SELENIUM_OCP_PASSWORD=password \ - -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ - -e TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd \ - -e TS_SELENIUM_LOG_LEVEL=TRACE \ - -e TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 \ - -e TS_DEBUG_MODE=true \ - -e NODE_TLS_REJECT_UNAUTHORIZED=0 \ - -e TS_DELETE_WORKSPACE_ON_FAILED_TEST=true \ - -e VIDEO_RECORDING=true \ - -e USERSTORY=EmptyWorkspace \ - -v /tmp/e2e/report:/tmp/e2e/report:Z \ - -v /tmp/e2e/video:/tmp/ffmpeg_report:Z \ - eclipse/che-e2e:nightly -``` - -### Kubernetes Platform Example - -```bash -podman run -it --shm-size=2g -p 5920:5920 \ - --network="host" \ - --name selenium-e2e \ - -e TS_PLATFORM=kubernetes \ - -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ - -e TS_SELENIUM_K8S_USERNAME=$TS_SELENIUM_K8S_USERNAME \ - -e TS_SELENIUM_K8S_PASSWORD=$TS_SELENIUM_K8S_PASSWORD \ - -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=false \ - -e NODE_TLS_REJECT_UNAUTHORIZED=0 \ - -e USERSTORY=EmptyWorkspace \ - eclipse/che-e2e:nightly -``` - -## VNC Access for Debugging - -Connect to VNC at `0.0.0.0:5920` to watch tests running in the container. - -## Build Local Container Image - -To build and use a local container image: - -```bash -cd tests/e2e -podman build -t quay.io/eclipse/che-e2e:local -f build/dockerfiles/Dockerfile . - -# Then run with local image -podman run -it --shm-size=2g -p 5920:5920 \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ - quay.io/eclipse/che-e2e:local -``` - -## Cleanup - -Remove existing container before running again: - -```bash -podman rm -f selenium-e2e -``` - -## Report Collection - -Mount volumes to collect test reports: - -```bash --v /local/path/report:/tmp/e2e/report:Z \ --v /local/path/video:/tmp/ffmpeg_report:Z -``` diff --git a/tests/e2e/.claude/commands/run-devspaces-e2e-test-locally.md b/tests/e2e/.claude/commands/run-devspaces-e2e-test-locally.md deleted file mode 100644 index 6851b7c2b6d..00000000000 --- a/tests/e2e/.claude/commands/run-devspaces-e2e-test-locally.md +++ /dev/null @@ -1,323 +0,0 @@ -# Run E2E Tests Against Dev Spaces Using Local Browser - -Run E2E tests against Red Hat OpenShift Dev Spaces using a local Chrome browser. This is useful for development and debugging as you can see the browser in real-time. - -## Execution Mode - ASK USER FIRST - -Before proceeding, ask the user which execution mode they prefer using AskUserQuestion: - -1. **Just bash command** - Provide only the bash command to run the test (assumes dependencies installed and code already compiled) -2. **Build and run** - Check for changes in the working directory (`git status`), rebuild if there are modifications, then run the test -3. **Check staged changes only** - Only rebuild if there are git staged changes, otherwise just run the test - -Based on the user's choice: -- **Just bash command**: Skip build steps, provide `export USERSTORY= && npm run test` command -- **Build and run**: Run `npm ci && npm run tsc` before the test if `git status` shows any changes -- **Check staged changes only**: Run `git diff --cached --name-only` to check for staged changes; rebuild only if staged files exist in the e2e directory - -## Required Parameters - ASK USER - -Before running tests, you MUST ask the user for these required parameters using AskUserQuestion: - -1. **Dev Spaces URL** (`TS_SELENIUM_BASE_URL`) - The Dev Spaces dashboard URL - - - Example: `https://devspaces.apps.ocp.crw-qe.com/` - -2. **Test Name** (`USERSTORY`) - Which test to run - - - Common options: `EmptyWorkspace`, `Factory`, `SmokeTest`, `EmptyWorkspaceAPI` - -3. **Username** (`TS_SELENIUM_OCP_USERNAME`) - OpenShift username - - - Example: `admin`, `developer`, `user@example.com` - -4. **Password** (`TS_SELENIUM_OCP_PASSWORD`) - OpenShift password - -5. **Login Provider** (`TS_OCP_LOGIN_PAGE_PROVIDER_TITLE`) - Optional, for SSO - - Common options: `htpasswd`, `DevSandbox`, or leave empty for default - -## Test-Specific Parameters - ASK BASED ON TEST NAME - -After getting the test name, read the test spec file to identify additional required parameters. -Use `cat specs/**/${USERSTORY}.spec.ts` to find the test file and look for environment variables used. - -### Factory URL Tests (Factory, RefusedOAuthFactory, NoSetupRepoFactory, etc.) -These tests navigate directly to a factory URL to create a workspace. -Ask for these additional parameters: -- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository to clone (used to construct the factory URL) -- **Git Provider** (`TS_SELENIUM_FACTORY_GIT_PROVIDER`) - `github`, `gitlab`, `bitbucket`, `azure-devops` -- **OAuth Enabled** (`TS_SELENIUM_GIT_PROVIDER_OAUTH`) - `true` or `false` - -### Git Repo Import Form Tests (FactoryWithGitRepoOptions, CreateWorkspaceWithExistingNameFromGitUrl, etc.) -These tests use the Dashboard's "Create Workspace" form to import a git repository. -Ask for these additional parameters: -- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository URL to enter in the form -- **Branch Name** (`TS_SELENIUM_FACTORY_GIT_REPO_BRANCH`) - Optional, branch to checkout (default: `main`) -- **Project Name** (`TS_SELENIUM_PROJECT_NAME`) - Optional, expected project folder name - -### API Tests (EmptyWorkspaceAPI, ContainerOverridesAPI, etc.) -Ask for: -- **Namespace** (`TS_API_TEST_NAMESPACE`) - Optional, for specific namespace testing -- **UDI Image** (`TS_API_TEST_UDI_IMAGE`) - Optional, custom Universal Developer Image - -### Sample/Devfile Tests -Ask for: -- **Sample List** (`TS_SAMPLE_LIST`) - Which samples to test, e.g., `Node.js Express` - -### SSH/PAT Tests (SshUrlNoOauthPatFactory, etc.) -Ask for: -- **SSH Private Key Path** or **Personal Access Token** details as needed by the test - -## Prerequisites - -1. **Node.js 22.x** (use nvm to manage versions) -2. **Chrome browser** version 114.x or later -3. **ChromeDriver** matching your Chrome version (installed via npm) -4. Access to a Dev Spaces instance on OpenShift - -## Full Test Run (Recommended) - -Complete workflow with clean build and all checks: - -```bash -cd tests/e2e - -# Use correct Node.js version -nvm use v22.10.0 - -# Set environment variables -export TS_SELENIUM_LOG_LEVEL="TRACE" -export TS_SELENIUM_BASE_URL=https://devspaces.apps.ocp.crw-qe.com/ -export TS_SELENIUM_OCP_USERNAME=admin -export TS_SELENIUM_OCP_PASSWORD=password -export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd -export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 -export VIDEO_RECORDING=true -export TS_DEBUG_MODE=true -export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true -export NODE_TLS_REJECT_UNAUTHORIZED=0 -export TESTING_APPLICATION_VERSION=3.23.0 -export TS_DELETE_WORKSPACE_ON_FAILED_TEST=true -export USERSTORY=EmptyWorkspace - -# Clean build and run tests -rm -rf node_modules dist && npm ci && npm run lint && npm run prettier && npm run tsc && npm test -``` - -## Quick Setup - -```bash -cd tests/e2e - -# Use correct Node.js version -nvm use v22.10.0 - -# Install dependencies -npm ci - -# Export required environment variables -export TS_SELENIUM_BASE_URL=https://devspaces.apps.cluster.example.com -export TS_SELENIUM_OCP_USERNAME= -export TS_SELENIUM_OCP_PASSWORD= -export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true -export NODE_TLS_REJECT_UNAUTHORIZED=0 -``` - -## Running Tests - -### Run Specific Test File - -```bash -# UI test -export USERSTORY=EmptyWorkspace && npm run test - -# Factory test -export USERSTORY=Factory && npm run test - -# API-only test (no browser) -export USERSTORY=EmptyWorkspaceAPI && npm run driver-less-test -``` - -## Common Dev Spaces Test Configurations - -### Dev Spaces with htpasswd Authentication - -```bash -export TS_SELENIUM_BASE_URL=https://devspaces.apps.ocp.crw-qe.com/ -export TS_SELENIUM_OCP_USERNAME=admin -export TS_SELENIUM_OCP_PASSWORD=password -export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd -export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true -export NODE_TLS_REJECT_UNAUTHORIZED=0 -export USERSTORY=EmptyWorkspace && npm run test -``` - -### Dev Spaces with SSO Provider (e.g., Developer Sandbox) - -```bash -export TS_SELENIUM_BASE_URL=https://devspaces.apps.sandbox.x8i5.p1.openshiftapps.com -export TS_SELENIUM_OCP_USERNAME=user@redhat.com -export TS_SELENIUM_OCP_PASSWORD=password -export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true -export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE="DevSandbox" -export NODE_TLS_REJECT_UNAUTHORIZED=0 -export USERSTORY=EmptyWorkspace && npm run test -``` - -### Dev Spaces Factory Test with GitHub OAuth - -```bash -export TS_SELENIUM_BASE_URL=https://devspaces.apps.cluster.example.com -export TS_SELENIUM_OCP_USERNAME=user@example.com -export TS_SELENIUM_OCP_PASSWORD=password -export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true -export TS_SELENIUM_FACTORY_GIT_REPO_URL=https://github.com/user/repo -export TS_SELENIUM_FACTORY_GIT_PROVIDER=github -export TS_SELENIUM_GIT_PROVIDER_OAUTH=true -export USERSTORY=Factory && npm run test -``` - -### Dev Spaces Factory Test with GitLab OAuth - -```bash -export TS_SELENIUM_BASE_URL=https://devspaces.apps.cluster.example.com -export TS_SELENIUM_OCP_USERNAME=user@example.com -export TS_SELENIUM_OCP_PASSWORD=password -export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true -export TS_SELENIUM_FACTORY_GIT_REPO_URL=https://gitlab.com/user/repo -export TS_SELENIUM_FACTORY_GIT_PROVIDER=gitlab -export TS_SELENIUM_GIT_PROVIDER_OAUTH=true -export USERSTORY=Factory && npm run test -``` - -### Dev Spaces with Bitbucket OAuth - -```bash -export TS_SELENIUM_BASE_URL=https://devspaces.apps.cluster.example.com -export TS_SELENIUM_OCP_USERNAME=user@example.com -export TS_SELENIUM_OCP_PASSWORD=password -export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true -export TS_SELENIUM_FACTORY_GIT_REPO_URL=https://bitbucket.org/user/repo -export TS_SELENIUM_FACTORY_GIT_PROVIDER=bitbucket -export TS_SELENIUM_GIT_PROVIDER_OAUTH=true -export USERSTORY=Factory && npm run test -``` - -### Dev Spaces with Azure DevOps - -```bash -export TS_SELENIUM_BASE_URL=https://devspaces.apps.cluster.example.com -export TS_SELENIUM_OCP_USERNAME=user@example.com -export TS_SELENIUM_OCP_PASSWORD=password -export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true -export TS_SELENIUM_FACTORY_GIT_REPO_URL=https://dev.azure.com/org/project/_git/repo -export TS_SELENIUM_FACTORY_GIT_PROVIDER=azure-devops -export TS_SELENIUM_GIT_PROVIDER_OAUTH=true -export USERSTORY=Factory && npm run test -``` - -## Timeout Configuration - -Adjust timeouts for slower environments or large workspaces: - -```bash -export TS_SELENIUM_LOAD_PAGE_TIMEOUT=60000 -export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 -export TS_COMMON_DASHBOARD_WAIT_TIMEOUT=30000 -export MOCHA_DEFAULT_TIMEOUT=420000 -``` - -## Verbose Logging - -Enable detailed logging for troubleshooting: - -```bash -export TS_SELENIUM_LOG_LEVEL=TRACE -export TS_SELENIUM_PRINT_TIMEOUT_VARIABLES=true -export USERSTORY=Factory && npm run test -``` - -## Headless Mode - -For CI environments or when you don't need to see the browser: - -```bash -export TS_SELENIUM_HEADLESS=true -export USERSTORY=EmptyWorkspace && npm run test -``` - -## View Test Reports - -After test execution, view Allure reports: - -```bash -npm run open-allure-dasboard -``` - -## Pre-flight Checks - -Before running tests, verify your setup: - -```bash -# Check TypeScript compiles -npm run tsc - -# Check linting passes -npm run lint - -# Check formatting -npm run prettier -- --check . -``` - -## Available Test Specifications - -Common tests for Dev Spaces: - -- `EmptyWorkspace` - Basic workspace creation UI test -- `EmptyWorkspaceAPI` - Workspace creation via API (no browser) -- `Factory` - Factory URL workspace creation with git operations -- `SmokeTest` - Quick validation test -- `UserPreferencesTest` - User preferences functionality -- `CustomOpenVSXRegistry` - Custom plugin registry tests -- `WorkspaceIdleTimeout` - Workspace timeout behavior - -Run `ls specs/` to see all available test categories. - -## Key Differences from Eclipse Che - -When testing Dev Spaces vs Eclipse Che: - -- Always set `TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true` -- May need `TS_OCP_LOGIN_PAGE_PROVIDER_TITLE` for SSO provider selection -- Base URL format is typically `https://devspaces.apps.` -- Dev Spaces always runs on OpenShift (`TS_PLATFORM=openshift` is default) - -## Troubleshooting - -### ChromeDriver Version Mismatch - -```bash -npm install chromedriver@ -``` - -### Certificate Errors - -```bash -export NODE_TLS_REJECT_UNAUTHORIZED=0 -``` - -### Slow Workspace Start - -```bash -export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 -export TS_SELENIUM_DEFAULT_ATTEMPTS=3 -``` - -### OAuth Login Issues - -Verify the login provider title matches exactly: - -```bash -# Check the login page for the provider button text -export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE="DevSandbox" -``` diff --git a/tests/e2e/.claude/commands/run-devspaces-e2e-test-using-podman.md b/tests/e2e/.claude/commands/run-devspaces-e2e-test-using-podman.md deleted file mode 100644 index 21d78beafcb..00000000000 --- a/tests/e2e/.claude/commands/run-devspaces-e2e-test-using-podman.md +++ /dev/null @@ -1,259 +0,0 @@ -# Run E2E Tests Against Dev Spaces Using Podman/Container Image - -Run E2E tests against Red Hat OpenShift Dev Spaces using the che-e2e container image with Podman. This provides a consistent, isolated test environment with Chrome browser and VNC support. - -## Execution Mode - ASK USER FIRST - -Before proceeding, ask the user which execution mode they prefer using AskUserQuestion: - -1. **Just bash command** - Provide only the podman run command (uses published image, no rebuild) -2. **Build and run** - Check for changes in the working directory (`git status`), rebuild container image if there are modifications, then run the test -3. **Check staged changes only** - Only rebuild container if there are git staged changes, otherwise use published image - -Based on the user's choice: -- **Just bash command**: Skip build steps, provide podman run command with `eclipse/che-e2e:nightly` image -- **Build and run**: Run `podman build` before the test if `git status` shows any changes in e2e directory -- **Check staged changes only**: Run `git diff --cached --name-only` to check for staged changes; rebuild container only if staged files exist in the e2e directory - -## Required Parameters - ASK USER - -Before running tests, you MUST ask the user for these required parameters using AskUserQuestion: - -1. **Dev Spaces URL** (`TS_SELENIUM_BASE_URL`) - The Dev Spaces dashboard URL - - Example: `https://devspaces.apps.ocp.crw-qe.com/` - -2. **Test Name** (`USERSTORY`) - Which test to run - - Common options: `EmptyWorkspace`, `Factory`, `SmokeTest`, `EmptyWorkspaceAPI` - -3. **Username** (`TS_SELENIUM_OCP_USERNAME`) - OpenShift username - - Example: `admin`, `developer`, `user@example.com` - -4. **Password** (`TS_SELENIUM_OCP_PASSWORD`) - OpenShift password - -5. **Login Provider** (`TS_OCP_LOGIN_PAGE_PROVIDER_TITLE`) - Optional, for SSO - - Common options: `htpasswd`, `DevSandbox`, or leave empty for default - -## Test-Specific Parameters - ASK BASED ON TEST NAME - -After getting the test name, read the test spec file to identify additional required parameters. -Use `cat specs/**/${USERSTORY}.spec.ts` to find the test file and look for environment variables used. - -### Factory URL Tests (Factory, RefusedOAuthFactory, NoSetupRepoFactory, etc.) -These tests navigate directly to a factory URL to create a workspace. -Ask for these additional parameters: -- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository to clone (used to construct the factory URL) -- **Git Provider** (`TS_SELENIUM_FACTORY_GIT_PROVIDER`) - `github`, `gitlab`, `bitbucket`, `azure-devops` -- **OAuth Enabled** (`TS_SELENIUM_GIT_PROVIDER_OAUTH`) - `true` or `false` - -### Git Repo Import Form Tests (FactoryWithGitRepoOptions, CreateWorkspaceWithExistingNameFromGitUrl, etc.) -These tests use the Dashboard's "Create Workspace" form to import a git repository. -Ask for these additional parameters: -- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository URL to enter in the form -- **Branch Name** (`TS_SELENIUM_FACTORY_GIT_REPO_BRANCH`) - Optional, branch to checkout (default: `main`) -- **Project Name** (`TS_SELENIUM_PROJECT_NAME`) - Optional, expected project folder name - -### API Tests (EmptyWorkspaceAPI, ContainerOverridesAPI, etc.) -Ask for: -- **Namespace** (`TS_API_TEST_NAMESPACE`) - Optional, for specific namespace testing -- **UDI Image** (`TS_API_TEST_UDI_IMAGE`) - Optional, custom Universal Developer Image - -### Sample/Devfile Tests -Ask for: -- **Sample List** (`TS_SAMPLE_LIST`) - Which samples to test, e.g., `Node.js Express` - -### SSH/PAT Tests (SshUrlNoOauthPatFactory, etc.) -Ask for: -- **SSH Private Key Path** or **Personal Access Token** details as needed by the test - -## Auto-Rebuild on Local Changes - -Before running tests, check for local modifications and rebuild the container if needed: - -```bash -cd tests/e2e - -# Check for uncommitted changes and rebuild if found -if [[ -n $(git status --porcelain .) ]]; then - echo "Local changes detected, rebuilding container image..." - podman build -t quay.io/eclipse/che-e2e:local -f build/dockerfiles/Dockerfile . - E2E_IMAGE="quay.io/eclipse/che-e2e:local" -else - echo "No local changes, using published image..." - E2E_IMAGE="eclipse/che-e2e:nightly" -fi - -# Run tests with the appropriate image -podman rm -f selenium-e2e 2>/dev/null; \ -podman run -it --shm-size=2g -p 5920:5920 \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ - -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ - -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ - -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ - $E2E_IMAGE -``` - -## Podman Run Commands - -### Basic Dev Spaces Test (with OAuth) - -```bash -cd tests/e2e -podman rm -f selenium-e2e 2>/dev/null; \ -podman run -it --shm-size=2g -p 5920:5920 \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ - -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ - -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ - -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ - eclipse/che-e2e:nightly -``` - -### Dev Spaces with htpasswd Authentication - -```bash -podman rm -f selenium-e2e 2>/dev/null; \ -podman run -it --shm-size=2g -p 5920:5920 \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=https://devspaces.apps.ocp.crw-qe.com/ \ - -e TS_SELENIUM_OCP_USERNAME=admin \ - -e TS_SELENIUM_OCP_PASSWORD=password \ - -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ - -e TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd \ - -e NODE_TLS_REJECT_UNAUTHORIZED=0 \ - -e USERSTORY=EmptyWorkspace \ - eclipse/che-e2e:nightly -``` - -### Dev Spaces with Local E2E Code Mounted - -Use this when testing local modifications to E2E tests: - -```bash -cd tests/e2e -podman rm -f selenium-e2e 2>/dev/null; \ -podman run -it --shm-size=2g -p 5920:5920 \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ - -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ - -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ - -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ - -v $(pwd):/tmp/e2e:Z \ - eclipse/che-e2e:nightly -``` - -### Running Specific Test Against Dev Spaces - -```bash -podman run -it --shm-size=2g -p 5920:5920 \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ - -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ - -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ - -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ - -e USERSTORY=Factory \ - eclipse/che-e2e:nightly -``` - -### Full Dev Spaces Example with All Common Options (Recommended) - -```bash -podman rm -f selenium-e2e 2>/dev/null; \ -podman run -it --shm-size=2g -p 5920:5920 \ - --network="host" \ - --name selenium-e2e \ - -e TS_PLATFORM=openshift \ - -e TS_SELENIUM_BASE_URL=https://devspaces.apps.ocp.crw-qe.com/ \ - -e TS_SELENIUM_OCP_USERNAME=admin \ - -e TS_SELENIUM_OCP_PASSWORD=password \ - -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ - -e TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd \ - -e TS_SELENIUM_LOG_LEVEL=TRACE \ - -e TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 \ - -e TS_DEBUG_MODE=true \ - -e NODE_TLS_REJECT_UNAUTHORIZED=0 \ - -e TESTING_APPLICATION_VERSION=3.23.0 \ - -e TS_DELETE_WORKSPACE_ON_FAILED_TEST=true \ - -e VIDEO_RECORDING=true \ - -e USERSTORY=EmptyWorkspace \ - -v /tmp/e2e/report:/tmp/e2e/report:Z \ - -v /tmp/e2e/video:/tmp/ffmpeg_report:Z \ - eclipse/che-e2e:nightly -``` - -### Dev Spaces Factory Test with Git Provider OAuth - -```bash -podman run -it --shm-size=2g -p 5920:5920 \ - --network="host" \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=https://devspaces.apps.cluster.example.com \ - -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ - -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ - -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ - -e TS_SELENIUM_FACTORY_GIT_REPO_URL=https://github.com/user/repo \ - -e TS_SELENIUM_FACTORY_GIT_PROVIDER=github \ - -e TS_SELENIUM_GIT_PROVIDER_OAUTH=true \ - -e USERSTORY=Factory \ - eclipse/che-e2e:nightly -``` - -### Dev Spaces on Developer Sandbox - -```bash -podman run -it --shm-size=2g -p 5920:5920 \ - --network="host" \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=https://devspaces.apps.sandbox.x8i5.p1.openshiftapps.com \ - -e TS_SELENIUM_OCP_USERNAME=$TS_SELENIUM_OCP_USERNAME \ - -e TS_SELENIUM_OCP_PASSWORD=$TS_SELENIUM_OCP_PASSWORD \ - -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ - -e TS_OCP_LOGIN_PAGE_PROVIDER_TITLE="DevSandbox" \ - -e USERSTORY=EmptyWorkspace \ - eclipse/che-e2e:nightly -``` - -## VNC Access for Debugging - -Connect to VNC at `0.0.0.0:5920` to watch tests running in the container. - -## Build Local Container Image - -To build and use a local container image: - -```bash -cd tests/e2e -podman build -t quay.io/eclipse/che-e2e:local -f build/dockerfiles/Dockerfile . - -# Then run with local image -podman run -it --shm-size=2g -p 5920:5920 \ - --name selenium-e2e \ - -e TS_SELENIUM_BASE_URL=$TS_SELENIUM_BASE_URL \ - -e TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true \ - quay.io/eclipse/che-e2e:local -``` - -## Cleanup - -Remove existing container before running again: - -```bash -podman rm -f selenium-e2e -``` - -## Report Collection - -Mount volumes to collect test reports: - -```bash --v /local/path/report:/tmp/e2e/report:Z \ --v /local/path/video:/tmp/ffmpeg_report:Z -``` - -## Key Differences from Eclipse Che - -When testing Dev Spaces vs Eclipse Che: - -- Always set `TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true` (Dev Spaces uses OpenShift OAuth) -- May need `TS_OCP_LOGIN_PAGE_PROVIDER_TITLE` for SSO provider selection -- Base URL format is typically `https://devspaces.apps.` diff --git a/tests/e2e/.claude/commands/run-e2e-test.md b/tests/e2e/.claude/commands/run-e2e-test.md new file mode 100644 index 00000000000..dd49a710ce9 --- /dev/null +++ b/tests/e2e/.claude/commands/run-e2e-test.md @@ -0,0 +1,573 @@ +# Run E2E Tests - Unified Command + +Run E2E tests against **Eclipse Che** or **Red Hat OpenShift Dev Spaces** using either a **local Chrome browser** or **Podman container**. + +## Arguments: $ARGUMENTS + +**Usage:** `/run-e2e-test [URL USERNAME PASSWORD [TESTNAME]]` + +**Examples:** + +- `/run-e2e-test` - Interactive mode (recommended) +- `/run-e2e-test https://devspaces.apps.cluster.example.com/ admin mypassword SmokeTest npm` +- `/run-e2e-test https://che.apps.cluster.example.com/ admin mypassword EmptyWorkspace podman` + +--- + +## Execution Flow + +1. **Parse arguments** - Extract parameters from `$ARGUMENTS` +2. **Prompt if missing** - Collect missing values via AskUserQuestion +3. **Auto-detect platform** - Determine Eclipse Che vs Dev Spaces from URL +4. **Detect local changes** - Check if rebuild is needed based on git status +5. **Detect test-specific parameters** - Read spec file for required env vars +6. **Generate bash commands** - Build appropriate bash commands +7. **Execute** - Run the test after user confirmation + +--- + +## ⚠️ MANDATORY RULES + +1. **Never print bash commands with `&& \` or multi-line continuations using `\`** - Commands using line continuation characters (`\`) or chained with `&& \` cannot be copy-pasted properly from the terminal. Instead, present commands as separate lines or use semicolons for simple chains. + + ❌ **Wrong (line continuations):** + + ```bash + cd /path/to/dir && \ + npm ci && \ + npm run test + ``` + + ❌ **Wrong (backslash continuations):** + + ```bash + podman run -it \ + --shm-size=2g \ + -p 5920:5920 \ + quay.io/eclipse/che-e2e:next + ``` + + ✅ **Correct (separate lines):** + + ```bash + cd /path/to/dir + npm ci + npm run test + ``` + + ✅ **Correct (single line for podman):** + + ```bash + podman run -it --shm-size=2g -p 5920:5920 quay.io/eclipse/che-e2e:next + ``` + +--- + +## Step 1: Parse Arguments + +Parse `$ARGUMENTS` to extract positional parameters: + +``` +$ARGUMENTS = "URL USERNAME PASSWORD [TESTNAME]" +``` + +**Parsing logic:** + +1. Split `$ARGUMENTS` by whitespace +2. Assign to variables: `URL`, `USERNAME`, `PASSWORD`, `TESTNAME`, `RUN_METHOD` +3. If `TESTNAME` is not provided, default to `EmptyWorkspace` + +**Example:** + +``` +Input: "https://devspaces.apps.example.com/ admin secret123 SmokeTest npm" +Result: + - URL = "https://devspaces.apps.example.com/" + - USERNAME = "admin" + - PASSWORD = "secret123" + - TESTNAME = "SmokeTest" + - RUN_METHOD = "npm" +``` + +--- + +## Step 2: Prompt for Missing Values + +If `$ARGUMENTS` is empty or incomplete, use **AskUserQuestion** to collect missing parameters. + +### Question 1 - Run Method (header: "Method") + +- "How do you want to run the test?" +- Options: + - Option 1: "npm run in local browser (Recommended)" - "Uses local Chrome and Node.js - faster, see browser in real-time" + - Option 2: "Podman container" - "Isolated environment with VNC support at localhost:5920" + +### Question 2 - Execution Mode (header: "Build") + +- "How should local changes be handled?" +- Options: + - Option 1: "Build and run (Recommended)" - "Compare to origin/main, rebuild if any changes exist" + - Option 2: "Just run" - "Skip build, assume code is already compiled" + +### Question 3 - Test Name (header: "Test") + +- "Which test do you want to run?" +- Options: + - Option 1: "EmptyWorkspace (Recommended)" - "Basic workspace creation test" + - Option 2: "SmokeTest" - "Quick validation of core functionality" + - Option 3: "Factory" - "Factory URL workspace creation with git operations" + - Option 4: "EmptyWorkspaceAPI" - "API-only test (no browser needed)" + +### For URL - Ask in plain text: + +> "What is the dashboard URL? (e.g., https://devspaces.apps.cluster.example.com/ or https://che.apps.cluster.example.com/)" + +### For Username and Password - Ask in plain text: + +> "Please provide your credentials: +> +> - **Username**: (e.g., admin, user) +> - **Password**: your password" + +Wait for the user's response before proceeding. + +--- + +## Step 3: Auto-detect Testing Product from URL + +Analyze the URL to determine which product is being tested and set appropriate defaults: + +| URL Pattern | Product | Auto-configured Settings | +| ---------------------- | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Contains `devspaces` | **Red Hat OpenShift Dev Spaces** | `TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true`, `TS_OCP_LOGIN_PAGE_PROVIDER_TITLE=htpasswd` `TS_PLATFORM=openshift` | +| Contains `eclipse-che` | **Eclipse Che** | May need OAuth config based on deployment. I host contains `crw-qe.com` - it is `TS_PLATFORM=openshift`. Otherwise ask user for platform: openshift or kubernetes | + +**Detection logic:** + +```bash +if [[ "$URL" == *"devspaces"* ]]; then + PRODUCT="devspaces" + TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true + TS_OCP_LOGIN_PAGE_PROVIDER_TITLE="htpasswd" +elif [[ "$URL" == *"eclipse-che"* ]]; then + PRODUCT="che" +fi +``` + +--- + +## Step 4: Detect Local Changes + +Check the git status to determine if code needs to be rebuilt before running tests. + +**Important:** Ignore changes to documentation and Claude configuration files: + +- `CLAUDE.md` +- `.claude/**/*` +- `*.md` files (documentation) + +### For Local Browser Method: + +**Smart rebuild based on all changes vs origin/main** - rebuild when there are any test code modifications compared to origin/main. + +**Logic:** + +1. Compare working tree to `origin/main` to detect all changes (committed, staged, and unstaged) +2. Rebuild if any test code changes exist compared to `origin/main` (excluding docs/config files) + +```bash +NEEDS_REBUILD=false + +# Get current branch name for informational purposes +CURRENT_BRANCH=$(git branch --show-current) +echo "Current branch: $CURRENT_BRANCH" + +# Check for any changes compared to origin/main (committed, staged, and unstaged) +# Excludes docs and Claude config files +CODE_CHANGES=$(git diff --name-only origin/main -- . 2>/dev/null | grep -v -E '(CLAUDE\.md|\.claude/|README\.md|\.md$)') + +if [[ -n "$CODE_CHANGES" ]]; then + echo "Code changes detected compared to origin/main:" + echo "$CODE_CHANGES" + NEEDS_REBUILD=true +else + echo "No test code changes compared to origin/main - no rebuild needed" +fi + +echo "Rebuild needed: $NEEDS_REBUILD" +``` + +### For Podman Container Method: + +**Smart mounting based on all changes vs origin/main** - mount full directory when there are any test code modifications compared to origin/main. + +**Logic:** + +1. Compare working tree to `origin/main` to detect all changes (committed, staged, and unstaged) +2. Mount full directory if any test code changes exist compared to `origin/main` (excluding docs/config files) + +```bash +E2E_IMAGE="quay.io/eclipse/che-e2e:next" +MOUNT_FULL_CODE=false + +# Get current branch name for informational purposes +CURRENT_BRANCH=$(git branch --show-current) +echo "Current branch: $CURRENT_BRANCH" + +# Check for any changes compared to origin/main (committed, staged, and unstaged) +# Excludes docs and Claude config files +CODE_CHANGES=$(git diff --name-only origin/main -- . 2>/dev/null | grep -v -E '(CLAUDE\.md|\.claude/|README\.md|\.md$)') + +if [[ -n "$CODE_CHANGES" ]]; then + echo "Code changes detected compared to origin/main:" + echo "$CODE_CHANGES" + MOUNT_FULL_CODE=true + PODMAN_MOUNT="-v $(pwd):/tmp/e2e:Z" +else + echo "No test code changes compared to origin/main - using published image code" + PODMAN_MOUNT="-v $(pwd)/report:/tmp/e2e/report:Z" +fi + +echo "Mount strategy: $PODMAN_MOUNT" +``` + +--- + +## Step 5: Detect Test-Specific Parameters + +After getting the test name, read the test spec file to identify additional required environment variables. + +### Find and read the spec file: + +```bash +# Find the test file +SPEC_FILE=$(find specs -name "${USERSTORY}.spec.ts" 2>/dev/null | head -1) + +if [[ -n "$SPEC_FILE" ]]; then + echo "Found test file: $SPEC_FILE" + # Read the file to identify required environment variables + cat "$SPEC_FILE" +fi +``` + +### Platform-Specific Configurations + +#### OpenShift + +```bash +export TS_PLATFORM=openshift +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true +export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE="htpasswd" +``` + +#### Kubernetes + +```bash +export TS_PLATFORM=kubernetes +export TS_SELENIUM_K8S_USERNAME=che@eclipse.org +export TS_SELENIUM_K8S_PASSWORD=admin +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=false +``` + +### Test-specific parameters by category: + +#### Factory URL Tests (Factory, RefusedOAuthFactory, NoSetupRepoFactory, etc.) + +These tests navigate directly to a factory URL to create a workspace. +**Ask for these additional parameters:** + +- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository to clone +- **Git Provider** (`TS_SELENIUM_FACTORY_GIT_PROVIDER`) - `github`, `gitlab`, `bitbucket`, `azure-devops` +- **OAuth Enabled** (`TS_SELENIUM_GIT_PROVIDER_OAUTH`) - `true` or `false` + +#### Git Repo Import Form Tests (FactoryWithGitRepoOptions, CreateWorkspaceWithExistingNameFromGitUrl, etc.) + +These tests use the Dashboard's "Create Workspace" form. +**Ask for these additional parameters:** + +- **Git Repository URL** (`TS_SELENIUM_FACTORY_GIT_REPO_URL`) - Repository URL +- **Branch Name** (`TS_SELENIUM_FACTORY_GIT_REPO_BRANCH`) - Optional (default: `main`) +- **Project Name** (`TS_SELENIUM_PROJECT_NAME`) - Optional + +#### API Tests (EmptyWorkspaceAPI, ContainerOverridesAPI, etc.) + +**Ask for these additional parameters:** + +- **Namespace** (`TS_API_TEST_NAMESPACE`) - Optional +- **UDI Image** (`TS_API_TEST_UDI_IMAGE`) - Optional + +#### Sample/Devfile Tests + +**Ask for these additional parameters:** + +- **Sample List** (`TS_SAMPLE_LIST`) - e.g., `Node.js Express` + +#### SSH/PAT Tests (SshUrlNoOauthPatFactory, etc.) + +**Ask for these additional parameters:** + +- **SSH Private Key Path** or **Personal Access Token** details + +--- + +## Step 6: Generate Bash Commands + +Based on all collected parameters, generate the appropriate bash commands. + +### Option A: Local Browser Commands + +#### Browser/ChromeDriver Compatibility Check + +Before running tests, verify ChromeDriver compatibility with local Chrome browser: + +```bash +# Get local Chrome version +CHROME_VERSION=$(google-chrome --version 2>/dev/null | grep -oP '\d+' | head -1) +echo "Local Chrome major version: $CHROME_VERSION" + +# Get ChromeDriver version from package.json +CHROMEDRIVER_VERSION=$(npm list chromedriver --depth=0 2>/dev/null | grep -oP 'chromedriver@\K[\d.]+') +echo "ChromeDriver version in package.json: $CHROMEDRIVER_VERSION" + +# If versions don't match, suggest installing compatible driver +if [[ "${CHROMEDRIVER_VERSION%%.*}" != "$CHROME_VERSION" ]]; then + echo "WARNING: ChromeDriver version mismatch!" + echo "Install compatible version: npm install chromedriver@$CHROME_VERSION" +fi +``` + +**If ChromeDriver is incompatible**, install a matching version: + +```bash +npm install chromedriver@ +``` + +#### Full Test Run (Build and Run) + +```bash +cd tests/e2e + +# Use correct Node.js version +nvm use v22.10.0 + +# Get current branch name for informational purposes +CURRENT_BRANCH=$(git branch --show-current) +echo "Current branch: $CURRENT_BRANCH" + +# Check for any changes compared to origin/main (committed, staged, and unstaged) +# Excludes docs and Claude config files +CODE_CHANGES=$(git diff --name-only origin/main -- . 2>/dev/null | grep -v -E '(CLAUDE\.md|\.claude/|README\.md|\.md$)') + +if [[ -n "$CODE_CHANGES" ]]; then + echo "Code changes detected compared to origin/main:" + echo "$CODE_CHANGES" + NEEDS_REBUILD=true +else + echo "No test code changes compared to origin/main - skipping rebuild" + NEEDS_REBUILD=false +fi + +# Check if package.json was modified compared to origin/main +PACKAGE_JSON_CHANGED=$(git diff --name-only origin/main -- package.json 2>/dev/null) + +# Rebuild if changes detected compared to origin/main +if [[ "$NEEDS_REBUILD" == "true" ]]; then + echo "Rebuilding TypeScript..." + rm -rf node_modules dist + + # Use npm install if package.json changed, otherwise npm ci + if [[ -n "$PACKAGE_JSON_CHANGED" ]]; then + echo "package.json modified - using npm install to update package-lock.json" + npm install + else + npm ci + fi + + npm run lint + npm run prettier + npm run tsc +fi + +# Set environment variables +export TS_SELENIUM_BASE_URL="" +export TS_SELENIUM_OCP_USERNAME="" +export TS_SELENIUM_OCP_PASSWORD="" +export USERSTORY="" +export TS_SELENIUM_VALUE_OPENSHIFT_OAUTH=true +export NODE_TLS_REJECT_UNAUTHORIZED=0 + +# Run the test +npm run test +``` + +#### API-Only Tests (No Browser) + +```bash +export USERSTORY=EmptyWorkspaceAPI +npm run driver-less-test +``` + +### Option B: Podman Container Commands + +**Important:** Use `--env-host` to pass all exported environment variables from the host to the container. + +**Smart mounting logic based on changes vs origin/main:** + +- **Changes compared to origin/main**: Mount full directory `-v $(pwd):/tmp/e2e:Z` to test local code +- **No changes compared to origin/main**: Mount only report directory `-v $(pwd)/report:/tmp/e2e/report:Z` + +#### With Test Code Changes vs origin/main (mount full directory): + +Use this when there are test code changes compared to `origin/main` (works for feature branches or local main with unpushed changes). + +```bash +cd tests/e2e + +# Set environment variables +export NODE_TLS_REJECT_UNAUTHORIZED=0 +export TS_SELENIUM_BASE_URL= +export TS_SELENIUM_OCP_USERNAME= +export TS_SELENIUM_OCP_PASSWORD= +export USERSTORY= + +# Run with full local code mounted (testing changes vs origin/main) +podman rm -f selenium-e2e 2>/dev/null +podman run -it --shm-size=2g -p 5920:5920 --env-host -v $(pwd):/tmp/e2e:Z quay.io/eclipse/che-e2e:next +``` + +#### No Test Code Changes vs origin/main (mount only report directory): + +```bash +cd tests/e2e + +# Set environment variables +export NODE_TLS_REJECT_UNAUTHORIZED=0 +export TS_SELENIUM_BASE_URL= +export TS_SELENIUM_OCP_USERNAME= +export TS_SELENIUM_OCP_PASSWORD= +export USERSTORY= + +# Run with only report directory mounted (no changes vs origin/main, uses published image code) +podman rm -f selenium-e2e 2>/dev/null +podman run -it --shm-size=2g -p 5920:5920 --env-host -v $(pwd)/report:/tmp/e2e/report:Z quay.io/eclipse/che-e2e:next +``` + +--- + +## Step 7: Execute After User Confirmation + +Before executing, present the generated command(s) to the user and ask for confirmation. + +### Confirmation prompt: + +> "Here is the command I will run: +> +> ```bash +> +> ``` +> +> **Summary:** +> +> - **Platform:** [OpenShift/Kubernetes] +> - **Product:** [Eclipse Che/Dev Spaces] +> - **Test:** [TESTNAME] +> - **Method:** [Local browser/Podman container] +> - **URL:** [URL] +> +> Shall I proceed?" + +### After confirmation: + +1. Execute the bash command(s) +2. Monitor the output +3. Report success or failure +4. If using Podman, remind user about VNC access at `localhost:5920` + +--- + +## Debugging Options + +### Verbose Logging + +```bash +export TS_SELENIUM_LOG_LEVEL=TRACE +export TS_SELENIUM_PRINT_TIMEOUT_VARIABLES=true +export TS_DEBUG_MODE=true +``` + +### Headless Mode (CI) + +```bash +export TS_SELENIUM_HEADLESS=true +``` + +### Video Recording + +```bash +export VIDEO_RECORDING=true +``` + +### Keep Workspace on Failure + +```bash +export TS_DELETE_WORKSPACE_ON_FAILED_TEST=false +``` + +--- + +## VNC Access for Visual Debugging (Podman only) + +Connect to VNC at `localhost:5920` to watch tests running in the container. + +**VNC clients:** + +- **TigerVNC** (recommended): `sudo dnf install tigervnc` then `vncviewer localhost:5920` +- **Remmina**: `sudo dnf install remmina remmina-plugins-vnc` (GUI-based) +- **Vinagre**: `sudo dnf install vinagre` then `vinagre localhost:5920` + +--- + +## View Test Reports + +After test execution: + +```bash +npm run open-allure-dasboard +``` + +--- + +## Troubleshooting + +### Certificate Errors + +```bash +export NODE_TLS_REJECT_UNAUTHORIZED=0 +``` + +### Slow Workspace Start + +```bash +export TS_SELENIUM_START_WORKSPACE_TIMEOUT=600000 +export TS_SELENIUM_DEFAULT_ATTEMPTS=3 +``` + +### OAuth Login Issues + +Verify the login provider title matches exactly what appears on the login page: + +```bash +export TS_OCP_LOGIN_PAGE_PROVIDER_TITLE="htpasswd" +``` + +### Container Cleanup + +```bash +podman rm -f selenium-e2e +``` + +--- + +## Debugging TypeScript Tests in VS Code + +For debugging E2E tests with breakpoints, see: https://code.visualstudio.com/docs/typescript/typescript-debugging diff --git a/tests/e2e/.claude/settings.local.json b/tests/e2e/.claude/settings.local.json new file mode 100644 index 00000000000..ed660e86739 --- /dev/null +++ b/tests/e2e/.claude/settings.local.json @@ -0,0 +1,13 @@ +{ + "permissions": { + "allow": [ + "Bash(source ~/.nvm/nvm.sh)", + "Bash(nvm use:*)", + "Bash(npm run prettier:*)", + "Bash(node:*)", + "Bash(npm run lint:*)", + "Bash(npm run tsc:*)", + "Bash(export:*)" + ] + } +} diff --git a/tests/e2e/.claude/skills/e2e-test-development/SKILL.md b/tests/e2e/.claude/skills/e2e-test-development/SKILL.md index f8bb36529d5..f36a85a0ae4 100644 --- a/tests/e2e/.claude/skills/e2e-test-development/SKILL.md +++ b/tests/e2e/.claude/skills/e2e-test-development/SKILL.md @@ -5,6 +5,7 @@ You are a Software Quality Engineer, who is an expert developer for Eclipse Che ## Project Overview This is the E2E test suite for Eclipse Che / Red Hat OpenShift Dev Spaces. It uses: + - **Selenium WebDriver** with Chrome browser - **Mocha** (TDD style - `suite()`, `test()`, `suiteSetup()`, `suiteTeardown()`) - **TypeScript** with strict type checking @@ -14,17 +15,17 @@ This is the E2E test suite for Eclipse Che / Red Hat OpenShift Dev Spaces. It us ## Directory Structure -| Directory | Purpose | -|-----------|---------| -| `specs/` | Test specifications organized by category (api/, factory/, dashboard-samples/, miscellaneous/) | -| `pageobjects/` | Page Object classes for UI elements (dashboard/, ide/, login/, openshift/, git-providers/, webterminal/) | -| `utils/` | Utilities (DriverHelper, BrowserTabsUtil, Logger, API handlers, KubernetesCommandLineToolsExecutor) | -| `tests-library/` | Reusable test helpers (WorkspaceHandlingTests, LoginTests, ProjectAndFileTests) | -| `constants/` | Environment variable mappings (BASE_TEST_CONSTANTS, TIMEOUT_CONSTANTS, FACTORY_TEST_CONSTANTS, etc.) | -| `configs/` | Mocha config, Inversify container (inversify.config.ts), shell scripts | -| `suites/` | Test suite configurations for different environments | -| `driver/` | Chrome driver configuration | -| `build/dockerfiles/` | Docker image for running tests | +| Directory | Purpose | +| -------------------- | -------------------------------------------------------------------------------------------------------- | +| `specs/` | Test specifications organized by category (api/, factory/, dashboard-samples/, miscellaneous/) | +| `pageobjects/` | Page Object classes for UI elements (dashboard/, ide/, login/, openshift/, git-providers/, webterminal/) | +| `utils/` | Utilities (DriverHelper, BrowserTabsUtil, Logger, API handlers, KubernetesCommandLineToolsExecutor) | +| `tests-library/` | Reusable test helpers (WorkspaceHandlingTests, LoginTests, ProjectAndFileTests) | +| `constants/` | Environment variable mappings (BASE_TEST_CONSTANTS, TIMEOUT_CONSTANTS, FACTORY_TEST_CONSTANTS, etc.) | +| `configs/` | Mocha config, Inversify container (inversify.config.ts), shell scripts | +| `suites/` | Test suite configurations for different environments | +| `driver/` | Chrome driver configuration | +| `build/dockerfiles/` | Docker image for running tests | ## Essential Commands @@ -58,7 +59,9 @@ npm run open-allure-dasboard ## CODE STYLE REQUIREMENTS (CRITICAL) ### File Header (Required for ALL .ts files) + Every TypeScript file MUST start with this exact header: + ```typescript /** ******************************************************************* * copyright (c) 2023 Red Hat, Inc. @@ -74,8 +77,8 @@ Every TypeScript file MUST start with this exact header: ### Page Object and Utility Classes 1. **Class Declaration with Dependency Injection** - - Use `@injectable()` decorator on ALL page objects and utilities - - Use constructor injection with `@inject()` decorators + - Use `@injectable()` decorator on ALL page objects and utilities + - Use constructor injection with `@inject()` decorators ```typescript import { inject, injectable } from 'inversify'; @@ -84,16 +87,14 @@ import { CLASSES } from '../../configs/inversify.types'; @injectable() export class MyPageObject { - constructor( - @inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper - ) {} + constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) {} } ``` 2. **Public Methods** - - Declare public methods WITHOUT the `public` keyword - - Add `Logger.debug()` at the START of every public method - - Always specify explicit return types + - Declare public methods WITHOUT the `public` keyword + - Add `Logger.debug()` at the START of every public method + - Always specify explicit return types ```typescript async clickButton(timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TIMEOUT): Promise { @@ -103,9 +104,9 @@ async clickButton(timeout: number = TIMEOUT_CONSTANTS.TS_CLICK_DASHBOARD_ITEM_TI ``` 3. **Locators** - - Static locators: `private static readonly` fields of type `By` - - Dynamic locators: `private` methods that return `By` - - NEVER declare locators as constants inside methods + - Static locators: `private static readonly` fields of type `By` + - Dynamic locators: `private` methods that return `By` + - NEVER declare locators as constants inside methods ```typescript // Static locators (correct) @@ -124,7 +125,9 @@ async wrongMethod(): Promise { ``` ### Member Ordering (Enforced by ESLint) + Classes must follow this order: + 1. Static fields 2. Public fields 3. Instance fields @@ -142,79 +145,82 @@ Classes must follow this order: ### Test File Conventions 1. **Naming** - - UI tests: `*.spec.ts` (e.g., `Factory.spec.ts`) - - API-only tests: `*API.spec.ts` (e.g., `EmptyWorkspaceAPI.spec.ts`) + + - UI tests: `*.spec.ts` (e.g., `Factory.spec.ts`) + - API-only tests: `*API.spec.ts` (e.g., `EmptyWorkspaceAPI.spec.ts`) 2. **Mocha TDD Style (Required)** - - Use `suite()`, `test()`, `suiteSetup()`, `suiteTeardown()` - - NEVER use arrow functions in test declarations (Mocha context issue) + - Use `suite()`, `test()`, `suiteSetup()`, `suiteTeardown()` + - NEVER use arrow functions in test declarations (Mocha context issue) ```typescript suite('My Test Suite', function (): void { - // Inject dependencies inside suite() to avoid unnecessary execution - const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); - const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); + // Inject dependencies inside suite() to avoid unnecessary execution + const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); + const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); - suiteSetup('Login to application', async function (): Promise { - await loginTests.loginIntoChe(); - }); + suiteSetup('Login to application', async function (): Promise { + await loginTests.loginIntoChe(); + }); - test('Verify dashboard is visible', async function (): Promise { - await dashboard.waitPage(); - }); + test('Verify dashboard is visible', async function (): Promise { + await dashboard.waitPage(); + }); - suiteTeardown('Cleanup', async function (): Promise { - // cleanup code - }); + suiteTeardown('Cleanup', async function (): Promise { + // cleanup code + }); }); ``` 3. **Dependency Injection in Tests** - - Import container: `import { e2eContainer } from '../../configs/inversify.config';` - - Import types: `import { CLASSES, TYPES } from '../../configs/inversify.types';` - - Get instances inside suite() function + - Import container: `import { e2eContainer } from '../../configs/inversify.config';` + - Import types: `import { CLASSES, TYPES } from '../../configs/inversify.types';` + - Get instances inside suite() function ```typescript import { e2eContainer } from '../../configs/inversify.config'; import { CLASSES, TYPES } from '../../configs/inversify.types'; suite('Test Suite', function (): void { - const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); - const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); - // ... test implementation + const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); + const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); + // ... test implementation }); ``` ### TypeScript Requirements 1. **Explicit Type Annotations Required** - - All parameters must have type annotations - - All property declarations must have type annotations - - All variable declarations must have type annotations - - All functions must have explicit return types + - All parameters must have type annotations + - All property declarations must have type annotations + - All variable declarations must have type annotations + - All functions must have explicit return types ```typescript // Correct async function doSomething(param: string, timeout: number): Promise { - const result: string = await someOperation(); + const result: string = await someOperation(); } // Wrong - missing types async function doSomething(param, timeout) { - const result = await someOperation(); + const result = await someOperation(); } ``` 2. **Naming Conventions** - - Variables: camelCase or UPPER_CASE - - No leading/trailing underscores + + - Variables: camelCase or UPPER_CASE + - No leading/trailing underscores 3. **String Quotes** - - Use single quotes for strings + + - Use single quotes for strings 4. **Comments** - - Comments must start with lowercase (capitalized-comments: never) - - Mark workarounds with `// todo` and issue number: `// todo commented due to issue crw-1010` + - Comments must start with lowercase (capitalized-comments: never) + - Mark workarounds with `// todo` and issue number: `// todo commented due to issue crw-1010` ### Prettier and ESLint @@ -226,17 +232,17 @@ async function doSomething(param, timeout) { Core variables (defined in `constants/` directory): -| Variable | Description | -|----------|-------------| -| `TS_SELENIUM_BASE_URL` | Che/DevSpaces dashboard URL | -| `TS_SELENIUM_OCP_USERNAME` | OpenShift username | -| `TS_SELENIUM_OCP_PASSWORD` | OpenShift password | -| `USERSTORY` | Specific test file to run (without .spec.ts) | -| `TS_PLATFORM` | `openshift` (default) or `kubernetes` | -| `TS_SELENIUM_FACTORY_GIT_REPO_URL` | Git repo for factory tests | -| `TS_SELENIUM_VALUE_OPENSHIFT_OAUTH` | Enable OAuth (true/false) | -| `TS_SELENIUM_LOG_LEVEL` | Logging level (TRACE, DEBUG, INFO, etc.) | -| `DELETE_WORKSPACE_ON_SUCCESSFUL_TEST` | Delete workspace on success | +| Variable | Description | +| ------------------------------------- | -------------------------------------------- | +| `TS_SELENIUM_BASE_URL` | Che/DevSpaces dashboard URL | +| `TS_SELENIUM_OCP_USERNAME` | OpenShift username | +| `TS_SELENIUM_OCP_PASSWORD` | OpenShift password | +| `USERSTORY` | Specific test file to run (without .spec.ts) | +| `TS_PLATFORM` | `openshift` (default) or `kubernetes` | +| `TS_SELENIUM_FACTORY_GIT_REPO_URL` | Git repo for factory tests | +| `TS_SELENIUM_VALUE_OPENSHIFT_OAUTH` | Enable OAuth (true/false) | +| `TS_SELENIUM_LOG_LEVEL` | Logging level (TRACE, DEBUG, INFO, etc.) | +| `DELETE_WORKSPACE_ON_SUCCESSFUL_TEST` | Delete workspace on success | ## Adding New Page Objects @@ -249,22 +255,20 @@ Core variables (defined in `constants/` directory): // 1. Create pageobjects/dashboard/NewPage.ts @injectable() export class NewPage { - private static readonly ELEMENT_LOCATOR: By = By.id('element'); + private static readonly ELEMENT_LOCATOR: By = By.id('element'); - constructor( - @inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper - ) {} + constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) {} - async waitForElement(): Promise { - Logger.debug(); - await this.driverHelper.waitVisibility(NewPage.ELEMENT_LOCATOR); - } + async waitForElement(): Promise { + Logger.debug(); + await this.driverHelper.waitVisibility(NewPage.ELEMENT_LOCATOR); + } } // 2. Add to configs/inversify.types.ts const CLASSES: any = { - // ... existing classes - NewPage: 'NewPage' + // ... existing classes + NewPage: 'NewPage' }; // 3. Add to configs/inversify.config.ts @@ -282,6 +286,7 @@ e2eContainer.bind(CLASSES.NewPage).to(NewPage); ## Common Utilities ### DriverHelper (utils/DriverHelper.ts) + - `waitVisibility(locator, timeout)` - Wait for element to be visible - `waitAndClick(locator, timeout)` - Wait and click element - `waitAndGetText(locator, timeout)` - Wait and get text @@ -290,12 +295,14 @@ e2eContainer.bind(CLASSES.NewPage).to(NewPage); - `wait(ms)` - Wait for specified milliseconds ### BrowserTabsUtil (utils/BrowserTabsUtil.ts) + - `navigateTo(url)` - Navigate to URL - `getCurrentUrl()` - Get current URL - `maximize()` - Maximize browser window - `closeAllTabsExceptCurrent()` - Close extra tabs ### Logger (utils/Logger.ts) + - `Logger.debug()` - Log method name (use at start of public methods) - `Logger.info(message)` - Log info message - `Logger.error(message)` - Log error message @@ -303,11 +310,14 @@ e2eContainer.bind(CLASSES.NewPage).to(NewPage); ## GitHub Actions Maintenance ### PR Check Workflow (.github/workflows/pr-check.yml) + Triggers on: -- Pull requests to main or 7.**.x branches + +- Pull requests to main or 7.\*\*.x branches - Changes in `tests/e2e/**` or the workflow file Steps performed: + 1. Prettier check - Fails if formatting issues found 2. TypeScript compilation - `npm run tsc` 3. ESLint check - `npm run lint` @@ -317,6 +327,7 @@ Steps performed: 7. Run Empty Workspace UI test When modifying tests: + - Ensure `npm run prettier` passes locally - Ensure `npm run tsc` compiles without errors - Ensure `npm run lint` passes @@ -325,52 +336,55 @@ When modifying tests: ## Test Patterns ### Workspace Lifecycle Pattern + ```typescript suite('Workspace Test', function (): void { - const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); - const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); - const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); + const workspaceHandlingTests: WorkspaceHandlingTests = e2eContainer.get(CLASSES.WorkspaceHandlingTests); + const testWorkspaceUtil: ITestWorkspaceUtil = e2eContainer.get(TYPES.WorkspaceUtil); + const loginTests: LoginTests = e2eContainer.get(CLASSES.LoginTests); - suiteSetup('Login', async function (): Promise { - await loginTests.loginIntoChe(); - }); + suiteSetup('Login', async function (): Promise { + await loginTests.loginIntoChe(); + }); - test('Create workspace', async function (): Promise { - await workspaceHandlingTests.createAndStartWorkspace(); - }); + test('Create workspace', async function (): Promise { + await workspaceHandlingTests.createAndStartWorkspace(); + }); - test('Obtain workspace name', async function (): Promise { - await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); - }); + test('Obtain workspace name', async function (): Promise { + await workspaceHandlingTests.obtainWorkspaceNameFromStartingPage(); + }); - test('Register running workspace', function (): void { - registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName()); - }); + test('Register running workspace', function (): void { + registerRunningWorkspace(WorkspaceHandlingTests.getWorkspaceName()); + }); - suiteTeardown('Stop and delete workspace', async function (): Promise { - await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); - }); + suiteTeardown('Stop and delete workspace', async function (): Promise { + await testWorkspaceUtil.stopAndDeleteWorkspaceByName(WorkspaceHandlingTests.getWorkspaceName()); + }); }); ``` ### API Test Pattern (No Browser) + ```typescript suite('API Test', function (): void { - const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = - e2eContainer.get(CLASSES.KubernetesCommandLineToolsExecutor); - - suiteSetup('Setup', async function (): Promise { - kubernetesCommandLineToolsExecutor.loginToOcp(); - }); - - test('Execute API operation', function (): void { - const output: ShellString = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(yaml); - expect(output.stdout).contains('condition met'); - }); - - suiteTeardown('Cleanup', function (): void { - kubernetesCommandLineToolsExecutor.deleteDevWorkspace(); - }); + const kubernetesCommandLineToolsExecutor: KubernetesCommandLineToolsExecutor = e2eContainer.get( + CLASSES.KubernetesCommandLineToolsExecutor + ); + + suiteSetup('Setup', async function (): Promise { + kubernetesCommandLineToolsExecutor.loginToOcp(); + }); + + test('Execute API operation', function (): void { + const output: ShellString = kubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace(yaml); + expect(output.stdout).contains('condition met'); + }); + + suiteTeardown('Cleanup', function (): void { + kubernetesCommandLineToolsExecutor.deleteDevWorkspace(); + }); }); ``` @@ -399,10 +413,11 @@ suite('API Test', function (): void { When helping with E2E test development and maintenance: 1. **Keep command files up to date** - When test infrastructure changes (new environment variables, test patterns, or execution methods), update the related command files in `.claude/commands/`: - - `run-che-e2e-test-locally.md` - - `run-che-e2e-test-using-podman.md` - - `run-devspaces-e2e-test-locally.md` - - `run-devspaces-e2e-test-using-podman.md` + + - `run-che-e2e-test-locally.md` + - `run-che-e2e-test-using-podman.md` + - `run-devspaces-e2e-test-locally.md` + - `run-devspaces-e2e-test-using-podman.md` 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. @@ -417,9 +432,11 @@ When helping with E2E test development and maintenance: For running E2E tests, use these companion commands: ### Eclipse Che + - **`/run-che-e2e-test-using-podman`** - Run E2E tests against Eclipse Che using the che-e2e container with Podman (isolated environment with VNC support) - **`/run-che-e2e-test-locally`** - Run E2E tests against Eclipse Che using a local Chrome browser (for development and debugging) ### Red Hat OpenShift Dev Spaces + - **`/run-devspaces-e2e-test-using-podman`** - Run E2E tests against Dev Spaces using the che-e2e container with Podman (includes OAuth configuration) - **`/run-devspaces-e2e-test-locally`** - Run E2E tests against Dev Spaces using a local Chrome browser (includes SSO/OAuth setup) diff --git a/tests/e2e/CLAUDE.md b/tests/e2e/CLAUDE.md index 0501fc3e0d9..a69eeda8e46 100644 --- a/tests/e2e/CLAUDE.md +++ b/tests/e2e/CLAUDE.md @@ -3,13 +3,16 @@ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. **Available commands:** + - `/e2e-test-development` - Comprehensive E2E test development guidance (code style, patterns, architecture) **Eclipse Che:** + - `/run-che-e2e-test-using-podman` - Run E2E tests using che-e2e container with Podman - `/run-che-e2e-test-locally` - Run E2E tests using local Chrome browser **Red Hat OpenShift Dev Spaces:** + - `/run-devspaces-e2e-test-using-podman` - Run E2E tests against Dev Spaces using Podman container - `/run-devspaces-e2e-test-locally` - Run E2E tests against Dev Spaces using local browser @@ -43,6 +46,7 @@ export USERSTORY=TestName && npm run test # Run single test **Always read `CODE_STYLE.md` before modifying code.** ### Required File Header + ```typescript /** ******************************************************************* * copyright (c) 2023 Red Hat, Inc. @@ -56,44 +60,47 @@ export USERSTORY=TestName && npm run test # Run single test ``` ### Page Object Pattern + ```typescript @injectable() export class MyPage { - private static readonly BUTTON: By = By.xpath('//button'); + private static readonly BUTTON: By = By.xpath('//button'); - constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) {} + constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) {} - async clickButton(): Promise { - Logger.debug(); - await this.driverHelper.waitAndClick(MyPage.BUTTON); - } + async clickButton(): Promise { + Logger.debug(); + await this.driverHelper.waitAndClick(MyPage.BUTTON); + } - private getDynamicLocator(name: string): By { - return By.xpath(`//div[text()="${name}"]`); - } + private getDynamicLocator(name: string): By { + return By.xpath(`//div[text()="${name}"]`); + } } ``` ### Test Structure (TDD Style - No Arrow Functions) + ```typescript suite('Suite Name', function (): void { - const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); + const dashboard: Dashboard = e2eContainer.get(CLASSES.Dashboard); - suiteSetup('Setup', async function (): Promise { - // setup code - }); + suiteSetup('Setup', async function (): Promise { + // setup code + }); - test('Test case', async function (): Promise { - // test code - }); + test('Test case', async function (): Promise { + // test code + }); - suiteTeardown('Cleanup', async function (): Promise { - // cleanup code - }); + suiteTeardown('Cleanup', async function (): Promise { + // cleanup code + }); }); ``` ### Key Rules + - `@injectable()` on all page objects and utilities - `Logger.debug()` at start of every public method - Static locators: `private static readonly NAME: By` @@ -105,29 +112,32 @@ suite('Suite Name', function (): void { ## Directory Structure -| Directory | Purpose | -|-----------|---------| -| `specs/` | Test files (api/, factory/, miscellaneous/) | -| `pageobjects/` | Page Object classes | -| `utils/` | DriverHelper, Logger, API handlers | +| Directory | Purpose | +| ---------------- | ----------------------------------------------------- | +| `specs/` | Test files (api/, factory/, miscellaneous/) | +| `pageobjects/` | Page Object classes | +| `utils/` | DriverHelper, Logger, API handlers | | `tests-library/` | Reusable helpers (LoginTests, WorkspaceHandlingTests) | -| `constants/` | Environment variables and timeouts | -| `configs/` | Inversify DI, Mocha config | +| `constants/` | Environment variables and timeouts | +| `configs/` | Inversify DI, Mocha config | ## Adding New Components ### New Page Object + 1. Create in `pageobjects//NewPage.ts` 2. Add to `inversify.types.ts`: `NewPage: 'NewPage'` 3. Add to `inversify.config.ts`: `e2eContainer.bind(CLASSES.NewPage).to(NewPage)` ### New Test + 1. Create `specs//TestName.spec.ts` 2. Run: `export USERSTORY=TestName && npm run test` ## GitHub Actions PR checks run on changes to `tests/e2e/**`: + 1. Prettier formatting check 2. TypeScript compilation 3. ESLint linting @@ -137,10 +147,10 @@ PR checks run on changes to `tests/e2e/**`: ## Environment Variables -| Variable | Description | -|----------|-------------| -| `TS_SELENIUM_BASE_URL` | Che dashboard URL | -| `TS_SELENIUM_OCP_USERNAME` | OpenShift username | -| `TS_SELENIUM_OCP_PASSWORD` | OpenShift password | -| `USERSTORY` | Test file to run (without .spec.ts) | -| `TS_PLATFORM` | `openshift` or `kubernetes` | +| Variable | Description | +| -------------------------- | ----------------------------------- | +| `TS_SELENIUM_BASE_URL` | Che dashboard URL | +| `TS_SELENIUM_OCP_USERNAME` | OpenShift username | +| `TS_SELENIUM_OCP_PASSWORD` | OpenShift password | +| `USERSTORY` | Test file to run (without .spec.ts) | +| `TS_PLATFORM` | `openshift` or `kubernetes` | diff --git a/tests/e2e/README.md b/tests/e2e/README.md index b1936c4302c..6b6c78f0a9c 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -55,7 +55,7 @@ Note: If there is any modifications in package.json, manually execute the `npm i ## Debug docker launch -The `'eclipse/che-e2e'` docker image has VNC server installed inside. For connecting use `'0.0.0.0:5920'` address. +The `'quay.io/eclipse/che-e2e'` docker image has VNC server installed inside. For connecting use `'0.0.0.0:5920'` address. ## The "Happy Path" scenario launching From f58812639e335c01e1ad8344a7959174170517bd Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Sun, 1 Feb 2026 16:17:41 +0200 Subject: [PATCH 7/8] Improve e2e-test-developer/SKILL.md content Signed-off-by: Dmytro Nochevnov --- .../SKILL.md | 57 +++++++++++-------- tests/e2e/CLAUDE.md | 14 ++--- 2 files changed, 38 insertions(+), 33 deletions(-) rename tests/e2e/.claude/skills/{e2e-test-development => e2e-test-developer}/SKILL.md (90%) diff --git a/tests/e2e/.claude/skills/e2e-test-development/SKILL.md b/tests/e2e/.claude/skills/e2e-test-developer/SKILL.md similarity index 90% rename from tests/e2e/.claude/skills/e2e-test-development/SKILL.md rename to tests/e2e/.claude/skills/e2e-test-developer/SKILL.md index f36a85a0ae4..5087b120f7d 100644 --- a/tests/e2e/.claude/skills/e2e-test-development/SKILL.md +++ b/tests/e2e/.claude/skills/e2e-test-developer/SKILL.md @@ -1,3 +1,8 @@ +--- +name: e2e-test-developer +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. +--- + # Eclipse Che E2E TypeScript Mocha Selenium Test Development Skill 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. @@ -33,6 +38,13 @@ This is the E2E test suite for Eclipse Che / Red Hat OpenShift Dev Spaces. It us # Install dependencies npm ci +# Lint and format +npm run lint +npm run prettier + +# Build TypeScript only +npm run tsc + # Run all tests (requires environment variables) export TS_SELENIUM_BASE_URL= export TS_SELENIUM_OCP_USERNAME= @@ -40,17 +52,12 @@ export TS_SELENIUM_OCP_PASSWORD= npm run test # Run a single test file (without .spec.ts extension) -export USERSTORY=SmokeTest && npm run test +export USERSTORY=SmokeTest +npm run test # Run API-only tests (no browser) -export USERSTORY=EmptyWorkspaceAPI && npm run driver-less-test - -# Lint and format -npm run lint -npm run prettier - -# Build TypeScript only -npm run tsc +export USERSTORY=EmptyWorkspaceAPI +npm run driver-less-test # View Allure test report npm run open-allure-dasboard @@ -64,7 +71,7 @@ Every TypeScript file MUST start with this exact header: ```typescript /** ******************************************************************* - * copyright (c) 2023 Red Hat, Inc. + * copyright (c) 2026 Red Hat, Inc. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -412,12 +419,7 @@ suite('API Test', function (): void { When helping with E2E test development and maintenance: -1. **Keep command files up to date** - When test infrastructure changes (new environment variables, test patterns, or execution methods), update the related command files in `.claude/commands/`: - - - `run-che-e2e-test-locally.md` - - `run-che-e2e-test-using-podman.md` - - `run-devspaces-e2e-test-locally.md` - - `run-devspaces-e2e-test-using-podman.md` +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`. 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. @@ -429,14 +431,23 @@ When helping with E2E test development and maintenance: ## Related Commands -For running E2E tests, use these companion commands: +### `/run-e2e-test` - Unified E2E Test Runner + +Run E2E tests against **Eclipse Che** or **Red Hat OpenShift Dev Spaces** using either a **local Chrome browser** or **Podman container**. -### Eclipse Che +**Usage:** `/run-e2e-test [URL USERNAME PASSWORD [TESTNAME] [METHOD]]` -- **`/run-che-e2e-test-using-podman`** - Run E2E tests against Eclipse Che using the che-e2e container with Podman (isolated environment with VNC support) -- **`/run-che-e2e-test-locally`** - Run E2E tests against Eclipse Che using a local Chrome browser (for development and debugging) +**Features:** +- **Interactive mode**: Run without arguments to be prompted for all parameters +- **Auto-detect platform**: Determines Eclipse Che vs Dev Spaces from URL +- **Smart rebuild**: Detects local code changes vs `origin/main` and rebuilds only when needed +- **Test-specific parameters**: Prompts for additional env vars based on selected test type -### Red Hat OpenShift Dev Spaces +**Examples:** +- `/run-e2e-test` - Interactive mode (recommended) +- `/run-e2e-test https://devspaces.apps.example.com/ admin password SmokeTest npm` +- `/run-e2e-test https://che.apps.example.com/ admin password EmptyWorkspace podman` -- **`/run-devspaces-e2e-test-using-podman`** - Run E2E tests against Dev Spaces using the che-e2e container with Podman (includes OAuth configuration) -- **`/run-devspaces-e2e-test-locally`** - Run E2E tests against Dev Spaces using a local Chrome browser (includes SSO/OAuth setup) +**Run methods:** +- `npm` - Local Chrome browser (faster, see browser in real-time) +- `podman` - Isolated container with VNC support at `localhost:5920` diff --git a/tests/e2e/CLAUDE.md b/tests/e2e/CLAUDE.md index a69eeda8e46..f0fbc84f87f 100644 --- a/tests/e2e/CLAUDE.md +++ b/tests/e2e/CLAUDE.md @@ -2,19 +2,13 @@ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. -**Available commands:** +**Available skills:** -- `/e2e-test-development` - Comprehensive E2E test development guidance (code style, patterns, architecture) +- `/e2e-test-developer` - Comprehensive E2E test development guidance (code style, patterns, architecture) -**Eclipse Che:** +**Available custom commands:** -- `/run-che-e2e-test-using-podman` - Run E2E tests using che-e2e container with Podman -- `/run-che-e2e-test-locally` - Run E2E tests using local Chrome browser - -**Red Hat OpenShift Dev Spaces:** - -- `/run-devspaces-e2e-test-using-podman` - Run E2E tests against Dev Spaces using Podman container -- `/run-devspaces-e2e-test-locally` - Run E2E tests against Dev Spaces using local browser +- `/run-e2e-test` - Run E2E tests against Eclipse Che or Red Hat OpenShift Dev Spaces using local browser or Podman container ## Overview From 911e72d8bcc7f7eb52cc6018f6444ed8992ab6e4 Mon Sep 17 00:00:00 2001 From: Dmytro Nochevnov Date: Sun, 1 Feb 2026 18:42:59 +0200 Subject: [PATCH 8/8] Fix prettier formatting errors Signed-off-by: Dmytro Nochevnov --- tests/e2e/.claude/settings.local.json | 22 +++++++++---------- .../skills/e2e-test-developer/SKILL.md | 3 +++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/e2e/.claude/settings.local.json b/tests/e2e/.claude/settings.local.json index ed660e86739..e5441cdaded 100644 --- a/tests/e2e/.claude/settings.local.json +++ b/tests/e2e/.claude/settings.local.json @@ -1,13 +1,13 @@ { - "permissions": { - "allow": [ - "Bash(source ~/.nvm/nvm.sh)", - "Bash(nvm use:*)", - "Bash(npm run prettier:*)", - "Bash(node:*)", - "Bash(npm run lint:*)", - "Bash(npm run tsc:*)", - "Bash(export:*)" - ] - } + "permissions": { + "allow": [ + "Bash(source ~/.nvm/nvm.sh)", + "Bash(nvm use:*)", + "Bash(npm run prettier:*)", + "Bash(node:*)", + "Bash(npm run lint:*)", + "Bash(npm run tsc:*)", + "Bash(export:*)" + ] + } } diff --git a/tests/e2e/.claude/skills/e2e-test-developer/SKILL.md b/tests/e2e/.claude/skills/e2e-test-developer/SKILL.md index 5087b120f7d..59b55b6f2ed 100644 --- a/tests/e2e/.claude/skills/e2e-test-developer/SKILL.md +++ b/tests/e2e/.claude/skills/e2e-test-developer/SKILL.md @@ -438,16 +438,19 @@ Run E2E tests against **Eclipse Che** or **Red Hat OpenShift Dev Spaces** using **Usage:** `/run-e2e-test [URL USERNAME PASSWORD [TESTNAME] [METHOD]]` **Features:** + - **Interactive mode**: Run without arguments to be prompted for all parameters - **Auto-detect platform**: Determines Eclipse Che vs Dev Spaces from URL - **Smart rebuild**: Detects local code changes vs `origin/main` and rebuilds only when needed - **Test-specific parameters**: Prompts for additional env vars based on selected test type **Examples:** + - `/run-e2e-test` - Interactive mode (recommended) - `/run-e2e-test https://devspaces.apps.example.com/ admin password SmokeTest npm` - `/run-e2e-test https://che.apps.example.com/ admin password EmptyWorkspace podman` **Run methods:** + - `npm` - Local Chrome browser (faster, see browser in real-time) - `podman` - Isolated container with VNC support at `localhost:5920`