Skip to content

Conversation

@JorchCortez
Copy link
Contributor

This pull request introduces comprehensive automated tests for several key modules and adds a GitHub Actions workflow for continuous integration. The most important changes are the addition of test suites for CMSFilter, CMSSelect, CookieConsent, and CountUp, which verify their core behaviors and edge cases, and the setup of a workflow to run these tests and report coverage.

Automated Testing Enhancements:

  • Added __tests__/CMSFilter.test.js with extensive tests for filtering, sorting, pagination, tag management, and advanced filtering in the CMSFilter module.
  • Added __tests__/CMSSelect.test.js to verify single/multiple select population, custom value handling, error logging, and fallback logic in the CMSSelect module.
  • Added __tests__/CookieConsent.test.js to test banner display, cookie setting, script injection, and consent management in the CookieConsent module.
  • Added __tests__/CountUp.test.js to test counter initialization, incrementing logic, prefix/suffix formatting, custom step handling, and edge cases in the CountUp module.

Continuous Integration Setup:

  • Added .github/workflows/tests.yml workflow to run tests on push and pull requests, install dependencies, execute Jest tests with coverage, upload coverage artifacts, and summarize coverage in job output.

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.
Added a comprehensive Jest test suite for FormCheck covering initialization, validation, error handling, reset, and various input types. Updated FormCheck.js to support CommonJS exports for test environments without affecting browser usage.
Adds a polyfill for HTMLElement.innerText in jsdom to mirror textContent behavior, ensuring compatibility with code that relies on innerText in Jest tests.
Added comprehensive Jest tests for CMSFilter functionality in __tests__/CMSFilter.test.js. Updated CMSFilter.js to export CMSFilter and InitializeCMSFilter for test environments, and fixed range filtering to use normalized dataset keys.
Added CommonJS export to FormatNumbers.js for testability. Introduced comprehensive Jest tests for NumberFormatter and InitializeFormatNumbers covering formatting styles, error handling, and multiple element scenarios.
Introduces a GitHub Actions workflow to run tests on push and pull request events. The workflow sets up Node.js, installs dependencies, runs Jest tests with coverage, uploads coverage artifacts, and appends a coverage summary to the job summary.
Exports CMSSelect and InitializeCMSSelect for CommonJS environments to support testing and bundlers. Adds comprehensive Jest tests for CMSSelect functionality and updates documentation to describe programmatic initialization.
Copilot AI review requested due to automatic review settings November 10, 2025 01:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive test coverage for multiple JavaScript modules in the codebase by implementing Jest-based unit tests. The changes enable testing in a Node.js/jsdom environment while maintaining browser compatibility.

  • Adds test files for 6 modules: FormatNumbers, FormCheck, CountUp, CookieConsent, CMSSelect, and CMSFilter
  • Implements CommonJS exports in all tested modules to enable importing in test environments
  • Adds innerText polyfill in jest.setup.js for jsdom compatibility
  • Creates GitHub Actions workflow for automated testing with coverage reporting
  • Updates documentation for programmatic usage

Reviewed Changes

Copilot reviewed 9 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
jest.setup.js Adds innerText polyfill for jsdom to mirror textContent behavior
docs/WebflowOnly/CMSSelect.md Documents programmatic initialization option for testing/bundlers
tests/FormatNumbers.test.js Comprehensive tests for number formatting with various styles and locales
tests/FormCheck.test.js Tests form validation, error handling, and submission logic
tests/CountUp.test.js Tests counter animation with custom steps, speeds, and targets
tests/CookieConsent.test.js Tests cookie consent banner, category management, and script injection
tests/CMSSelect.test.js Tests select element population from CMS data sources
tests/CMSFilter.test.js Tests filtering, sorting, pagination, and advanced filtering features
Dist/WebflowOnly/CMSSelect.js Adds CommonJS exports for testing without affecting browser usage
Dist/WebflowOnly/CMSFilter.js Adds CommonJS exports and fixes range filtering dataset access
Dist/Functional/FormatNumbers.js Adds CommonJS exports wrapped in try-catch
Dist/Functional/FormCheck.js Adds CommonJS exports with aliased initializer function
Dist/Functional/CountUp.js Adds CommonJS exports wrapped in try-catch
Dist/Functional/CookieConsent.js Adds CommonJS exports for test environment compatibility
.github/workflows/tests.yml Creates CI workflow for running tests with coverage reporting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JorchCortez JorchCortez merged commit 4a71fd4 into main Nov 10, 2025
6 checks passed
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