-
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -118,6 +118,88 @@ var jiraTests = []linkTest{ | |||||
"Welcome https://mattermost.atlassian.net/browse/MM-12345", | ||||||
"Welcome [MM-12345](https://mattermost.atlassian.net/browse/MM-12345)", | ||||||
}, | ||||||
{ | ||||||
"Jump To Comment With Jira Cloud", | ||||||
autolink.Autolink{ | ||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Can we write a test that doesn't have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #175 (comment) should cover it as well I think. |
||||||
"[DP-454 With Focused Comment(11347)](https://mmtest.atlassian.net/browse/DP-454?focusedCommentId=11347)", | ||||||
}, | ||||||
{ | ||||||
"Jump To Comment With Jira Ecc", | ||||||
autolink.Autolink{ | ||||||
Pattern: "(http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/)(DKHPROJ)(-)(?P<jira_id>\\d+)[?](focusedCommentId)(=)(?P<comment_id>\\d+)", | ||||||
Template: "[DKHPROJ-${jira_id} With Focused Comment($comment_id)](http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/DKHPROJ-${jira_id}?focusedCommentId=$comment_id)", | ||||||
}, | ||||||
"http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/DKHPROJ-5?focusedCommentId=10200", | ||||||
"[DKHPROJ-5 With Focused Comment(10200)](http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/DKHPROJ-5?focusedCommentId=10200)", | ||||||
}, | ||||||
{ | ||||||
"Jump To Comment With Jira Ecc Long Link", | ||||||
autolink.Autolink{ | ||||||
Pattern: "(http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/)(DKHPROJ)(-)(?P<jira_id>\\d+)[?](focusedCommentId)(=)(?P<comment_id>\\d+)", | ||||||
Template: "[DKHPROJ-${jira_id} With Focused Comment($comment_id)](http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/DKHPROJ-${jira_id}?focusedCommentId=$comment_id)", | ||||||
}, | ||||||
"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", | ||||||
}, | ||||||
{ | ||||||
"Jump To Comment With Jira Ecc Long Short", | ||||||
autolink.Autolink{ | ||||||
Pattern: "(http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/)(DKHPROJ)(-)(?P<jira_id>\\d+)[?](focusedCommentId)(=)(?P<comment_id>\\d+)", | ||||||
Template: "[DKHPROJ-${jira_id} With Focused Comment($comment_id)](http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/DKHPROJ-${jira_id}?focusedCommentId=$comment_id)", | ||||||
}, | ||||||
"http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/DKHPROJ-5", | ||||||
"http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/DKHPROJ-5", | ||||||
}, | ||||||
{ | ||||||
"Jump To Comment With Jira Cloud Failed", | ||||||
autolink.Autolink{ | ||||||
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}", | ||||||
}, | ||||||
"https://mmtest.atlassian.net/browse/DP-454", | ||||||
"https://mmtest.atlassian.net/browse/DP-454", | ||||||
}, | ||||||
// Trials Linker | ||||||
{ | ||||||
"Trial With Jira Cloud", | ||||||
autolink.Autolink{ | ||||||
Pattern: "(?P<URI>.*/)(?P<IssueKey>[A-Za-z]+-[0-9]+)[?](focusedCommentId=*(?P<FocusedCommentId>[^\\s&]+))", | ||||||
Template: "[${IssueKey} FocusedComment(${FocusedCommentId})](${URI}${IssueKey}?focusedCommentId=${FocusedCommentId})", | ||||||
}, | ||||||
"https://mmtest.atlassian.net/browse/DP-454?focusedCommentId=11347", | ||||||
"[DP-454 FocusedComment(11347)](https://mmtest.atlassian.net/browse/DP-454?focusedCommentId=11347)", | ||||||
}, | ||||||
{ | ||||||
"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 commentThe reason will be displayed to describe this comment to others. Learn more. I think just putting
Suggested change
|
||||||
}, | ||||||
"http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/DKHPROJ-5?focusedCommentId=10200", | ||||||
"[DKHPROJ-5 FocusedComment(10200)](http://ec2-54-157-116-101.compute-1.amazonaws.com/browse/DKHPROJ-5?focusedCommentId=10200)", | ||||||
}, | ||||||
{ | ||||||
"Trial With Jira Server #2", //Not Worked here ? | ||||||
autolink.Autolink{ | ||||||
Pattern: "(?P<URI>.*/)(?P<IssueKey>[A-Za-z]+-[0-9]+)[?](focusedCommentId=*(?P<FocusedCommentId>[^\\s&]+))", | ||||||
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 commentThe 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? |
||||||
}, | ||||||
{ | ||||||
"Trial With Jira Cloud Without Focused Comment ID", //Not Worked here ? | ||||||
autolink.Autolink{ | ||||||
Pattern: "(?P<URI>.*/)(?P<IssueKey>[A-Za-z]+-[0-9]+)[?](focusedCommentId=*(?P<FocusedCommentId>[^\\s&]+))", | ||||||
Template: "[${IssueKey} FocusedComment(${FocusedCommentId})](${URI}${IssueKey}?focusedCommentId=${FocusedCommentId})", | ||||||
}, | ||||||
"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 commentThe 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 commentThe 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:
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 |
||||||
} | ||||||
|
||||||
func TestJira(t *testing.T) { | ||||||
|
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.