Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,33 @@ updates:
labels:
- "area/ci-tooling"
- "ok-to-test"
# UI test dependencies (npm)
- package-ecosystem: "npm"
directory: "/test/ui"
schedule:
interval: "weekly"
day: "friday"
time: "01:00"
timezone: "Etc/UTC"
commit-message:
prefix: "build(deps)"
labels:
- "area/ci-tooling"
- "area/ui-tests"
- "ok-to-test"
groups:
playwright-dependencies:
patterns:
- "@playwright/*"
- "playwright*"
typescript-dependencies:
patterns:
- "typescript*"
- "@types/*"
eslint-dependencies:
patterns:
- "eslint*"
- "@eslint/*"
misc-dependencies:
patterns:
- "*"
30 changes: 29 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ verify-docs-nav: $(PYTHON_VENV_STAMP) ## Verify docs nav entries are sorted alph

.PHONY: verify-codespell
verify-codespell: codespell ## Verify codespell.
@$(CODESPELL) --count --ignore-words=./.codespellignore --skip="./docs/site/*,./vendor/*,./api/vendor/*,./hack/tools/vendor/*,./api/hypershift/v1alpha1/*,./support/thirdparty/*,./docs/content/reference/*,./hack/tools/bin/*,./cmd/install/assets/*,./go.sum,./api/go.sum,./hack/workspace/go.work.sum,./api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests,./hack/tools/go.mod,./hack/tools/go.sum,./karpenter-operator/controllers/karpenter/assets/*.yaml,./dev/*"
@$(CODESPELL) --count --ignore-words=./.codespellignore --skip="./docs/site/*,./vendor/*,./api/vendor/*,./hack/tools/vendor/*,./api/hypershift/v1alpha1/*,./support/thirdparty/*,./docs/content/reference/*,./hack/tools/bin/*,./cmd/install/assets/*,./go.sum,./api/go.sum,./hack/workspace/go.work.sum,./api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests,./hack/tools/go.mod,./hack/tools/go.sum,./karpenter-operator/controllers/karpenter/assets/*.yaml,./dev/*,./test/ui/playwright-report/*,./test/ui/node_modules/*,./test/ui/test-results/*"

.PHONY: verify-api-deps
verify-api-deps: $(VERIFY_API_DEPS) ## Verify API dependencies against allowlist.
Expand Down Expand Up @@ -709,3 +709,31 @@ $(CODESPELL): $(PYTHON_VENV_STAMP)

gitlint: $(GITLINT) ## Install local copy of gitlint.
$(GITLINT): $(PYTHON_VENV_STAMP)

##@ UI Tests
.PHONY: test-ui-install
test-ui-install: ## Install UI test dependencies (Playwright)
@echo "Installing UI test dependencies..."
cd test/ui && npm ci
@echo "Installing Playwright browsers..."
cd test/ui && npx playwright install chromium

.PHONY: test-ui
test-ui: test-ui-install ## Run all UI tests (headless)
@echo "Running all UI tests..."
cd test/ui && npm test

.PHONY: test-ui-headed
test-ui-headed: test-ui-install ## Run UI tests in headed mode (interactive)
@echo "Running UI tests in headed mode..."
cd test/ui && npm run test:headed

.PHONY: test-ui-common
test-ui-common: test-ui-install ## Run common UI tests (smoke tests, infrastructure validation)
@echo "Running common UI tests..."
cd test/ui && npm run test:common

.PHONY: test-ui-agent
test-ui-agent: test-ui-install ## Run Agent platform UI tests
@echo "Running Agent platform UI tests..."
cd test/ui && npm run test:agent
Comment thread
coderabbitai[bot] marked this conversation as resolved.
17 changes: 17 additions & 0 deletions test/ui/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# HyperShift UI E2E Test Environment Configuration
# Copy this file to .env and fill in your values

# Hub cluster configuration
HUB_URL=https://api.your-cluster.example.com:6443
HUB_PASSWORD=your-kubeadmin-password

# Console URL (optional - derived from HUB_URL if not set)
# CONSOLE_URL=https://console-openshift-console.apps.your-cluster.example.com

# Console authentication (optional overrides)
CONSOLE_USERNAME=kubeadmin
CONSOLE_IDP=kube:admin

# Test configuration
CI=false
TEST_MODE=integration
33 changes: 33 additions & 0 deletions test/ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Dependencies
node_modules/

# Build output
dist/

# Playwright
test-results/
playwright-report/
playwright/.cache/

# Auth state (contains session cookies - DO NOT COMMIT)
.auth/

# IDE
.idea/
.vscode/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db

# Logs
*.log
npm-debug.log*

# Environment variables
.env
.env.local
.env.*.local
*.local.env
6 changes: 6 additions & 0 deletions test/ui/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
test-results/
playwright-report/
.auth/
dist/
package-lock.json
6 changes: 6 additions & 0 deletions test/ui/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 100
}
151 changes: 151 additions & 0 deletions test/ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# HyperShift UI E2E Tests

Playwright-based E2E test framework for HyperShift MCE console integration following console E2E patterns.

## Prerequisites

1. **Node.js** 20+
2. oc CLI installed and logged into your cluster
3. Playwright browsers installed
```bash
# Install dependencies and Playwright browsers
make test-ui-install
```

## Environment Variables

**Recommended:** Copy `.env.example` when making `.env` (gitignored). Playwright loads it via `src/config/index.ts`.

**Hub cluster + console authentication:**

