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

messages: Add tests for transform_content. #1507

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rsashank
Copy link
Member

What does this PR do, and why?

This update PR tests for the transform_content class method for self.message_links and self.time_mentions. The addition of these tests addresses feedback from issue #1455, which pointed out the lack of tests for these aspects.

@neiljp said:

It'd be good to see some tests for what ends up in self.code_snippets, though we don't seem to have tests for the others.

External discussion & connections

  • Discussed in #zulip-terminal in topic
  • Fully fixes #
  • Partially fixes issue #
  • Builds upon previous unmerged work in PR #
  • Is a follow-up to work in PR #
  • Requires merge of PR #
  • Merge will enable work on #

How did you test this?

  • Manually - Behavioral changes
  • Manually - Visual changes
  • Adapting existing automated tests
  • Adding automated tests for new behavior (or missing tests)
  • Existing automated tests should already cover this (only a refactor of tested code)

Self-review checklist for each commit

  • It is a minimal coherent idea
  • It has a commit summary following the documented style (title & body)
  • It has a commit summary describing the motivation and reasoning for the change
  • It individually passes linting and tests
  • [] It contains test additions for any new behavior
  • It flows clearly from a previous branch commit, and/or prepares for the next commit

@zulipbot zulipbot added the size: L [Automatic label added by zulipbot] label May 29, 2024
Copy link
Collaborator

@Niloth-p Niloth-p left a comment

Choose a reason for hiding this comment

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

Same as the other PR,

  • type annotations
  • test ids

Nice work with the noqa exceptions 😉

Nicely done!
I haven't looked into the scope and history behind this PR yet.
But the implementation lgtm.

),
(
"""
<p><a href="#narrow/stream/206-zulip-terminal/topic/announce">https://chat.zulip.zulip/#narrow/stream/206-zulip-terminal/topic/announce</a></p>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not chat.zulip.org? xD

Copy link
Member Author

Choose a reason for hiding this comment

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

SERVER_URL = "https://chat.zulip.zulip" is defined on line 28 of test_messages.py, and I used it when calling transform_content in the test. Could be changed though, if needed :)

[
(
"""
<p><a href="https://github.com/zulip/zulip-terminal/pull/1">https://github.com/zulip/zulip-terminal/pull/1</a></p>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we have some link where the text is not the same as the link?
One of the first two?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done :)

tests/ui_tools/test_messages.py Outdated Show resolved Hide resolved
@zulipbot zulipbot added size: XL [Automatic label added by zulipbot] and removed size: L [Automatic label added by zulipbot] labels May 31, 2024
This commit introduces tests for the `transform_content` class method,
specifically focusing on the `message_links` and `time_mentions`.

These enhancements improve the reliability and testing coverage of the
`transform_content` method.
@rsashank
Copy link
Member Author

Thanks for helping out with the noqa exceptions and for the detailed review! :) @Niloth-p

Copy link
Collaborator

@mounilKshah mounilKshah left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @rsashank
The test cases considered for each of the functions seem appropriate and enough for testing the respective aspects of the transform_content function.

@@ -1585,14 +1587,120 @@ def test_keypress_EDIT_MESSAGE(
# fmt: on
],
)
def test_transform_content(self, mocker, raw_html, expected_content):
def test_transform_content(self, raw_html: str, expected_content: Any) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure if there's a need for this change as we don't usually define data type for the function arguments or the function return variable as we decide what to pass.
You may not keep them in the newly created test function as well.

@mounilKshah mounilKshah added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs mentor review labels Jun 16, 2024
@rsashank rsashank removed the PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback label Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: tests PR needs review PR requires feedback to proceed size: XL [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants