Added new validations for CBIO#221
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds JavaScript-based validation scripts for cBioPortal endpoints in the CCDI monitoring configuration. The validations ensure proper functionality of both the frontend portal and backend API services.
Key Changes:
- Added HTTP validation script for the cBioPortal dev portal endpoint
- Added API validation script for the cBioPortal dev API endpoint
- Implemented response checks for HTML structure, status codes, and API data format
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| assert.equal(response.statusCode, 200, 'Expected a 200 OK response.'); | ||
| assert.ok(Array.isArray(body), 'Expected response body to be an array.'); | ||
|
|
There was a problem hiding this comment.
Accessing body[0] without checking if the array is empty will throw an error if the API returns an empty array. Add a length check before accessing the first element.
| assert.ok(body.length > 0, 'Expected response array to have at least one element.'); |
| assert.ok(Array.isArray(body), 'Expected response body to be an array.'); | ||
|
|
||
| const firstObj = body[0] |
There was a problem hiding this comment.
The body response from an HTTP request is typically a string that needs to be parsed as JSON before checking if it's an array. The Array.isArray(body) check will always fail for string responses.
| assert.ok(Array.isArray(body), 'Expected response body to be an array.'); | |
| const firstObj = body[0] | |
| let parsedBody; | |
| try { | |
| parsedBody = JSON.parse(body); | |
| } catch (e) { | |
| throw new Error('Failed to parse response body as JSON: ' + e.message); | |
| } | |
| assert.ok(Array.isArray(parsedBody), 'Expected response body to be an array.'); | |
| const firstObj = parsedBody[0] |
|
LGTM! |
Added new frontend and backend validations.