|
| 1 | +# Claude Code Configuration for Galaxy Selenium Tests |
| 2 | + |
| 3 | +This directory contains Claude Code configuration and slash commands for working with Galaxy's Selenium test suite. |
| 4 | + |
| 5 | +## CLAUDE.md |
| 6 | + |
| 7 | +The `CLAUDE.md` file in the parent directory (`../CLAUDE.md`) provides comprehensive documentation about Galaxy Selenium testing conventions. It includes: |
| 8 | + |
| 9 | +- Test structure and base classes |
| 10 | +- Common patterns (login, navigation, data upload) |
| 11 | +- Decorator usage (`@selenium_test`, `@managed_history`, `@requires_admin`) |
| 12 | +- Component system access |
| 13 | +- Helper methods and wait types |
| 14 | +- Accessibility testing guidelines |
| 15 | +- Complete test templates for different scenarios |
| 16 | + |
| 17 | +**Purpose**: This file serves as context for Claude Code when writing or modifying Selenium tests, ensuring consistency with Galaxy's testing conventions. |
| 18 | + |
| 19 | +## Slash Commands |
| 20 | + |
| 21 | +### Direct Test Creation |
| 22 | + |
| 23 | +#### `/new-selenium-test` |
| 24 | + |
| 25 | +Bootstrap a new Selenium test file from scratch. |
| 26 | + |
| 27 | +**Usage:** |
| 28 | +``` |
| 29 | +/new-selenium-test <feature description> |
| 30 | +``` |
| 31 | + |
| 32 | +**Examples:** |
| 33 | +``` |
| 34 | +/new-selenium-test workflow import with accessibility testing |
| 35 | +/new-selenium-test admin user management features |
| 36 | +/new-selenium-test dataset metadata editing with managed history |
| 37 | +``` |
| 38 | + |
| 39 | +**What it does:** |
| 40 | +- Creates a new test file with proper structure |
| 41 | +- Includes appropriate imports and decorators |
| 42 | +- Follows Galaxy naming conventions |
| 43 | +- Uses correct template based on requirements |
| 44 | +- Asks clarifying questions if needed |
| 45 | + |
| 46 | +#### `/add-selenium-test` |
| 47 | + |
| 48 | +Add new test methods to an existing Selenium test file. |
| 49 | + |
| 50 | +**Usage:** |
| 51 | +``` |
| 52 | +/add-selenium-test <description and target file> |
| 53 | +``` |
| 54 | + |
| 55 | +**Examples:** |
| 56 | +``` |
| 57 | +/add-selenium-test Add a test for tag filtering to test_history_panel.py |
| 58 | +/add-selenium-test Add admin test for user deletion to test_admin_app.py |
| 59 | +/add-selenium-test Add dataset copy test with managed history to test_dataset_edit.py |
| 60 | +``` |
| 61 | + |
| 62 | +**What it does:** |
| 63 | +- Reads existing file to match style |
| 64 | +- Adds properly structured test methods |
| 65 | +- Updates imports if necessary |
| 66 | +- Maintains consistency with existing code |
| 67 | + |
| 68 | +### Interactive Jupyter Workflow |
| 69 | + |
| 70 | +For complex tests or when you need to explore the DOM interactively, use the Jupyter notebook workflow: |
| 71 | + |
| 72 | +#### `/setup-selenium-test-notebook` |
| 73 | + |
| 74 | +Create a Jupyter notebook for interactively prototyping a Selenium test. |
| 75 | + |
| 76 | +**Usage:** |
| 77 | +``` |
| 78 | +/setup-selenium-test-notebook <feature description OR GitHub PR> |
| 79 | +``` |
| 80 | + |
| 81 | +**Examples (text mode):** |
| 82 | +``` |
| 83 | +/setup-selenium-test-notebook dataset metadata editing |
| 84 | +/setup-selenium-test-notebook workflow import from URL |
| 85 | +/setup-selenium-test-notebook admin user quota management |
| 86 | +``` |
| 87 | + |
| 88 | +**Examples (GitHub PR mode):** |
| 89 | +``` |
| 90 | +/setup-selenium-test-notebook https://github.com/galaxyproject/galaxy/pull/12345 |
| 91 | +/setup-selenium-test-notebook #12345 |
| 92 | +/setup-selenium-test-notebook 12345 |
| 93 | +``` |
| 94 | + |
| 95 | +**What it does:** |
| 96 | +- Fetches PR context (if PR mode): description, screenshots, author |
| 97 | +- Launches research subagent to find similar existing tests |
| 98 | +- Creates a prototype notebook in `jupyter/` directory |
| 99 | +- Includes PR context, example code, and starter code |
| 100 | +- Prints complete setup instructions |
| 101 | + |
| 102 | +**Workflow:** |
| 103 | +1. Run `/setup-selenium-test-notebook <feature>` to create notebook |
| 104 | +2. Follow printed instructions to start Jupyter |
| 105 | +3. Prototype test interactively with screenshots |
| 106 | +4. Run `/extract-selenium-test` when done to convert to test file |
| 107 | + |
| 108 | +#### `/extract-selenium-test` |
| 109 | + |
| 110 | +Extract test code from a Jupyter notebook and convert to a proper test file. |
| 111 | + |
| 112 | +**Usage:** |
| 113 | +``` |
| 114 | +/extract-selenium-test <notebook path or description> |
| 115 | +``` |
| 116 | + |
| 117 | +**Examples:** |
| 118 | +``` |
| 119 | +/extract-selenium-test from jupyter/test_prototype_dataset_metadata.ipynb |
| 120 | +/extract-selenium-test jupyter/test_prototype_workflow_import.ipynb as test_workflow_import |
| 121 | +/extract-selenium-test notebook test_prototype_admin_users.ipynb |
| 122 | +``` |
| 123 | + |
| 124 | +**What it does:** |
| 125 | +- Reads notebook cells (skipping initialization) |
| 126 | +- Transforms `gx_selenium_context` to `self` |
| 127 | +- Detects required decorators and attributes |
| 128 | +- Creates properly structured Pytest test file for the Selenium test suite |
| 129 | +- Groups related cells into test methods |
| 130 | + |
| 131 | +## Getting Started |
| 132 | + |
| 133 | +### Quick Start (Direct Creation) |
| 134 | + |
| 135 | +For straightforward tests with known requirements: |
| 136 | + |
| 137 | +1. **Read `../CLAUDE.md`** to understand Galaxy Selenium testing conventions |
| 138 | +2. **Use `/new-selenium-test <description>`** to create a new test file |
| 139 | +3. **Use `/add-selenium-test <description>`** to extend an existing test file |
| 140 | +4. **Run** with `pytest lib/galaxy_test/selenium/test_<your_file>.py` |
| 141 | + |
| 142 | +### Interactive Development (Jupyter Workflow) |
| 143 | + |
| 144 | +For complex tests or DOM exploration: |
| 145 | + |
| 146 | +1. **Create notebook**: `/setup-selenium-test-notebook <description>` |
| 147 | +2. **Start Galaxy & Jupyter** following the printed instructions |
| 148 | +3. **Prototype interactively** in the notebook with live screenshots |
| 149 | +4. **Extract to test**: `/extract-selenium-test <notebook_path>` |
| 150 | +5. **Run** with `pytest lib/galaxy_test/selenium/test_<your_file>.py` |
| 151 | + |
| 152 | +## Tips |
| 153 | + |
| 154 | +- **Be specific** in command descriptions (mention admin access, managed history, etc.) |
| 155 | +- **Use Jupyter workflow** when you need to explore the DOM or iterate quickly |
| 156 | +- **Use direct creation** when you know exactly what needs to be tested |
| 157 | +- Commands will **ask clarifying questions** if your request is ambiguous |
| 158 | +- **Review generated code** to ensure it meets your specific needs |
| 159 | +- **Reference existing tests** in the parent directory for patterns and examples |
0 commit comments