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

[GH-174] Add Jira Autolink With Comment (#174) #175

Closed
wants to merge 3 commits into from

Conversation

jupriano
Copy link

Summary

Aims to add unit test for mattermost/mattermost-plugin-jira#797

Ticket Link

Fix #174

@jupriano jupriano requested a review from levb as a code owner November 10, 2021 14:01
@mattermod
Copy link
Contributor

Hello @vicky-demansol,

Thanks for your pull request! A Core Committer will review your pull request soon. For code contributions, you can learn more about the review process here.

{
"Jump To Comment With Jira Cloud",
autolink.Autolink{
Pattern: "(https://mmtest.atlassian.net/browse/)(DP)(-)(?P<jira_id>\\d+)[?](focusedCommentId)(=)(?P<comment_id>\\d+)",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible for us to have this regex be project-agnostic? This way it can work with on-prem Jira instances with no changes needed. I discussed this in the Jira plugin issue here mattermost/mattermost-plugin-jira#773 (comment). Please me know if this is possible because I'm not sure if it is.

Also, it possible to write a test for the_change that was done for the Jira plugin PR? The goal would be to initialize the autolink plugin with the old Jira autolink config, then update it using setLink, then assert the Looks like we'll need to test this function https://github.com/mattermost/mattermost-plugin-autolink/blob/571d6cd3c642b23c2a6aa1d4fa50cc5965fa1b20/server/api/api.go#L90

@DHaussermann We'll need to test the upgrade path of the Jira plugin that introduces this functionality.

Copy link
Author

Choose a reason for hiding this comment

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

@mickmister take a look at #175 (comment) and see if it is ok.

Pattern: "(https://mmtest.atlassian.net/browse/)(DP)(-)(?P<jira_id>\\d+)[?](focusedCommentId)(=)(?P<comment_id>\\d+)",
Template: "[DP-${jira_id} With Focused Comment($comment_id)](https://mmtest.atlassian.net/browse/DP-${jira_id}?focusedCommentId=$comment_id)",
},
"https://mmtest.atlassian.net/browse/DP-454?focusedCommentId=11347",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we write a test that doesn't have focusedCommentId in the URL, to test that the regular issue link case works?

Copy link
Author

Choose a reason for hiding this comment

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

#175 (comment) should cover it as well I think.

@codecov-commenter
Copy link

codecov-commenter commented Nov 25, 2021

Codecov Report

Merging #175 (6a837f4) into master (571d6cd) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #175   +/-   ##
=======================================
  Coverage   41.49%   41.49%           
=======================================
  Files           6        6           
  Lines         670      670           
=======================================
  Hits          278      278           
  Misses        375      375           
  Partials       17       17           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 571d6cd...6a837f4. Read the comment docs.

},
"https://mmtest.atlassian.net/browse/DP-454",
"https://mmtest.atlassian.net/browse/DP-454",
},
Copy link
Author

Choose a reason for hiding this comment

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

hi @mickmister did you mean it will be like this ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Since we want to continue to be able to transform regular issue URLs like this one above, we'll need to incorporate the existing regexes used in the Jira plugin repo here in these tests. One of the existing regexes defined in the Jira plugin is able to parse this URL in the test above.

Since we have 3 regexes now, we need to have 3x3 = 9 unit tests for the following:

  • The first regex correctly transforms a link its meant to transform
  • The first regex does not change a link that the second regex is meant to transform
  • The first regex does not change a link that the third regex is meant to transform

and so on for the second and third regexes, for a total of 9 tests.

Also, the regexes in the Jira plugin use the Jira instance's URL in the Pattern, so you'll want to do that here as well, instead of using ?P<URI>.*/.

@hanzei hanzei added the 3: QA Review Requires review by a QA tester label Nov 30, 2021
@hanzei
Copy link
Contributor

hanzei commented Nov 30, 2021

@mattermod
Copy link
Contributor

This PR has been automatically labelled "stale" because it hasn't had recent activity.
A core team member will check in on the status of the PR to help with questions.
Thank you for your contribution!

/cc @BenLloydPearson @aspleenic

Copy link
Contributor

@mickmister mickmister left a comment

Choose a reason for hiding this comment

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

Thanks @jupriano

I've added a few requests, including one to write a total of 9 unit tests for the 3 regexes we have in the Jira plugin now https://github.com/mattermost/mattermost-plugin-jira/blob/4db5740c99a287423f72279d46604c0d8d30c0b2/server/plugin.go#L359-L373, testing that each regex only affects links that are intended for that specific regex

"Trial With Jira Server #1",
autolink.Autolink{
Pattern: "(?P<URI>.*/)(?P<IssueKey>[A-Za-z]+-[0-9]+)[?](focusedCommentId=*(?P<FocusedCommentId>[^\\s&]+))",
Template: "[${IssueKey} FocusedComment(${FocusedCommentId})](${URI}${IssueKey}?focusedCommentId=${FocusedCommentId})",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think just putting (comment) in the link text is enough to show that it's a comment

Suggested change
Template: "[${IssueKey} FocusedComment(${FocusedCommentId})](${URI}${IssueKey}?focusedCommentId=${FocusedCommentId})",
Template: "[${IssueKey} (comment)](${URI}${IssueKey}?focusedCommentId=${FocusedCommentId})",

Template: "[${IssueKey} FocusedComment(${FocusedCommentId})](${URI}${IssueKey}?focusedCommentId=${FocusedCommentId})",
},
"http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/DKHPROJ-5?focusedCommentId=10200&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-10200",
"http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/DKHPROJ-5?focusedCommentId=10200&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-10200",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the regex to "match" the rest of the URL automatically?

},
"https://mmtest.atlassian.net/browse/DP-454",
"https://mmtest.atlassian.net/browse/DP-454",
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we want to continue to be able to transform regular issue URLs like this one above, we'll need to incorporate the existing regexes used in the Jira plugin repo here in these tests. One of the existing regexes defined in the Jira plugin is able to parse this URL in the test above.

Since we have 3 regexes now, we need to have 3x3 = 9 unit tests for the following:

  • The first regex correctly transforms a link its meant to transform
  • The first regex does not change a link that the second regex is meant to transform
  • The first regex does not change a link that the third regex is meant to transform

and so on for the second and third regexes, for a total of 9 tests.

Also, the regexes in the Jira plugin use the Jira instance's URL in the Pattern, so you'll want to do that here as well, instead of using ?P<URI>.*/.

@sibasankarnayak
Copy link
Contributor

closing this and raising a new PR

@mattermod mattermod removed the Awaiting Submitter Action Blocked on the author label Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester Lifecycle/1:stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Jira Autolink Issue With Comment Test Case
7 participants