Fix file loading API and WebSocket connection issues #571
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.
This PR addresses two critical issues preventing proper functionality of the CodeceptJS UI:
Issue 1: File Content Loading Fails with 400 Error
When clicking on a test file to view its content, the frontend was receiving a
400 Bad Request
error:Root Cause: The frontend sends a POST request with JSON body
{ path: test.file, line: test.line }
, but the backend API expected the file path inreq.file
parameter instead ofreq.body.path
.Solution:
/api/file
endpoint to read fromreq.body.path
for new frontend requestsreq.file
parametersource
field for frontend consumption while preserving file streaming for legacy usageIssue 2: WebSocket Connection Refused Error
Browser tests couldn't start due to WebSocket connection failures:
Root Cause: The frontend was constructing WebSocket URLs using
window.location.protocol
(e.g.,http:
), but WebSocket connections requirews:
orwss:
protocols.Solution:
src/main.js
to properly converthttp:
→ws:
andhttps:
→wss:
Key Changes
lib/api/get-file.js
: Enhanced to support both JSON body requests and legacy parameter requestslib/api/index.js
: Added JSON body parser to/api/file
endpointsrc/main.js
: Fixed WebSocket URL protocol conversionTesting
These changes ensure that both test file content loading and WebSocket-based browser test execution work correctly.
Fixes #570.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
googlechromelabs.github.io
https://storage.googleapis.com/chrome-for-testing-public/139.0.7258.154/linux64/chrome-headless-shell-linux64.zip
node install.mjs
(http block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.