You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2024/08/14 07:58:48 UTC

(incubator-devlake) branch main updated: test(jira): add e2e test for custom account field in issues (#7894)

This is an automated email from the ASF dual-hosted git repository.

abeizn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new eebc0057e test(jira): add e2e test for custom account field in issues (#7894)
eebc0057e is described below

commit eebc0057eaca2d531888469b42d8d040429e162a
Author: Lynwee <15...@qq.com>
AuthorDate: Wed Aug 14 15:58:44 2024 +0800

    test(jira): add e2e test for custom account field in issues (#7894)
---
 .../_tool_jira_issue_fields.csv                    |  3 +
 .../plugins/jira/e2e/extract_issue_fields_test.go  | 62 +++++++++++++++++++
 backend/plugins/jira/e2e/issue_changelog_test.go   | 72 ++++++++++++++++++++++
 .../_raw_jira_api_issue_changelogs.csv             |  5 ++
 .../e2e/issue_changelogs/_tool_jira_accounts.csv   |  4 ++
 .../_tool_jira_issue_changelogs.csv                |  4 ++
 .../issue_changelogs/_tool_jira_issue_fields.csv   |  4 ++
 7 files changed, 154 insertions(+)

diff --git a/backend/plugins/jira/e2e/extract_issue_fields/_tool_jira_issue_fields.csv b/backend/plugins/jira/e2e/extract_issue_fields/_tool_jira_issue_fields.csv
new file mode 100644
index 000000000..7b70bea3d
--- /dev/null
+++ b/backend/plugins/jira/e2e/extract_issue_fields/_tool_jira_issue_fields.csv
@@ -0,0 +1,3 @@
+connection_id,board_id,id,name,custom,orderable,navigable,searchable,schema_type,schema_items,schema_custom,schema_custom_id,sche_custom_system,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
+2,8,customfield_10315,cu用户单选,1,1,1,1,user,,com.atlassian.jira.plugin.system.customfieldtypes:userpicker,10315,,"{""ConnectionId"":2,""BoardId"":8}",_raw_jira_api_issue_fields,70,
+2,8,customfield_10400,gitBranch,1,1,1,1,any,,com.xiplink.jira.git.jira_git_plugin:gitbranches,10400,,"{""ConnectionId"":2,""BoardId"":8}",_raw_jira_api_issue_fields,66,
diff --git a/backend/plugins/jira/e2e/extract_issue_fields_test.go b/backend/plugins/jira/e2e/extract_issue_fields_test.go
new file mode 100644
index 000000000..b219a600c
--- /dev/null
+++ b/backend/plugins/jira/e2e/extract_issue_fields_test.go
@@ -0,0 +1,62 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package e2e
+
+import (
+	"github.com/apache/incubator-devlake/helpers/e2ehelper"
+	"github.com/apache/incubator-devlake/plugins/jira/impl"
+	"github.com/apache/incubator-devlake/plugins/jira/models"
+	"github.com/apache/incubator-devlake/plugins/jira/tasks"
+	"testing"
+)
+
+func TestIssueFieldsDataFlow(t *testing.T) {
+	var plugin impl.Jira
+	dataflowTester := e2ehelper.NewDataFlowTester(t, "jira", plugin)
+
+	taskData := &tasks.JiraTaskData{
+		Options: &tasks.JiraOptions{
+			ConnectionId: 2,
+			BoardId:      8,
+		},
+	}
+
+	// import raw data: _raw_jira_api_issue_fields
+	dataflowTester.ImportCsvIntoRawTable("./raw_tables/_raw_jira_api_issue_fields.csv", "_raw_jira_api_issue_fields")
+	dataflowTester.FlushTabler(&models.JiraIssueField{})
+	dataflowTester.Subtask(tasks.ExtractIssueFieldsMeta, taskData)
+	dataflowTester.VerifyTable(
+		models.JiraIssueField{},
+		"./extract_issue_fields/_tool_jira_issue_fields.csv",
+		e2ehelper.ColumnWithRawData(
+			"connection_id",
+			"id",
+			"board_id",
+			"name",
+			"custom",
+			"orderable",
+			"navigable",
+			"searchable",
+			"schema_type",
+			"schema_items",
+			"schema_custom",
+			"schema_custom_id",
+			"sche_custom_system",
+		),
+	)
+}
diff --git a/backend/plugins/jira/e2e/issue_changelog_test.go b/backend/plugins/jira/e2e/issue_changelog_test.go
new file mode 100644
index 000000000..0674dfe20
--- /dev/null
+++ b/backend/plugins/jira/e2e/issue_changelog_test.go
@@ -0,0 +1,72 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package e2e
+
+import (
+	"github.com/apache/incubator-devlake/helpers/e2ehelper"
+	"github.com/apache/incubator-devlake/plugins/jira/impl"
+	"github.com/apache/incubator-devlake/plugins/jira/models"
+	"github.com/apache/incubator-devlake/plugins/jira/tasks"
+	"testing"
+)
+
+func TestIssueExtractorDataFlow(t *testing.T) {
+	var plugin impl.Jira
+	dataflowTester := e2ehelper.NewDataFlowTester(t, "jira", plugin)
+
+	taskData := &tasks.JiraTaskData{
+		Options: &tasks.JiraOptions{
+			ConnectionId: 2,
+			BoardId:      8,
+		},
+	}
+	// import raw data table
+	dataflowTester.ImportCsvIntoRawTable("./issue_changelogs/_raw_jira_api_issue_changelogs.csv", "_raw_jira_api_issue_changelogs")
+	dataflowTester.ImportCsvIntoTabler("./issue_changelogs/_tool_jira_issue_fields.csv", &models.JiraIssueField{})
+	dataflowTester.FlushTabler(&models.JiraIssueChangelogs{})
+	dataflowTester.FlushTabler(&models.JiraIssueChangelogItems{})
+	dataflowTester.FlushTabler(&models.JiraAccount{})
+	dataflowTester.Subtask(tasks.ExtractIssueChangelogsMeta, taskData)
+	dataflowTester.VerifyTable(
+		models.JiraIssueChangelogs{},
+		"./issue_changelogs/_tool_jira_issue_changelogs.csv",
+		e2ehelper.ColumnWithRawData(
+			"connection_id",
+			"changelog_id",
+			"issue_id",
+			"author_account_id",
+			"author_display_name",
+			"author_active",
+			"created",
+			"issue_updated",
+		))
+	dataflowTester.VerifyTable(
+		models.JiraAccount{},
+		"./issue_changelogs/_tool_jira_accounts.csv",
+		e2ehelper.ColumnWithRawData(
+			"connection_id",
+			"account_id",
+			"account_type",
+			"name",
+			"email",
+			"avatar_url",
+			"timezone",
+		),
+	)
+
+}
diff --git a/backend/plugins/jira/e2e/issue_changelogs/_raw_jira_api_issue_changelogs.csv b/backend/plugins/jira/e2e/issue_changelogs/_raw_jira_api_issue_changelogs.csv
new file mode 100644
index 000000000..aa9eb9416
--- /dev/null
+++ b/backend/plugins/jira/e2e/issue_changelogs/_raw_jira_api_issue_changelogs.csv
@@ -0,0 +1,5 @@
+"id","params","data","url","input","created_at"
+204483,"{""ConnectionId"":2,""BoardId"":8}","{""id"":""57278"",""author"":{""self"":""https://merico.atlassian.net/rest/api/3/user?accountId=5fb48fe20d2f61006f0d0106"",""accountId"":"""",""emailAddress"":"""",""avatarUrls"":{""48x48"":""https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5fb48fe20d2f61006f0d0106/3233dbe8-0b15-45fa-96f3-fba86afe140d/48"",""24x24"":""https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5fb48fe20d2f61006f0d0106/3233dbe8-0b [...]
+204484,"{""ConnectionId"":2,""BoardId"":8}","{""id"":""57279"",""author"":{""self"":""https://merico.atlassian.net/rest/api/3/user?accountId=5fb48fe20d2f61006f0d0106"",""accountId"":"""",""emailAddress"":"""",""avatarUrls"":{""48x48"":""https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5fb48fe20d2f61006f0d0106/3233dbe8-0b15-45fa-96f3-fba86afe140d/48"",""24x24"":""https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5fb48fe20d2f61006f0d0106/3233dbe8-0b [...]
+204485,"{""ConnectionId"":2,""BoardId"":8}","{""id"":""57280"",""author"":{""self"":""https://merico.atlassian.net/rest/api/3/user?accountId=5fb48fe20d2f61006f0d0106"",""accountId"":"""",""emailAddress"":"""",""avatarUrls"":{""48x48"":""https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5fb48fe20d2f61006f0d0106/3233dbe8-0b15-45fa-96f3-fba86afe140d/48"",""24x24"":""https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5fb48fe20d2f61006f0d0106/3233dbe8-0b [...]
+204486,"{""ConnectionId"":2,""BoardId"":8}","{""id"":""57280"",""author"":{""self"":""https://merico.atlassian.net/rest/api/3/user?accountId=5fb48fe20d2f61006f0d0106"",""accountId"":"""",""emailAddress"":"""",""avatarUrls"":{""48x48"":""https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5fb48fe20d2f61006f0d0106/3233dbe8-0b15-45fa-96f3-fba86afe140d/48"",""24x24"":""https://avatar-management--avatars.us-west-2.prod.public.atl-paas.net/5fb48fe20d2f61006f0d0106/3233dbe8-0b [...]
diff --git a/backend/plugins/jira/e2e/issue_changelogs/_tool_jira_accounts.csv b/backend/plugins/jira/e2e/issue_changelogs/_tool_jira_accounts.csv
new file mode 100644
index 000000000..479c7a34f
--- /dev/null
+++ b/backend/plugins/jira/e2e/issue_changelogs/_tool_jira_accounts.csv
@@ -0,0 +1,4 @@
+connection_id,account_id,account_type,name,email,avatar_url,timezone,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
+2,assignee_uid1,,,,,,"{""ConnectionId"":2,""BoardId"":8}",_raw_jira_api_issue_changelogs,204486,
+2,reporter_uid1,,,,,,"{""ConnectionId"":2,""BoardId"":8}",_raw_jira_api_issue_changelogs,204485,
+2,uid1,,,,,,"{""ConnectionId"":2,""BoardId"":8}",_raw_jira_api_issue_changelogs,204483,
diff --git a/backend/plugins/jira/e2e/issue_changelogs/_tool_jira_issue_changelogs.csv b/backend/plugins/jira/e2e/issue_changelogs/_tool_jira_issue_changelogs.csv
new file mode 100644
index 000000000..15dc70ff5
--- /dev/null
+++ b/backend/plugins/jira/e2e/issue_changelogs/_tool_jira_issue_changelogs.csv
@@ -0,0 +1,4 @@
+connection_id,changelog_id,issue_id,author_account_id,author_display_name,author_active,created,issue_updated,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
+2,57278,13383,,Runjuu,0,2021-01-25T03:09:27.985+00:00,2021-03-28T08:08:12.741+00:00,"{""ConnectionId"":2,""BoardId"":8}",_raw_jira_api_issue_changelogs,204483,
+2,57279,13383,,Runjuu,0,2021-01-25T03:09:27.985+00:00,2021-03-28T08:08:13.741+00:00,"{""ConnectionId"":2,""BoardId"":8}",_raw_jira_api_issue_changelogs,204484,
+2,57280,13383,,Runjuu,0,2021-01-25T03:09:27.985+00:00,2021-03-28T08:08:13.741+00:00,"{""ConnectionId"":2,""BoardId"":8}",_raw_jira_api_issue_changelogs,204486,
diff --git a/backend/plugins/jira/e2e/issue_changelogs/_tool_jira_issue_fields.csv b/backend/plugins/jira/e2e/issue_changelogs/_tool_jira_issue_fields.csv
new file mode 100644
index 000000000..0b23a7d32
--- /dev/null
+++ b/backend/plugins/jira/e2e/issue_changelogs/_tool_jira_issue_fields.csv
@@ -0,0 +1,4 @@
+connection_id,board_id,id,name,custom,orderable,navigable,searchable,schema_type,schema_items,schema_custom,schema_custom_id,sche_custom_system,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark
+2,8,customfield_10315,cu用户单选,1,1,1,1,user,,com.atlassian.jira.plugin.system.customfieldtypes:userpicker,10315,,"{""ConnectionId"":2,""BoardId"":8}",_raw_jira_api_issue_fields,70,
+2,8,customfield_10400,gitBranch,1,1,1,1,any,,com.xiplink.jira.git.jira_git_plugin:gitbranches,10400,,"{""ConnectionId"":2,""BoardId"":8}",_raw_jira_api_issue_fields,66,
+2,8,customfield_1,a_fake_user,1,1,1,1,user,,com.atlassian.jira.plugin.system.customfieldtypes:userpicker,10316,,"{""ConnectionId"":2,""BoardId"":8}",_raw_jira_api_issue_fields,67,