Skip to content

Add unit tests for AiAssistEditing class to ensure functionality and reliability#35

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

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

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.

…revent unwanted whitespace

test(aiassistediting.ts): add unit tests for AiAssistEditing plugin to ensure functionality and command registration
@me146 me146 requested a review from jjroelofs November 18, 2024 05:36
@me146 me146 changed the title Test Cases to cover AiAssistEditing Add unit tests for AiAssistEditing class to ensure functionality and reliability Nov 18, 2024
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.

I have 4 failures and also the same sinon config file problem as in the other 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/aiassistediting.ts
./tests/aiassistediting.ts 2:18-25
[tsl] ERROR in /Users/jur/www/ckeditor5-ai-assist/tests/aiassistediting.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 2931 ms
18 11 2024 15:03:49.050:INFO [karma-server]: Karma v6.4.4 server started at http://localhost:9876/
18 11 2024 15:03:49.051:INFO [launcher]: Launching browsers CHROME_LOCAL with concurrency unlimited
18 11 2024 15:03:49.054:INFO [launcher]: Starting browser Chrome
18 11 2024 15:03:49.951:INFO [Chrome 130.0.0.0 (Mac OS 10.15.7)]: Connected on socket q5SyjVm5-6TZ9WbqAAAB with id 8853146
  AiAssist
    ✔ should be named
    init()
      ✖ "before each" hook for "should load AiAssist"
      ✖ "after each" hook for "should load AiAssist"
  AiAssistEditing
    ✔ should be loaded
    ✔ should register the aiAssist command
    ✔ should set up enter key handling
    setupEnterKeyHandling()
      ✖ should execute aiAssist command when content starts with /
      ✔ should not execute aiAssist command when content does not start with / and inline-slash is not present
      ✖ should execute aiAssist command when inline-slash is present
  CKEditor5 AiAssist DLL
    ✔ exports AiAssist
    icons
      ✔ exports the "ckeditor" icon

Finished in 3.155 secs / 3.025 secs @ 15:03:53 GMT+0100 (Central European Standard Time)

SUMMARY:
✔ 7 tests completed
✖ 4 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)

  AiAssistEditing
    setupEnterKeyHandling()
      ✖ should execute aiAssist command when content starts with /
        Chrome 130.0.0.0 (Mac OS 10.15.7)
      AssertionError: expected false to be true

      + expected - actual

      -false
      +true
      
    at Context.eval (webpack://@dxpr/ckeditor5-ai-assist/./tests/aiassistediting.ts?:80:102)


      ✖ should execute aiAssist command when inline-slash is present
        Chrome 130.0.0.0 (Mac OS 10.15.7)
      AssertionError: expected false to be true

      + expected - actual

      -false
      +true
      
    at Context.eval (webpack://@dxpr/ckeditor5-ai-assist/./tests/aiassistediting.ts?:125:102)


/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