-
Notifications
You must be signed in to change notification settings - Fork 58
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
Conversation
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+)", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 Report
@@ 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.
|
}, | ||
"https://mmtest.atlassian.net/browse/DP-454", | ||
"https://mmtest.atlassian.net/browse/DP-454", | ||
}, |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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>.*/
.
@vicky-demansol Heads up that CI is failing: https://circleci.com/workflow-run/d28cd0ca-8f16-4652-8eef-dc0628e52a38?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-checks-link |
This PR has been automatically labelled "stale" because it hasn't had recent activity. |
There was a problem hiding this 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})", |
There was a problem hiding this comment.
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
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", |
There was a problem hiding this comment.
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", | ||
}, |
There was a problem hiding this comment.
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>.*/
.
closing this and raising a new PR |
Summary
Aims to add unit test for mattermost/mattermost-plugin-jira#797
Ticket Link
Fix #174