-
Notifications
You must be signed in to change notification settings - Fork 2
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
objectDifference.ts - enhancements and fixes; Unit test - Jest; #36
objectDifference.ts - enhancements and fixes; Unit test - Jest; #36
Conversation
objectDifference.ts - support for change resulting in empty link/block list; objectDifference.ts - fix bug from version 2.4.5 (isArray called with origObj instead of value); Add unit tests for objectDifference.ts; Add unit testing framework - jest; Update typescript to 5.1.6;
I am still noticing some undesired behavior in browser so further updates might be required (to the FieldExtension.tsx) |
Updated script triggering mechanism. For each modified flattened path the code will be checked agains presence of the oldest ancestor from the modified path up to the level where field holding the script resides.
|
@gswierczynski Thanks for the extensive PR. I like the change in the object differences function, but I see some code style changes (like removed spaces or single/double quotes https://github.com/voorhoede/datocms-plugin-computed-fields/pull/36/files#diff-4ac47e410f008329ee7cbc652eb14e4fa23c06c36c411278561ac51e8108f225R1). Can you make sure that stays consistent? I think we don't want to add unit testing in this PR. Since we have a lot of other plugins we want to keep them consistent. Next to a github action that tests the code we also want it to be implemented consistent to other plugins (like we did in this plugin: https://github.com/voorhoede/datocms-plugin-translate-fields/tree/main). Is it okay if we cherry pick some test code and implement that in a different PR? Next to that (just to have a small and clean PR) updating any packages I want to do in a seperate PR. |
@velomovies Thank you for taking a look. Totally understandable. On all points. This Unit Test approach was just the first solution I found that helped me tinker with the implementation. Code style changes sponsored by WebStorm - there's not much of it. I can adjust by hand. By all means pick and choose from the tests into another PR with proper approach. I will remove tests, style changes and package upgrade in this PR. |
Removal of unit tests; Removal of typescript upgrade; Removal of package number update; Revert package-lock.json;
@velomovies Cleaned up. |
Perfect, thank you! I will do a last check and merge it |
This is sufficient for now. When we add the testing library, I think we also want to have a seperate function for these lines: https://github.com/voorhoede/datocms-plugin-computed-fields/pull/36/files#diff-4ac47e410f008329ee7cbc652eb14e4fa23c06c36c411278561ac51e8108f225R54 Commenting this so we can reference it ;) Thanks @gswierczynski. This will be merged and available in version |
objectDifference.ts - support for removal from link/block lists;
objectDifference.ts - support for change resulting in empty link/block list;
objectDifference.ts - fix bug from version 2.4.5 (isArray called with origObj instead of value);
Add unit tests for objectDifference.ts;
Add unit testing framework - jest;
Update typescript to 5.1.6;
Addresses #35 among other things.
Version 2.4.5 introduced a bug that is causing script not to fire in multiple situations (isArray called with origObj instead of value).
Here's an update to objectDifferences.ts that addresses that.
I rewrote the function to additionally add support for moments when elements are being deleted from list (be that blocks or ref links).
Added Jest Unit Test framework and wrote a couple of unit tests for the difference function.
I am not a java script developer so I might not be following some insider best practices.
Please let me know if something should be corrected or adjusted.