| Variable | Required | Default | Description |
| ------------------ | -------- | ------------ | ------------------------------------------------------------------- |
| `HUB_URL` | **Yes** | - | Hub cluster API URL (e.g., `https://api.cluster.com:6443`) |
| `HUB_PASSWORD` | **Yes** | - | Password for `oc login` and console UI authentication |
| `CONSOLE_URL` | No | (derived) | Console URL (derived from `HUB_URL` if not set) |
| `CONSOLE_USERNAME` | No | `kubeadmin` | Username for console login form |
| `CONSOLE_IDP` | No | `kube:admin` | Identity provider link text on console login page |

**Test configuration (optional):**

| Variable | Required | Default | Description |
| ----------- | -------- | ------------- | ----------------------------------------------------- |
| `CI` | No | `false` | Set to `true` to enable CI mode (retries, forbidOnly) |
| `TEST_MODE` | No | `integration` | Test mode (`integration`, `e2e`, etc.) |
Comment thread
coderabbitai[bot] marked this conversation as resolved.

> **Note:** `CI` is parsed as a boolean. Only the string `"true"` enables CI mode; any other value (including `"false"` or unset) disables it.
>
> **Typical kubeadmin setup:** `.env` with just `HUB_URL` and `HUB_PASSWORD`.
Comment thread
coderabbitai[bot] marked this conversation as resolved.

### Example `.env`

```bash
HUB_URL=https://api.my-hub-cluster.example.com:6443
HUB_PASSWORD=my-kubeadmin-password
CONSOLE_USERNAME=kubeadmin
CONSOLE_IDP=kube:admin
```

## Playwright Projects

| Project | Scope | Test Path |
Comment thread
coderabbitai[bot] marked this conversation as resolved.
| -------- | ------------------------------------------------------------------------------- | --------------------- |
| `setup` | Authentication setup → saves session to `.auth/admin.json` | `src/auth.setup.ts` |
| `common` | Platform-agnostic tests (smoke tests, infrastructure validation) | `src/tests/common/**` |
| `agent` | Agent-platform HyperShift tests (InfraEnv, discovery ISO, bare metal workflows) | `src/tests/agent/**` |

Projects depend on `setup` for authentication and run with a saved console session.

**Note**: All tests migrated from stolostron/clc-ui-e2e (CNTRLPLANE-2104) are Agent platform tests. AWS and other platform tests are not in the initial migration scope.

## Running Tests
### All Tests
```bash
make test-ui
```
### Platform-Specific Tests
```bash
# Common tests (smoke tests, infrastructure)
make test-ui-common

# Agent platform tests
make test-ui-agent
```
### Development Mode
```bash
# Headed mode (see browser)
make test-ui-headed
```
### Direct Playwright CLI
```bash
cd test/ui

# Run all tests
npm test

# Run specific project
npm run test:common
npm run test:agent

# Run specific test file
npx playwright test src/tests/common/smoke.spec.ts

# UI mode (interactive)
npx playwright test --ui

# Debug mode (step through with inspector)
npx playwright test --debug
```

## Architecture
- **Playwright** for browser automation
- **TypeScript** with path aliases (`@config`, `@pages`, `@services`, etc.)
- **Page Object Model** pattern for UI interactions
- **Fixtures** for dependency injection (`oc` CLI service, unique name generator, cleanup tracker)

This directory maps to it as follows:
```text
test/ui/
├── src/
│ ├── auth.setup.ts # OpenShift console authentication
│ ├── global-setup.ts # Pre-test cleanup (.auth/ directory)
│ ├── config/ # Environment configuration
│ ├── constants/ # Selectors and constants
│ ├── services/ # CLI services (OcCliService, etc.)
│ ├── pages/ # Page Object Model classes
│ │ └── ...
│ ├── fixtures/ # Playwright test fixtures (oc, uniqueName, cleanup)
│ │ └── hypershift-test.ts # Base fixture extending Playwright test
│ ├── utils/ # Helper utilities
│ └── tests/ # Test specifications
│ ├── common/ # Platform-agnostic smoke tests
│ └── agent/ # Agent platform tests
├── .env.example # Environment variable template
├── playwright.config.ts # Playwright configuration
├── tsconfig.json # TypeScript configuration
└── package.json # Dependencies and scripts
```

## Writing New Tests
1. **Create a test file** in `src/tests/common/` or `src/tests/agent/`
2. **Use the HyperShift fixture:**
Comment thread
coderabbitai[bot] marked this conversation as resolved.
```typescript
import { test, expect } from '@fixtures/hypershift-test';

test.describe('My Feature', () => {
test('should do something', async ({ page, oc, uniqueName, cleanup }) => {
// page: Playwright Page object
// oc: OcCliService for running oc commands
// uniqueName: Unique test resource name (hypershift-ci-xxxxx)
// cleanup: Automatic cleanup tracker for HostedClusters and namespaces
// Your test logic here
});
});
```
1. **Create page objects** in `src/pages/` following the Page Object Model pattern
2. **Add cleanup** for any resources created:
```typescript
cleanup.trackHostedCluster('my-cluster', 'clusters');
cleanup.trackNamespace('my-test-namespace');
```

27 changes: 27 additions & 0 deletions test/ui/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import eslint from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import playwright from 'eslint-plugin-playwright';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{
ignores: [
'**/node_modules/**',
'**/.auth/**',
'**/test-results/**',
'**/playwright-report/**',
],
},
{
files: ['**/*.ts'],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
playwright.configs['flat/recommended'],
eslintConfigPrettier,
],
rules: {
'playwright/expect-expect': 'warn',
},
}
);
Loading