Skip to content

[Feature]: Add Test Infrastructure for Core Carousel Plugin#19

Merged
theMasudRana merged 5 commits intomainfrom
feat/add-test-for-plugin
Feb 5, 2026
Merged

[Feature]: Add Test Infrastructure for Core Carousel Plugin#19
theMasudRana merged 5 commits intomainfrom
feat/add-test-for-plugin

Conversation

@theMasudRana
Copy link
Copy Markdown
Collaborator

@theMasudRana theMasudRana commented Feb 5, 2026

Add Test Infrastructure for Core Carousel Plugin

Summary

This PR adds comprehensive JavaScript and PHP testing infrastructure along with CI/CD integration for automated test execution.

Changes

Test Infrastructure

  • Jest Configuration (jest.config.js): Custom config extending @wordpress/scripts with coverage thresholds, module aliases, and test setup
  • PHPUnit Configuration (phpunit.xml.dist): PHP unit test configuration with Brain\Monkey integration
  • Test Setup Files: Mocks for WordPress Interactivity API, Embla Carousel, and other dependencies

JavaScript Tests (86 tests)

  • view.test.ts: Tests for carousel store registration, state getters, actions (scrollPrev, scrollNext, onDotClick), callbacks, and error handling
  • types.test.ts: Type validation tests for CarouselAttributes and CarouselContext

PHP Tests (14 tests)

  • PluginTest.php: Tests for block category registration, block registration, pattern category, and block patterns
  • SingletonTest.php: Tests for the Singleton trait behavior

Dependencies

  • Added Jest testing dependencies to package.json
  • Added PHPUnit, Brain\Monkey, and Yoast PHPUnit Polyfills to composer.json

Screenshot

image image

Testing

# Run JavaScript tests
npm run test:js

# Run PHP tests
composer test

- Add Jest configuration (jest.config.js)
- Add PHPUnit configuration (phpunit.xml.dist)
- Update package.json with test scripts and devDependencies
- Update composer.json with PHPUnit, Brain\Monkey dependencies
- Add test setup files and mocks (tests/js/, tests/php/)
- Add JS tests for view.ts (86 tests)
- Add JS tests for types.ts validation
- Add PHP tests for Plugin class
- Add PHP tests for Singleton trait
Copilot AI review requested due to automatic review settings February 5, 2026 11:27
Copy link
Copy Markdown
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 establishes comprehensive testing infrastructure for the Core Carousel plugin, adding both JavaScript and PHP unit tests along with CI/CD automation.

Changes:

  • Added Jest-based JavaScript testing with 86 tests covering carousel store, state management, actions, and type definitions
  • Added PHPUnit-based PHP testing with 14 tests covering plugin initialization, singleton pattern, and block registration
  • Integrated GitHub Actions workflow for automated testing on push and pull requests

Reviewed changes

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

Show a summary per file
File Description
jest.config.js Jest configuration extending @wordpress/scripts with coverage thresholds and module aliases
tests/js/setup.ts Global test setup with mocks for WordPress and Embla Carousel dependencies
tests/js/mocks/wordpress-interactivity.ts Mock implementation of WordPress Interactivity API
src/blocks/carousel/tests/view.test.ts Comprehensive tests for carousel frontend logic (86 tests)
src/blocks/carousel/tests/types.test.ts Type validation tests for TypeScript definitions
tests/js/tsconfig.json TypeScript configuration for Jest tests
phpunit.xml.dist PHPUnit configuration for PHP unit tests
tests/phpstan/constants.php PHPStan bootstrap constants for static analysis
tests/php/bootstrap.php PHPUnit bootstrap with Brain\Monkey setup
tests/php/Unit/UnitTestCase.php Base test case class for unit tests
tests/php/Unit/Traits/SingletonTest.php Tests for Singleton trait behavior
tests/php/Unit/PluginTest.php Tests for Plugin class covering block/pattern registration
package.json Added Jest testing dependencies and test scripts
composer.json Added PHPUnit, Brain\Monkey, and Yoast PHPUnit Polyfills dependencies
.github/workflows/tests.yml CI/CD workflow for JavaScript tests, PHP tests, and build verification
core-carousel.php Updated plugin headers with GitHub URL and version requirements

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

@theMasudRana theMasudRana requested a review from danish17 February 5, 2026 11:49
@theMasudRana theMasudRana self-assigned this Feb 5, 2026
@theMasudRana theMasudRana merged commit 808d6df into main Feb 5, 2026
4 checks passed
theMasudRana added a commit that referenced this pull request Feb 5, 2026
theMasudRana added a commit that referenced this pull request Feb 5, 2026
Revert "Merge pull request #19 from rtCamp/feat/add-test-for-plugin"
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.

3 participants