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
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions server/autolink/lib_jira_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,42 @@ 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+)",
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.

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.

"[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",
},
}

func TestJira(t *testing.T) {
Expand Down