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

tests: Add missing tests #29

Merged
merged 13 commits into from
Nov 26, 2024
Merged

tests: Add missing tests #29

merged 13 commits into from
Nov 26, 2024

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented Nov 26, 2024

Summary by Sourcery

Add missing tests for plugin actions and HTML sanitization, and introduce Jest for JavaScript testing. Update package.json with Jest dependencies and configure GitHub Actions to run tests and upload coverage reports.

New Features:

  • Introduce Jest testing framework with configurations for running tests, watching changes, and generating coverage reports.
  • Add new JavaScript tests for CMS editor functionalities, including initialization, destruction, and plugin form handling.

Enhancements:

  • Refactor test strings to use consistent double quotes for better readability and consistency.

Build:

  • Update package.json to include Jest and related dependencies for testing.

CI:

  • Modify GitHub Actions workflow to include running Jest tests and uploading coverage reports to Codecov.

Tests:

  • Add missing tests for plugin actions and HTML sanitization, ensuring comprehensive coverage of existing functionalities.
  • Introduce tests for dynamic attributes in HTML, verifying correct attribute setting and error handling.

sourcery-ai bot and others added 9 commits November 20, 2024 14:22
Set up a modern JavaScript testing framework using Jest, integrated with the existing webpack build system. Configure Babel for modern JavaScript support and establish a test file structure and conventions. Update the package.json to include Jest dependencies and scripts for running tests, watching tests, and generating coverage reports. Set up a continuous integration pipeline to run JavaScript tests alongside existing Python tests.

New Features:
- Introduce a modern JavaScript testing framework using Jest, integrated with the existing webpack build system.

Enhancements:
- Configure Babel for modern JavaScript support with a new Babel configuration file.

CI:
- Set up a continuous integration pipeline to run JavaScript tests alongside existing Python tests.

Tests:
- Establish a test file structure and conventions for JavaScript tests, including an example test file to verify the setup.
- Configure test coverage reporting for JavaScript code.

Resolves #27
Copy link
Contributor

sourcery-ai bot commented Nov 26, 2024

Reviewer's Guide by Sourcery

This pull request adds missing tests to the project, focusing on JavaScript unit tests for the CMS editor functionality and improving test coverage. The changes include setting up Jest testing infrastructure, adding new test files, and making minor code style improvements to existing Python tests.

Class diagram for new test classes

classDiagram
    class TestGetChildPluginCandidates {
        +test_get_child_plugin_candidates_whitelist()
        +test_get_child_plugin_candidates_blacklist()
        +test_get_child_plugin_candidates_no_whitelist_blacklist()
    }
    class DynamicAttributesTestCase {
        +test_dynamic_href_sets_correct_attribute()
        +test_dynamic_src_sets_correct_attribute()
        +test_render_dynamic_attributes_changes_html()
        +test_render_dynamic_attributes_fails()
        +test_render_dynamic_attributes_handles_no_dynamic_attributes()
    }
    class DjangoCMSPictureIntegrationTestCase {
        +setUp()
        +test_extract_images()
    }
    class HtmlSanitizerAdditionalProtocolsTests {
        +test_default_tag_escaping()
        +test_custom_tag_enabled()
        +test_default_attribute_escaping()
        +test_custom_attribute_enabled()
        +test_default_protocol_escaping()
        +test_custom_protocol_enabled()
        +test_clean_html_with_sanitize_enabled()
        +test_invalid_dynamic_link()
    }
Loading

File-Level Changes

Change Details Files
Added Jest testing infrastructure and configuration
  • Added Jest and related testing dependencies to package.json
  • Created Jest configuration file with test environment and coverage settings
  • Added Babel configuration for modern JavaScript support
  • Created test setup files and mock files for handling assets
package.json
jest.config.js
babel.config.js
tests/js/setup-tests.js
tests/js/__mocks__/fileMock.js
tests/js/__mocks__/styleMock.js
Added JavaScript unit tests for CMS editor functionality
  • Created test file for CMS editor with comprehensive test cases
  • Added tests for editor initialization and destruction
  • Added tests for plugin form loading and markup requests
  • Added tests for inline editor management
tests/js/cms.editor.test.js
tests/js/example.test.js
Updated CI workflow to include JavaScript testing
  • Added Jest test execution step to frontend workflow
  • Added coverage reporting to Codecov
.github/workflows/frontend.yml
Code style improvements in Python tests
  • Converted string quotes from single to double quotes
  • Fixed line wrapping and indentation
  • Improved code formatting consistency
tests/test_plugin.py
tests/test_html.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@fsbraun fsbraun merged commit 2e9e6fd into main Nov 26, 2024
22 checks passed
@fsbraun fsbraun deleted the sourcery-ai/issue-27 branch November 26, 2024 16:43
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.

1 participant