Skip to content

Add unit tests for for AiAssist plugin initialization and …#32

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

Add unit tests for for AiAssist plugin initialization and …#32
me146 wants to merge 4 commits into1.xfrom
meet/1.x/#24-regression-tests-aiassist

Conversation

@me146
Copy link
Copy Markdown
Collaborator

@me146 me146 commented Nov 13, 2024

we are having dependency issue or something else, not able to figure out as now I'm getting module not found in augmentation.ts priorer it's working absolutely fine, spent a almost 2-3 hrs on it 🙁😓.

…configuration to ensure proper functionality and error handling
@me146 me146 requested a review from jjroelofs November 13, 2024 11:10
@jjroelofs
Copy link
Copy Markdown
Contributor

@me146 I tried running tests on your branch and I did not get "module not found" error, just "Cannot find name" errors. Are you doing something else? Can you provide steps to reproduce?
All I did to test your changes is yarn run test I did not start the server.

(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 9.13 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 9.14 MiB = runtime.js 8.53 KiB commons.js 9.13 MiB tests-entry-point.3893782553.js 1.04 KiB

ERROR in /Users/jur/www/ckeditor5-ai-assist/tests/aiassist.ts
./tests/aiassist.ts 68:5-12
[tsl] ERROR in /Users/jur/www/ckeditor5-ai-assist/tests/aiassist.ts(68,6)
      TS2304: Cannot find name 'Heading'.
 @ ./tmp/tests-entry-point.js 1:0-62

ERROR in /Users/jur/www/ckeditor5-ai-assist/tests/aiassist.ts
./tests/aiassist.ts 69:5-15
[tsl] ERROR in /Users/jur/www/ckeditor5-ai-assist/tests/aiassist.ts(69,6)
      TS2304: Cannot find name 'Essentials'.
 @ ./tmp/tests-entry-point.js 1:0-62

ERROR in /Users/jur/www/ckeditor5-ai-assist/tests/aiassist.ts
./tests/aiassist.ts 138:12-17
[tsl] ERROR in /Users/jur/www/ckeditor5-ai-assist/tests/aiassist.ts(138,13)
      TS18046: 'error' is of type 'unknown'.
 @ ./tmp/tests-entry-point.js 1:0-62

3 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.94.0 compiled with 3 errors in 3564 ms
14 11 2024 11:57:49.319:INFO [karma-server]: Karma v6.4.4 server started at http://localhost:9876/
14 11 2024 11:57:49.320:INFO [launcher]: Launching browsers CHROME_LOCAL with concurrency unlimited
14 11 2024 11:57:49.322:INFO [launcher]: Starting browser Chrome
14 11 2024 11:57:49.955:INFO [Chrome 130.0.0.0 (Mac OS 10.15.7)]: Connected on socket 8SXDAzohQj4bJrmCAAAB with id 82905284
  AiAssist
    ✔ should be named AiAssist
    init()
      ✔ should load AiAssist
      ✔ should add an icon to the toolbar
      ✔ should initialize with default configuration
    AiAssist - Successful Initialization Tests
      ✖ "before each" hook for "should initialize with provided configuration"
      ✖ "after each" hook for "should initialize with provided configuration"
    AiAssist Configuration
      ✔ should throw an error if apiKey is not provided
      ✔ should throw an error if temperature is out of range

Finished in 0.077 secs / 0.004 secs @ 11:57:50 GMT+0100 (Central European Standard Time)

SUMMARY:
✔ 6 tests completed
✖ 2 tests failed

FAILED TESTS:
  AiAssist
    AiAssist - Successful Initialization Tests
      ✖ "before each" hook for "should initialize with provided configuration"
        Chrome 130.0.0.0 (Mac OS 10.15.7)
      ReferenceError: Heading is not defined
          at Context.eval (webpack://@dxpr/ckeditor5-ai-assist/./tests/aiassist.ts?:62:21)

      ✖ "after each" hook for "should initialize with provided configuration"
        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?:88: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 /Users/jur/www/ckeditor5-ai-assist/node_modules/karma/lib/server.js:475:9
    at Server.close (node:net:2316: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 % 

@me146
Copy link
Copy Markdown
Collaborator Author

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 changed the title test(aiassist): enhance tests for AiAssist plugin initialization and … Add unit tests for for AiAssist plugin initialization and … 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.

Thx, now I only have one error due to a test failure, please check it out:

(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 9.24 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 9.25 MiB = runtime.js 8.53 KiB commons.js 9.24 MiB tests-entry-point.3893782553.js 1.04 KiB

ERROR in /Users/jur/www/ckeditor5-ai-assist/tests/aiassist.ts
./tests/aiassist.ts 137:12-17
[tsl] ERROR in /Users/jur/www/ckeditor5-ai-assist/tests/aiassist.ts(137,13)
      TS18046: 'error' is of type 'unknown'.
ts-loader-default_aadc0d91f92e8c5c
 @ ./tmp/tests-entry-point.js 1:0-62

webpack 5.96.1 compiled with 1 error in 3733 ms
18 11 2024 14:33:31.716:INFO [karma-server]: Karma v6.4.4 server started at http://localhost:9876/
18 11 2024 14:33:31.717:INFO [launcher]: Launching browsers CHROME_LOCAL with concurrency unlimited
18 11 2024 14:33:31.720:INFO [launcher]: Starting browser Chrome
18 11 2024 14:33:32.933:INFO [Chrome 130.0.0.0 (Mac OS 10.15.7)]: Connected on socket G0wql6W5EfXD8jZfAAAB with id 42474583
  AiAssist
    ✔ should be named AiAssist
    init()
      ✔ should load AiAssist
      ✔ should add an icon to the toolbar
      ✔ should initialize with default configuration
    AiAssist - Successful Initialization Tests
      ✔ should initialize with provided configuration
    AiAssist Configuration
      ✔ should throw an error if apiKey is not provided
      ✔ should throw an error if temperature is out of range
      ✔ should throw an error if maxTokens is out of range

Finished in 0.107 secs / 0.009 secs @ 14:33:33 GMT+0100 (Central European Standard Time)

SUMMARY:
✔ 8 tests completed
✨  Done in 7.67s.

@jjroelofs
Copy link
Copy Markdown
Contributor

@me146 Please pull latest changes and run yarn install to make sure we are on the same module versions as defined in the yarn.lock file, so that we can be sure the errors are not due to different dependency versions.

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