Add unit tests for AiAssistCommand class to ensure functionality and reliability#36
Open
Add unit tests for AiAssistCommand class to ensure functionality and reliability#36
Conversation
…unctionality and error handling
jjroelofs
requested changes
Nov 18, 2024
Contributor
jjroelofs
left a comment
There was a problem hiding this comment.
please fix below problems which are similar to errors on the other test PR:
(base) jur@jurs-MacBook-Pro ckeditor5-ai-assist % yarn run test
yarn run v1.22.22
warning ../package.json: No license field
$ ckeditor5-package-tools test
Entry file saved in "/Users/jur/www/ckeditor5-ai-assist/tmp/tests-entry-point.js".
START:
Webpack bundling...
asset commons.js 6.39 MiB [emitted] (name: commons) (id hint: commons)
asset runtime.js 8.53 KiB [emitted] (name: runtime)
asset tests-entry-point.3893782553.js 1.04 KiB [emitted] (name: tests-entry-point.3893782553)
Entrypoint tests-entry-point.3893782553 6.4 MiB = runtime.js 8.53 KiB commons.js 6.39 MiB tests-entry-point.3893782553.js 1.04 KiB
ERROR in /Users/jur/www/ckeditor5-ai-assist/tests/aiassistcommand.ts
./tests/aiassistcommand.ts 2:18-25
[tsl] ERROR in /Users/jur/www/ckeditor5-ai-assist/tests/aiassistcommand.ts(2,19)
TS7016: Could not find a declaration file for module 'sinon'. '/Users/jur/www/ckeditor5-ai-assist/node_modules/sinon/pkg/sinon-esm.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/sinon` if it exists or add a new declaration (.d.ts) file containing `declare module 'sinon';`
ts-loader-default_aadc0d91f92e8c5c
@ ./tmp/tests-entry-point.js 2:0-69
webpack 5.96.1 compiled with 1 error in 2794 ms
18 11 2024 15:05:28.253:INFO [karma-server]: Karma v6.4.4 server started at http://localhost:9876/
18 11 2024 15:05:28.254:INFO [launcher]: Launching browsers CHROME_LOCAL with concurrency unlimited
18 11 2024 15:05:28.256:INFO [launcher]: Starting browser Chrome
18 11 2024 15:05:29.070:INFO [Chrome 130.0.0.0 (Mac OS 10.15.7)]: Connected on socket 0cMbN9StjPBGZLPsAAAB with id 76872990
AiAssist
✔ should be named
init()
✖ "before each" hook for "should load AiAssist"
✖ "after each" hook for "should load AiAssist"
AiAssistCommand
constructor()
✔ should create an instance of AiAssistCommand
refresh()
✔ should enable the command
ERROR: 'Error handling slash command:', DOMException{}
execute()
✔ should call aiAssistService with correct parameters
✔ should handle errors gracefully during execution
CKEditor5 AiAssist DLL
✔ exports AiAssist
icons
✔ exports the "ckeditor" icon
Finished in 0.099 secs / 0.013 secs @ 15:05:29 GMT+0100 (Central European Standard Time)
SUMMARY:
✔ 7 tests completed
✖ 2 tests failed
FAILED TESTS:
AiAssist
init()
✖ "before each" hook for "should load AiAssist"
Chrome 130.0.0.0 (Mac OS 10.15.7)
Error: AiAssist: apiKey is required.
at AiAssist.validateConfiguration (webpack://@dxpr/ckeditor5-ai-assist/./src/aiassist.js?:54:19)
at new AiAssist (webpack://@dxpr/ckeditor5-ai-assist/./src/aiassist.js?:44:14)
at eval (webpack://@dxpr/ckeditor5-ai-assist/./node_modules/@ckeditor/ckeditor5-core/src/plugincollection.js?:334:52)
at Array.map (<anonymous>)
at loadPlugins (webpack://@dxpr/ckeditor5-ai-assist/./node_modules/@ckeditor/ckeditor5-core/src/plugincollection.js?:332:39)
at PluginCollection.init (webpack://@dxpr/ckeditor5-ai-assist/./node_modules/@ckeditor/ckeditor5-core/src/plugincollection.js?:161:33)
at ClassicEditor.initPlugins (webpack://@dxpr/ckeditor5-ai-assist/./node_modules/@ckeditor/ckeditor5-core/src/editor/editor.js?:301:29)
at eval (webpack://@dxpr/ckeditor5-ai-assist/./node_modules/@ckeditor/ckeditor5-editor-classic/src/classiceditor.js?:173:28)
at new Promise (<anonymous>)
at ClassicEditor.create (webpack://@dxpr/ckeditor5-ai-assist/./node_modules/@ckeditor/ckeditor5-editor-classic/src/classiceditor.js?:171:16)
✖ "after each" hook for "should load AiAssist"
Chrome 130.0.0.0 (Mac OS 10.15.7)
TypeError: Cannot read properties of undefined (reading 'destroy')
at Context.eval (webpack://@dxpr/ckeditor5-ai-assist/./tests/aiassist.ts?:37:27)
/Users/jur/www/ckeditor5-ai-assist/node_modules/@ckeditor/ckeditor5-package-tools/lib/tasks/test.js:36
reject( new Error( `Karma finished with "${ exitCode }" code.` ) );
^
Error: Karma finished with "1" code.
at /Users/jur/www/ckeditor5-ai-assist/node_modules/@ckeditor/ckeditor5-package-tools/lib/tasks/test.js:36:13
at removeAllListeners (/Users/jur/www/ckeditor5-ai-assist/node_modules/karma/lib/server.js:468:9)
at Server.<anonymous> (/Users/jur/www/ckeditor5-ai-assist/node_modules/karma/lib/server.js:475:9)
at Object.onceWrapper (node:events:633:28)
at Server.emit (node:events:531:35)
at Server.emit (node:domain:488:12)
at emitCloseNT (node:net:2376:8)
at process.processTicksAndRejections (node:internal/process/task_queues:89:21)
Node.js v22.9.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
(base) jur@jurs-MacBook-Pro ckeditor5-ai-assist %
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
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.
Please ensure the following dependencies are added to the project to prevent errors and maintain consistency across all pull requests:
This is a common requirement, and including these dependencies in the project setup will avoid the need to include them individually in each pull request.