fix: resolve aidebugger.test.js CI failures#7442
Conversation
|
🧪 Jest Test Results ✅ All Jest tests passed! This PR is ready to merge. Coverage: Statements: 48.3% | Branches: 39.6% | Functions: 53.07% | Lines: 48.72% |
mahesh-09-12
left a comment
There was a problem hiding this comment.
this PR now feels a bit broader than just fixing the CI failure, since it also adds quite a bit of aidebugger test coverage beyond the original failing scenario
There was a problem hiding this comment.
these aidebugger test additions seem to already exist from the recently merged CI fix PR (#7403), so could you rebase onto latest master and drop the already-merged parts from this diff?
There was a problem hiding this comment.
Thanks for the feedback @mahesh-09-12!
I've rebased onto the latest master and dropped the two _sendMessage tests that were already merged via #7403 ("shows consent banner and does not send message if consent not given" and "sends message and clears input").
All tests pass locally. Let me know if you'd like any further changes!
There was a problem hiding this comment.
@riyacore404 oh, my mistake. Before rebasing onto the latest master, it made sense to remove these since they were duplicated by the earlier aidebugger fix work. After the rebase though, removing them here would actually remove tests that are already present on master. Sorry for the confusion and the earlier suggestion.
There was a problem hiding this comment.
No worries, thanks for clarifying! I’ve reverted my previous change and restored the tests so the PR is back in sync. 👍
There was a problem hiding this comment.
Thanks for your patience and for restoring the tests. My concern is resolved now.
0c3c33d to
01b5475
Compare
|
🧪 Jest Test Results ✅ All Jest tests passed! This PR is ready to merge. Coverage: Statements: 48.34% | Branches: 39.68% | Functions: 53.12% | Lines: 48.75% |
01b5475 to
8f9bb64
Compare
|
🧪 Jest Test Results ✅ All Jest tests passed! This PR is ready to merge. Coverage: Statements: 48.36% | Branches: 39.69% | Functions: 53.12% | Lines: 48.77% |
PR Category
Summary
Resolves #7433 — the Jest CI pipeline was failing due to three issues in the AI Debugger widget.
Changes
jest.config.js
Added
testEnvironmentOptions: { url: "http://localhost/" }.jsdom's default URL (
about:blank) giveswindow.location.hostname = "", whichthe
BACKEND_CONFIGIIFE didn't recognise, firing aconsole.warnand settingBASE_URL = nullon every test run.js/widgets/aidebugger.js
Added an early-return guard in
_hideTypingIndicatorwhenthis.chatLogis null.The widget's
onclosehandler calls_hideTypingIndicator()beforeinit()hasrun
_createLayout(), sochatLogcan be null — crashing with a TypeError.js/widgets/tests/aidebugger.test.js
Added 19 new tests covering all previously untested code paths:
_consentGiveninitial state_addWelcomeMessage_showConsentBanner(accept + decline button flows)_loadProjectAndInitialize(success, export-throws fallback, bad-JSON non-fatal)_initializeBackendWithProject(fetch success, fetch fail, missing .response)_sendToBackend(success, network error, non-ok HTTP)_exportChatwith a non-empty history (download triggered)_exportChatwith prepareExport throwing (graceful fallback)_hideTypingIndicatorwith null chatLog (regression guard)Test Results
Checklist
npm test)npm run lint)npx prettier --check .)