Skip to content

chore: Add test for editor note plugin #281

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

Merged
merged 1 commit into from
May 21, 2025
Merged

chore: Add test for editor note plugin #281

merged 1 commit into from
May 21, 2025

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented May 21, 2025

Summary by Sourcery

Add tests for the EditorNotePlugin and adjust test fixtures and template tags to support proper placeholder retrieval and inline editing behavior.

Enhancements:

  • Simplify the inline editing condition in render_tag to a single-line check.
  • Correct the docstring formatting in update_component_properties.

Tests:

  • Add tests to verify that editor notes are hidden on public pages and visible in the CMS4 editing interface.
  • Update test fixtures by removing redundant page publish and refactor get_placeholders to use PageContent.latest_content and Placeholder.objects.get_for_obj.

Copy link
Contributor

sourcery-ai bot commented May 21, 2025

Reviewer's Guide

This PR adds dedicated tests for the EditorNotePlugin (covering both standard and django CMS 4 inline editing scenarios), refines a frontend templatetag implementation, and updates test fixtures to defer publishing and improve placeholder retrieval.

File-Level Changes

Change Details Files
Introduce tests for the EditorNotePlugin
  • Add test_editor_note to verify notes are hidden on published pages
  • Add test_editor_note_with_cms4 (skipped on CMS<4) to verify inline notes visibility in CMS4
  • Use login_user_context and client.get to assert response contents
tests/utilities/test_plugins.py
Correct docstring and simplify inline editing condition in frontend tag
  • Fix extra quotation mark in update_component_properties docstring
  • Collapse multi-line elif condition into a single-line check
djangocms_frontend/templatetags/frontend.py
Refine test fixture setup: remove premature publish and adjust placeholder lookup
  • Remove automatic page.publish in setUp
  • Override get_placeholders to fetch placeholders via PageContent.admin_manager.latest_content and Placeholder.objects.get_for_obj
tests/fixtures.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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

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 1ef2bc7 into master May 21, 2025
9 of 32 checks passed
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @fsbraun - I've reviewed your changes - here's some feedback:

  • Remove the debug print(response.content) call from test_editor_note_with_cms4, since it’s not needed in committed tests.
  • Fix the stray extra quote in the update_component_properties docstring (it currently reads " "Adds or appends…).
  • In fixtures.get_placeholders, use the page parameter instead of hardcoding self.page when fetching PageContent, to avoid confusion and improve reusability.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -39,7 +39,7 @@ def is_inline_editing_active(context: template.Context) -> bool:


def update_component_properties(context: template.Context, key: str, value: typing.Any, append: bool = False) -> None:
""""Adds or appends the value to the property "key" of a component during delcaration"""
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick (typo): Docstring has an extra quote and a typo

Please remove the extra quote at the start and correct the spelling of 'declaration' in the docstring.

Suggested change
""""Adds or appends the value to the property "key" of a component during delcaration"""
"""Adds or appends the value to the property "key" of a component during declaration"""

@fsbraun fsbraun deleted the chore/add-tests branch May 21, 2025 17:58
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