Conversation
Develop - > Main
Signed-off-by: Jorge C. <jacortez_94@hotmail.com>
Update monthly hits badge in README
Signed-off-by: Jorge C. <jacortez_94@hotmail.com>
Fix error handling for undefined platform in ShareLink
Added a link to follow development and news about WebTricks. Signed-off-by: Jorge C. <jacortez_94@hotmail.com>
Update README with development follow link
Created a .gitignore file to prevent node_modules directory from being tracked by git.
Improves copy-to-clipboard feedback by supporting external HTML templates, custom success/error classes, and configurable timeouts. Refactors UI update logic for copy actions, adds screen reader support, and enables module export for testing environments. Also updates LinkedIn share URL to include title.
Introduces a workflow to run tests on pull requests targeting the Develop branch. The workflow sets up Node.js, installs dependencies, and executes tests using npm.
Introduces comprehensive Jest tests for the ShareLink module, covering initialization, clipboard copy success/failure, and fallback behavior. Adds Jest and jsdom environment dependencies for testing.
ShareLink now supports a 'wt-share-copytemplate' attribute to select a specific template for the copy message. Templates are cached and removed from the DOM after use to improve performance. Added a test to verify per-element template selection.
fix #57 ShareLink- Copy Feedback + Clipboard Fallback Enhancement
Added CommonJS export support to CopyToClipboard, Marquee, and ReadTime modules for testability. Introduced comprehensive Jest test suites for each module to verify initialization, behavior, and edge cases in a jsdom environment.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Jorge C. <jacortez_94@hotmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Jorge C. <jacortez_94@hotmail.com>
Added safety guards to Marquee's fillContainer to prevent infinite loops when element sizes cannot be measured. Updated tests to proactively stop marquee intervals and drain timers, and added a global Jest setup file to increase timeouts and polyfill animation frame methods for jsdom. Configured Jest to use the setup file and increased default test timeout.
…deRaccoons/WebTricks into CopyToClipboard-unit-tests
Add CommonJS exports and tests for functional modules
Added a Jest test suite for CookieConsent covering banner display, event wiring, cookie setting, script injection, and consent management. Updated CookieConsent.js to support module exports for test environments.
Added Jest tests for CountUp functionality, including initialization, counting logic, custom step, prefix/suffix, and edge cases. Updated CountUp.js to export CountUp and InitializeCountUp for test environments without affecting browser usage.
Removed GitHub License badge from README. Signed-off-by: Jorge C. <jacortez_94@hotmail.com>
Removed the ShareLink Tests job and added coverage summary reporting. Signed-off-by: Jorge C. <jacortez_94@hotmail.com>
Updated version and description fields, modified test script to include coverage options, and added collectCoverageFrom configuration. Signed-off-by: Jorge C. <jacortez_94@hotmail.com>
…element="empty" flag is set
…l-max-elements Configurable Empty State Threshold for CMSFilter
…al-max-elements Adds optional parameter for maximum elements displayed when wt-cms-element="empty"
…n-XvPAS_0b61 docs(contributor): contributors readme action update
…slider Improvement/simple range slider
There was a problem hiding this comment.
Pull request overview
This PR introduces a Jest-based test/CI setup for the WebTricks distribution scripts, adds a new “RangeSliderSimple” module + documentation, and updates several existing Dist modules and docs (including CMSFilter enhancements and README contributor automation).
Changes:
- Add Node/Jest test infrastructure, CI workflow, and a suite of jsdom-based unit tests for multiple Dist modules.
- Add
RangeSliderSimple(native-thumb dual range slider) with documentation, and update RangeSlider docs/implementation to share core helpers and improve numeric handling. - Enhance/adjust multiple existing Dist modules (e.g., CMSFilter empty-state threshold, CMSSelect text extraction, ShareLink copy UX, Marquee infinite-loop guard) and refresh documentation/README content.
Reviewed changes
Copilot reviewed 35 out of 49 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Adds Jest configuration and dev dependencies for running unit tests/coverage. |
| jest.setup.js | Global Jest setup utilities/polyfills (currently not wired into Jest config). |
| docs/WebflowOnly/TabsSlider.md | Doc formatting cleanup (spacing / code fence alignment). |
| docs/WebflowOnly/RenderStatic.md | Doc formatting cleanup (spacing / code fence alignment). |
| docs/WebflowOnly/MirrorClick.md | Doc formatting cleanup (spacing / list/code formatting). |
| docs/WebflowOnly/HideContainer.md | Doc formatting cleanup (spacing / list formatting). |
| docs/WebflowOnly/CMSSelect.md | Doc updates + adds programmatic initialization example for tests/bundlers. |
| docs/WebflowOnly/CMSFilter.md | Doc updates, including new wt-cmsfilter-empty-max behavior and examples. |
| docs/Functional/ShareLink.md | Doc formatting cleanup (spacing / list formatting). |
| docs/Functional/ReadTime.md | Doc formatting cleanup (spacing / list formatting). |
| docs/Functional/RangeSliderSimple.md | New documentation for the new RangeSliderSimple module. |
| docs/Functional/RangeSlider.md | Doc updates and cross-link to RangeSliderSimple, updated CDN guidance. |
| docs/Functional/Marquee.md | Doc formatting cleanup (spacing / list formatting). |
| docs/Functional/FormatNumbers.md | Doc formatting cleanup (spacing / list formatting). |
| docs/Functional/FormCheck.md | Doc formatting cleanup (spacing / list formatting). |
| docs/Functional/DateCountDown.md | Doc formatting cleanup (spacing / list formatting). |
| docs/Functional/CountUp.md | Doc formatting cleanup (spacing / list formatting). |
| docs/Functional/CopyToClipboard.md | Doc formatting cleanup (spacing / list formatting). |
| docs/Functional/CookieConsent.md | Doc formatting cleanup (spacing / list formatting). |
| tests/ShareLink.test.js | Adds unit tests for ShareLink initialization + copy behavior. |
| tests/ReadTime.test.js | Adds unit tests for ReadTime output and edge cases. |
| tests/RangeSliderSimple.test.js | Adds unit tests validating RangeSliderSimple constraints and API. |
| tests/RangeSlider.test.js | Adds unit tests validating RangeSlider constraints with decimals/integers. |
| tests/Marquee.test.js | Adds unit tests for Marquee cloning/scrolling/resize behavior. |
| tests/FormatNumbers.test.js | Adds unit tests for Intl-based number formatting and error paths. |
| tests/FormCheck.test.js | Adds unit tests covering validation + submission/reset behaviors. |
| tests/CountUp.test.js | Adds unit tests for counter behavior and step handling. |
| tests/CopyToClipboard.test.js | Adds unit tests for clipboard + UI behavior and missing-target behavior. |
| tests/CookieConsent.test.js | Adds unit tests for consent flows and script injection behavior. |
| tests/CMSSelect.test.js | Adds unit tests for CMSSelect option generation and error handling. |
| tests/CMSFilter.test.js | Adds unit tests for CMSFilter filtering, tags, sorting, and empty-max logic. |
| README.md | Updates badges/content, adds range-slider guidance, and adds contributors section scaffold. |
| Dist/WebflowOnly/CMSSelect.js | Improves option text extraction and exports CommonJS entry points for tests. |
| Dist/WebflowOnly/CMSFilter.js | Adds empty-max handling, search caching, range defaults, and CommonJS exports. |
| Dist/Functional/ShareLink.js | Improves URL encoding, adds copy UX/features, template caching, and CommonJS exports. |
| Dist/Functional/ReadTime.js | Adds CommonJS exports for tests/bundlers. |
| Dist/Functional/RangeSliderSimple.js | New distribution script implementing native-thumb dual-handle slider. |
| Dist/Functional/RangeSlider.js | Refactors to shared helpers, improves numeric handling, adds CommonJS exports. |
| Dist/Functional/Marquee.js | Adds cloning loop safety guards and CommonJS exports. |
| Dist/Functional/FormatNumbers.js | Adds CommonJS exports. |
| Dist/Functional/FormCheck.js | Adds CommonJS exports. |
| Dist/Functional/CountUp.js | Adds CommonJS exports. |
| Dist/Functional/CopyToClipboard.js | Hardens missing-target handling and adds CommonJS exports. |
| Dist/Functional/CookieConsent.js | Adds CommonJS exports. |
| CONTRIBUTING.md | Documents that README contributors list is auto-updated via GitHub Actions. |
| .gitignore | Ignores node_modules, coverage, and editor settings. |
| .github/workflows/update-contributors.yml | Adds workflow to auto-update README contributors section. |
| .github/workflows/tests.yml | Adds CI workflow to run Jest tests with coverage reporting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| </p> | ||
| <sub> | ||
| WebTricks might have been started as a personal project, but I'm a believer that a project for the comunity by the comunity can offer way more value than any single dev could provide so feel free to contribute to this project and use any solution here. | ||
| WebTricks might have been started as a personal project, but I'm a believer that a project for the comunity by the comunity can offer way more value than any single dev could provide so feel free to contribute to this project and use any solution here. <br> |
There was a problem hiding this comment.
Typo: "comunity" should be "community".
| WebTricks might have been started as a personal project, but I'm a believer that a project for the comunity by the comunity can offer way more value than any single dev could provide so feel free to contribute to this project and use any solution here. <br> | |
| WebTricks might have been started as a personal project, but I'm a believer that a project for the community by the community can offer way more value than any single dev could provide so feel free to contribute to this project and use any solution here. <br> |
| </a> | ||
| </td> | ||
| </tr> | ||
| <tbody> |
There was a problem hiding this comment.
The contributors table has an invalid HTML structure: <tbody> is opened twice and never closed (line 179 should be </tbody>). This can break rendering in some Markdown/HTML parsers.
| <tbody> | |
| </tbody> |
| "type": "module", | ||
| "scripts": { | ||
| "test": "jest --runInBand --coverage --coverageReporters=text-summary --coverageReporters=lcov --coverageReporters=json-summary" | ||
| }, |
There was a problem hiding this comment.
"type": "module" will cause Node/Jest to treat .js files (including tests) as ESM. The added tests use CommonJS require(...), and the Dist scripts expose CommonJS module.exports, so this setting is likely to break the test run with require is not defined / ERR_REQUIRE_ESM. Either remove the type field (defaulting to CommonJS) or migrate tests + Jest config to ESM and export the modules accordingly.
| "jest": { | ||
| "testEnvironment": "jsdom", | ||
| "collectCoverageFrom": [ | ||
| "**/*.js", |
There was a problem hiding this comment.
jest.setup.js is added but not referenced by Jest config, so the global setup (timeout, timers reset, polyfills) never runs. Consider wiring it via jest.setupFilesAfterEnv (or setupFiles) or removing the unused setup file to avoid drift/duplicate per-test polyfills.
| "collectCoverageFrom": [ | ||
| "**/*.js", | ||
| "!**/node_modules/**", | ||
| "!**/coverage/**", | ||
| "!jest.config.js" | ||
| ] |
There was a problem hiding this comment.
collectCoverageFrom: ["**/*.js", ...] will include __tests__/** and docs/** in coverage collection, which can significantly slow coverage runs and skew results. Consider excluding those paths (e.g. !**/__tests__/**, !**/docs/**) so coverage reflects executable library code.
| this.filterForm = document.querySelector( | ||
| '[wt-cmsfilter-element="filter-form"]', | ||
| ); | ||
| this.listElement = document.querySelector('[wt-cmsfilter-element="list"]'); |
There was a problem hiding this comment.
The constructor dereferences this.filterForm/this.listElement without checking they exist (e.g. this.filterForm.querySelectorAll(...), this.listElement.getAttribute(...)). If the CMSFilter script is included on a page without the required markup, it will throw during initialization and can break other scripts. Consider adding an early guard in InitializeCMSFilter (or the constructor) that logs an error and returns when required elements are missing.
| this.listElement = document.querySelector('[wt-cmsfilter-element="list"]'); | |
| this.listElement = document.querySelector('[wt-cmsfilter-element="list"]'); | |
| // Guard against missing required elements to avoid runtime errors | |
| if (!this.filterForm || !this.listElement) { | |
| if (typeof console !== "undefined" && console.error) { | |
| console.error( | |
| 'CMSFilter: Required elements not found. Expected [wt-cmsfilter-element="filter-form"] and [wt-cmsfilter-element="list"].', | |
| ); | |
| } | |
| return; | |
| } |
| console.log( | ||
| `Configured range slider for ${category}: min=${this.dataRanges[datasetCategory].min}, max=${this.dataRanges[datasetCategory].max}`, | ||
| ); |
There was a problem hiding this comment.
This console.log(...) runs for every configured range slider and will spam the console on production sites. Consider removing it or gating it behind an explicit debug flag (e.g. an attribute) so normal usage stays quiet.
| console.log( | |
| `Configured range slider for ${category}: min=${this.dataRanges[datasetCategory].min}, max=${this.dataRanges[datasetCategory].max}`, | |
| ); | |
| // Only log configuration details when explicit debug flag is present | |
| if (slider.hasAttribute("wt-rangeslider-debug")) { | |
| console.log( | |
| `Configured range slider for ${category}: min=${this.dataRanges[datasetCategory].min}, max=${this.dataRanges[datasetCategory].max}`, | |
| ); | |
| } |
New Feature: [Feature Title]
Description
Provide a brief summary of the new feature added to an existing script. Highlight what enhancement it brings or the new functionality introduced.
Related Issues
Fixes #123).Script Details
Changes Made
Features
This PR closes NONE
Checklist
developbranch.Additional Notes
Add any extra details or comments for reviewers.