-
-
Notifications
You must be signed in to change notification settings - Fork 749
Migrate "e2e" api tests to javascript #11779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alisman
wants to merge
9
commits into
cBioPortal:master
Choose a base branch
from
alisman:js-e2e
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+1,477
−562
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Converted Java E2E tests to JavaScript/TypeScript using Mocha test framework. The new test suite provides equivalent coverage to the original Java tests while allowing for easier JavaScript-based test development. Key features: - 7 comprehensive test cases covering alteration enrichment scenarios - TypeScript for type safety and better IDE support - Mocha + Chai for test framework and assertions - Configurable server URL via environment variable - Test utilities matching original Java helper methods - All tests passing against local cBioPortal instance Test coverage includes: - Multi-study comparison (WES and IMPACT) - CNA-only profile filtering - Missense mutation filtering - Multi-panel sample handling - Alteration type filtering - Patient vs Sample enrichment types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Refactor test utilities to work with parsed JSON objects Updated TestUtils to handle JSON objects directly instead of strings: - loadTestData() now parses and returns JSON objects instead of raw strings - callEnrichmentEndpoint() accepts objects instead of strings (axios handles serialization) - Removed redundant JSON.parse() and JSON.stringify() calls throughout tests - Fixed shallow copy bug by using deep clones where needed and reordering test execution This change makes the code more idiomatic and eliminates unnecessary string conversions. All 7 tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Refactor tests to use lodash with inline logic and improved comments Removed abstraction layers and made test logic transparent: - Removed helper methods (findGeneEnrichment, getTotalProfiledSamples, getTotalAlteredSamples) - Inlined all response processing logic directly in test bodies - Replaced native JS array methods with lodash equivalents: - _.find() for finding genes by symbol - _.sumBy() for calculating totals - _.cloneDeep() for deep cloning objects - _.filter(), _.forEach(), _.every(), _.some() for array operations - _.endsWith() for string matching - Added comprehensive inline comments explaining each step - All assertions now clearly show what data is being processed Benefits: - Test logic is explicit and visible in each test - Comments explain the "why" behind each calculation - Easier to understand and debug test failures - Consistent use of lodash throughout All 7 tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Add comprehensive test writing guide Created WRITING_TESTS.md to document testing patterns and best practices: - Core principles: transparency, lodash usage, thorough commenting - Detailed lodash method examples (find, sumBy, filter, every, some, etc.) - Step-by-step guide for writing test logic - Four common reusable patterns with code examples - Best practices with good/bad comparisons - Three complete example tests - Debugging tips The guide provides clear instructions for writing maintainable, well-commented E2E tests that follow the established patterns in the codebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> Reorganize tests and update types from Swagger documentation Major changes: - Reorganized test structure: each spec now lives in its own directory with test data - Updated TypeScript types to match official cBioPortal Swagger API documentation - Renamed AlterationCount to CountSummary (correct Swagger name) - Made 'name' field required in CountSummary (per Swagger spec) - Removed qValue field (not in Swagger spec) - Updated loadTestData() to automatically find test data in same directory as test - Uses stack trace inspection to determine caller location - Replaced WRITING_TESTS.md with CLAUDE.md for AI-assisted development Type derivation: - All types now sourced from https://www.cbioportal.org/api/v3/api-docs/internal - Added comprehensive JSDoc comments with source attribution - Documented which fields are required vs optional - Added instructions in CLAUDE.md for deriving types from Swagger docs Directory structure changes: - test/AlterationEnrichmentController/ ├── AlterationEnrichmentController.spec.ts ├── all_alterations.json ├── multi_panel.json ├── patient.json └── sample.json All tests passing with updated structure and types. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> fesafdsafdsa
…ontroller Migrate two Java E2E test suites to TypeScript/Mocha: - ColumnStoreMutationControllerE2ETest.java → test/ColumnStoreMutationController/ - ColumnStoreStudyControllerE2ETest.java → test/ColumnStoreStudyController/ Key changes: - Add MutationDTO, Gene, AlleleSpecificCopyNumber types and ProjectionType enum - Add mutation fetch tests for ID, SUMMARY, and DETAILED projections - Add study fetch test with DETAILED projection - Fix CancerStudyMetadataDTO.cancerType → typeOfCancer to match API response - All 11 E2E tests passing (7 AlterationEnrichment + 3 Mutation + 1 Study) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add comprehensive section describing the JavaScript/TypeScript E2E tests: - Prerequisites: Node.js, running cBioPortal with cgds_public_2025_06_24 database - Installation and running instructions with npm commands - Environment variable configuration (CBIOPORTAL_URL) - Test structure and conventions - Reference to CLAUDE.md for detailed test writing guidelines 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Remove Java E2E tests reference from directory structure - Simplify JavaScript E2E tests description to focus on API testing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Delete src/e2e/java/ directory and all Java E2E test files: - AbstractE2ETest.java - AlterationEnrichmentControllerE2ETest.java - ColumnStoreMutationControllerE2ETest.java - ColumnStoreStudyControllerE2ETest.java - HealthCheckE2ETest.java - All associated test data JSON files Update README.md to remove Java E2E test references: - Update E2E test layer to use Mocha, Chai, Axios instead of Spring Boot tools - Remove ClickHouse E2E environment variable references - Remove e2e-test Maven profile from documentation - Update environment variables table to only reference Integration tests All E2E tests are now exclusively JavaScript/TypeScript based in src/e2e/js/ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Add "(test api requests)" to section heading for clarity - Remove watch mode command (not commonly used) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
- Update run-tests.sh to check if cBioPortal is responding before running tests - Fail with clear error message if server is not accessible - Update npm test script to use run-tests.sh - Change default URL from 8080 to 8082 to match actual server - Pass through spec patterns to mocha for flexible test execution - Update README with corrected test commands Benefits: - Tests fail fast with helpful message if server is not running - Saves time by not running tests against non-responsive server - Clear instructions on how to fix the issue 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Use --no-warnings flag to suppress MODULE_TYPELESS_PACKAGE_JSON warning for cleaner test output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Migrate E2E tests from Java to JavaScript/TypeScript (Mocha)
Summary
This PR migrates all E2E tests from Java to JavaScript/TypeScript using Mocha, Chai, and Axios. The new test suite provides better developer experience with faster test execution and clearer test patterns.
Changes
New JavaScript/TypeScript E2E Tests
src/e2e/js/directory with complete test infrastructureAlterationEnrichmentController(7 tests)ColumnStoreMutationController(3 tests)ColumnStoreStudyController(1 test)cgds_public_2025_06_24databaseTest Infrastructure
Key Features
Removed
src/e2e/java/directory and all Java E2E testse2e-testMaven profileDocumentation
CLAUDE.mdwith comprehensive test writing guidelinesTesting
All 11 tests verified passing:
Results: ✅ 11 passing (15s)
Prerequisites for Running Tests
cgds_public_2025_06_24databasehttp://localhost:8080(or setCBIOPORTAL_URL)Example Test Structure
Benefits
Migration Notes
All Java E2E test functionality has been preserved:
Related Documentation
src/e2e/js/CLAUDE.mdBranch:
alisman:js-e2e→cbioportal:master