Skip to content

Add unit tests for AiAssistCommand class to ensure functionality and reliability#36

Open
me146 wants to merge 2 commits into1.xfrom
meet/1.x/#24-regression-tests-aiassistcommand
Open

Add unit tests for AiAssistCommand class to ensure functionality and reliability#36
me146 wants to merge 2 commits into1.xfrom
meet/1.x/#24-regression-tests-aiassistcommand

Conversation

@me146
Copy link
Copy Markdown
Collaborator

@me146 me146 commented Nov 18, 2024

Please ensure the following dependencies are added to the project to prevent errors and maintain consistency across all pull requests:

npm install sinon @ckeditor/ckeditor5-core

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.

@me146 me146 requested a review from jjroelofs November 18, 2024 06:20
Copy link
Copy Markdown
Contributor

@jjroelofs jjroelofs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 % 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants