Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add js tests #75

Merged
merged 1 commit into from
Jul 3, 2023
Merged

Add js tests #75

merged 1 commit into from
Jul 3, 2023

Conversation

rahulsom
Copy link

@rahulsom rahulsom commented Jun 22, 2023

This extracts some code out to Util.ts and tests it using jest in Util.test.ts. unochoice.js has been renamed to UnoChoice.es6 so we can synthesize UnoChoice.js.

Testing done

This PR adds tests on top of #74

Submitter checklist

Preview Give feedback

@rahulsom rahulsom force-pushed the add-js-tests branch 3 times, most recently from 7753820 to 072e2f6 Compare June 22, 2023 22:35
@rahulsom rahulsom force-pushed the add-js-tests branch 2 times, most recently from 7aa5787 to 660a418 Compare June 25, 2023 04:06
Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

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

Just some random comments, didn't have time to test it yet, sorry 👋 Thanks!

"jquery": "^3.7.0",
"@types/jquery": "^3.5.16"
},
"dependencies": {
Copy link
Member

Choose a reason for hiding this comment

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

It will be nice if someday Jenkins move to having a separate UI layer, so that we can declare dependencies to plug-ins and other libs here (like the JQuery one). Although that's probably hard with stapler and all the plugin tooling.

package.json Outdated Show resolved Hide resolved
pom.xml Show resolved Hide resolved
.mvn_exec_yarn Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
@rahulsom rahulsom force-pushed the add-js-tests branch 5 times, most recently from 785b153 to 3a10e74 Compare June 26, 2023 17:59
This extracts some code out to `Util.ts` and tests it using jest in `Util.test.ts`.
`unochoice.js` has been renamed to `UnoChoice.es6` so we can synthesize `UnoChoice.js`.
@rahulsom rahulsom requested a review from kinow June 27, 2023 21:34
@kinow
Copy link
Member

kinow commented Jun 27, 2023

Ready for review @rahulsom ?

@rahulsom
Copy link
Author

Yeah.

Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

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

Tested the build and some example projects, and everything worked fine 👏 Just pending to read the code changes and understand how it's supposed to work now 🙂

@@ -8,6 +8,7 @@
4. [#71](https://github.com/jenkinsci/active-choices-plugin/pull/71): test: Add end-to-end tests for UI behavior, thanks to @rahulsom
5. [#74](https://github.com/jenkinsci/active-choices-plugin/pull/74): refactor: Extract helper functions and drop table-layout support, thanks @rahulsom
6. [#78](https://github.com/jenkinsci/active-choices-plugin/pull/78): Refresh plugin for June 2023, thanks @basil
7. [#75](https://github.com/jenkinsci/active-choices-plugin/pull/75) Add test for pure javascript code, thanks @rahulsom
Copy link
Member

Choose a reason for hiding this comment

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

❤️ thank you!

Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

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

A few random comments, but nothing major. My main concern was having any build files in the source directories, but that's not an issue here! So it's looking really good!

I abandoned webpack in the Vue projects I use at $work and Apache, and have been using Vite/vitest/etc. But webpack + jest looks fast enough, so no need to bother with that.

Thanks @rahulsom !

@@ -965,3 +829,4 @@ var UnoChoice = UnoChoice || ($ => {
instance.cascadeParameters = cascadeParameters;
return instance;
})(jQuery3);
window.UnoChoice = UnoChoice;
Copy link
Member

Choose a reason for hiding this comment

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

Isn't there a way to use webpack to avoid polluting window? Like merging/combining the files, maybe minifying too (we already have the source map anyway).

Copy link
Author

Choose a reason for hiding this comment

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

We need to call the functions from the jelly files. So it needs to be exposed at the moment. I'm guessing if there's a way to have the module search for components on the page and decide to run the code, we can avoid polluting window.
The way it's written, this behavior is mimicking what we had before.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough 👍 I think you've answered everything, LGTM

Copy link
Member

Choose a reason for hiding this comment

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

This new module looks perfect! 🙆‍♂️ !

tsconfig.json Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Great tests, and run really fast!

Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

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

💥

@kinow kinow merged commit 83a0e40 into jenkinsci:master Jul 3, 2023
@kinow
Copy link
Member

kinow commented Jul 3, 2023

Thank you @rahulsom 🙇

@rahulsom rahulsom deleted the add-js-tests branch July 4, 2023 20:45
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