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
75 changes: 0 additions & 75 deletions .claude/commands/cypress/cypress-setup.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: cypress-run
name: run
description: Display Cypress test commands - choose execution mode (headless recommended)
parameters:
- name: execution-mode
Expand All @@ -11,8 +11,8 @@ parameters:
# Cypress Test Commands

**Prerequisites**:
1. Run `/cypress-setup` first to configure your environment.
2. Ensure the "Cypress Tests" terminal window is open (created by `/cypress-setup`)
1. Run `/cypress:setup` first to configure your environment.
2. Ensure the "Cypress Tests" terminal window is open (created by `/cypress:setup`)

**Note**: All commands are executed in the "Cypress Tests" terminal window using the helper scripts.

Expand Down Expand Up @@ -340,7 +340,7 @@ Use these tags with `--env grepTags`:

## Related Commands

- **`/cypress-setup`** - Configure testing environment and open Cypress Tests terminal
- **`/cypress:setup`** - Configure testing environment and open Cypress Tests terminal

---

Expand Down
87 changes: 87 additions & 0 deletions .claude/commands/cypress/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
name: setup
description: Automated Cypress environment setup with direct configuration
parameters: []
---

# Cypress Environment Setup

This command sets up the Cypress testing environment by checking prerequisites, installing dependencies, and configuring environment variables.

## Instructions for Claude

Follow these steps in order:

### Step 1: Check Prerequisites

1. **Check Node.js version** - Required: >= 18
- Run `node --version` and verify it's >= 18
- If not, inform the user they need to install Node.js 18 or higher

### Step 2: Navigate and Install Dependencies

1. **Navigate to the cypress directory**:
```bash
cd web/cypress
```
Comment on lines +23 to +26
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Path flow is inconsistent after cd web/cypress

After Line 25, commands in Lines 49 and 79 should target export-env.sh directly, not web/cypress/export-env.sh. Current instructions can write/source the wrong location.

🧩 Proposed fix
-cat > web/cypress/export-env.sh << 'ENVEOF'
+cat > export-env.sh << 'ENVEOF'
...
-source web/cypress/export-env.sh
+source export-env.sh

Also applies to: 49-50, 79-80

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/commands/cypress/setup.md around lines 23 - 26, The docs change
directory with the line "cd web/cypress" but later commands still reference
"web/cypress/export-env.sh"; update those occurrences (e.g., the commands at the
locations referencing "web/cypress/export-env.sh" around Lines 49-50 and 79-80)
to reference "export-env.sh" (or "./export-env.sh") so they correctly target the
script relative to the already-changed working directory and avoid
sourcing/writing the wrong path.


2. **Install npm dependencies**:
```bash
npm install
```

### Step 3: Create or Update Environment Configuration

**Important**: Do NOT run the interactive `configure-env.sh` script. Instead, create the `web/cypress/export-env.sh` file directly.

1. Check if `web/cypress/export-env.sh` already exists
2. If it exists, read it and show the current values to the user. Ask if they want to keep or update them.
3. Look for cluster credentials in the following order:
- **Conversation context**: Check if the user already provided a console URL and kubeadmin password earlier in the conversation
- **Existing export-env.sh**: Reuse values from an existing file if the user confirms they're current
- **Ask the user directly**: If no credentials are found, ask the user to provide:
- Console URL (e.g., `https://console-openshift-console.apps.ci-ln-xxxxx.aws-4.ci.openshift.org`)
- Kubeadmin password
- **Do NOT proceed without credentials** — the file cannot be created with placeholder values
4. Write the file directly:

```bash
cat > web/cypress/export-env.sh << 'ENVEOF'
# shellcheck shell=bash
export CYPRESS_BASE_URL='<console-url>'
export CYPRESS_LOGIN_IDP='kube:admin'
export CYPRESS_LOGIN_USERS='kubeadmin:<password>'
Comment on lines +51 to +53
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add explicit secret-handling safeguards for export-env.sh

These lines persist kubeadmin credentials in plaintext. Add guardrails: restrictive permissions, ignore-from-git, and an explicit “do not commit” warning.

🔐 Proposed addition
+chmod 600 export-env.sh
+# IMPORTANT: export-env.sh contains secrets. Do not commit it.
+# Ensure it is listed in .gitignore.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/commands/cypress/setup.md around lines 51 - 53, The exported
credential lines in export-env.sh (CYPRESS_BASE_URL, CYPRESS_LOGIN_IDP,
CYPRESS_LOGIN_USERS) persist kubeadmin credentials in plaintext; update
export-env.sh to add an explicit “DO NOT COMMIT / secrets” header, enforce
restrictive file permissions (e.g., create or instruct to run chmod 600 on the
file), and add a .gitignore entry to ignore this file by name; also include a
short comment explaining the secure workflow (temporary file only, remove after
use) and a one-line check in the script that exits if the file is tracked in git
to prevent accidental commits.

export CYPRESS_KUBECONFIG_PATH='/tmp/kubeconfig'
export CYPRESS_SKIP_ALL_INSTALL='false'
export CYPRESS_SKIP_COO_INSTALL='false'
export CYPRESS_COO_UI_INSTALL='true'
export CYPRESS_SKIP_KBV_INSTALL='true'
export CYPRESS_KBV_UI_INSTALL='false'
export CYPRESS_TIMEZONE='UTC'
export CYPRESS_MOCK_NEW_METRICS='false'
export CYPRESS_SESSION='true'
export CYPRESS_DEBUG='false'
ENVEOF
```

Notes on the values:
- `CYPRESS_BASE_URL`: The OpenShift console URL from the cluster provisioning output
- `CYPRESS_LOGIN_USERS`: Format is `kubeadmin:<password>` using the password from cluster provisioning
- `CYPRESS_KUBECONFIG_PATH`: Use `/tmp/kubeconfig` when running in a Docker sandbox, or the actual path to kubeconfig on the host
- `CYPRESS_SKIP_ALL_INSTALL='false'`: Ensures operators get installed on first run
- `CYPRESS_COO_UI_INSTALL='true'`: Installs the Cluster Observability Operator UI plugin

### Step 4: Verify the setup

Source the file and confirm the variables are set:

```bash
source web/cypress/export-env.sh
echo "Base URL: $CYPRESS_BASE_URL"
```

### Step 5: Inform the user

Let the user know the environment is configured and they can run tests using `/cypress:run`.

---
Loading