Alerting: Add simplified_notifications_section field to the alert rule metadata (#95988)
This commit is contained in:
@@ -793,7 +793,8 @@ func TestIntegrationDeleteFolderWithRules(t *testing.T) {
|
||||
"exec_err_state": "Alerting",
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1276,7 +1277,8 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
"exec_err_state":"Alerting",
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1317,7 +1319,8 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
"exec_err_state":"Alerting",
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1630,7 +1633,8 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
"exec_err_state":"Alerting",
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1744,7 +1748,8 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
"exec_err_state":"Alerting",
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1837,7 +1842,8 @@ func TestIntegrationAlertRuleCRUD(t *testing.T) {
|
||||
"exec_err_state":"Alerting",
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2369,7 +2375,8 @@ func TestIntegrationQuota(t *testing.T) {
|
||||
"exec_err_state":"Alerting",
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -919,6 +919,46 @@ func TestIntegrationAlertRuleEditorSettings(t *testing.T) {
|
||||
require.False(t, updatedRuleGroup.Rules[0].GrafanaManagedAlert.Metadata.EditorSettings.SimplifiedQueryAndExpressionsSection)
|
||||
})
|
||||
|
||||
t.Run("set simplified notifications editor in editor settings", func(t *testing.T) {
|
||||
metadata := &apimodels.AlertRuleMetadata{
|
||||
EditorSettings: apimodels.AlertRuleEditorSettings{
|
||||
SimplifiedQueryAndExpressionsSection: false,
|
||||
},
|
||||
}
|
||||
createdRuleGroup := createAlertInGrafana(metadata)
|
||||
|
||||
rulesWithUID := convertGettableRuleGroupToPostable(createdRuleGroup)
|
||||
rulesWithUID.Rules[0].GrafanaManagedAlert.Metadata.EditorSettings.SimplifiedNotificationsSection = true
|
||||
|
||||
_, status, _ := apiClient.PostRulesGroupWithStatus(t, folderName, &rulesWithUID)
|
||||
assert.Equal(t, http.StatusAccepted, status)
|
||||
|
||||
updatedRuleGroup := apiClient.GetRulesGroup(t, folderName, groupName).GettableRuleGroupConfig
|
||||
require.Len(t, updatedRuleGroup.Rules, 1)
|
||||
require.True(t, updatedRuleGroup.Rules[0].GrafanaManagedAlert.Metadata.EditorSettings.SimplifiedNotificationsSection)
|
||||
})
|
||||
|
||||
t.Run("disable simplified notifications editor in editor settings", func(t *testing.T) {
|
||||
metadata := &apimodels.AlertRuleMetadata{
|
||||
EditorSettings: apimodels.AlertRuleEditorSettings{
|
||||
SimplifiedNotificationsSection: true,
|
||||
},
|
||||
}
|
||||
createdRuleGroup := createAlertInGrafana(metadata)
|
||||
|
||||
rulesWithUID := convertGettableRuleGroupToPostable(createdRuleGroup)
|
||||
|
||||
// disabling the editor
|
||||
rulesWithUID.Rules[0].GrafanaManagedAlert.Metadata.EditorSettings.SimplifiedNotificationsSection = false
|
||||
|
||||
_, status, _ := apiClient.PostRulesGroupWithStatus(t, folderName, &rulesWithUID)
|
||||
assert.Equal(t, http.StatusAccepted, status)
|
||||
|
||||
updatedRuleGroup := apiClient.GetRulesGroup(t, folderName, groupName).GettableRuleGroupConfig
|
||||
require.Len(t, updatedRuleGroup.Rules, 1)
|
||||
require.False(t, updatedRuleGroup.Rules[0].GrafanaManagedAlert.Metadata.EditorSettings.SimplifiedNotificationsSection)
|
||||
})
|
||||
|
||||
t.Run("post alert without metadata", func(t *testing.T) {
|
||||
createAlertInGrafana(nil)
|
||||
|
||||
@@ -1154,7 +1194,8 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
|
||||
"exec_err_state": "Alerting",
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1192,7 +1233,8 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
|
||||
"exec_err_state": "Alerting",
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1242,7 +1284,8 @@ func TestIntegrationRulerRulesFilterByDashboard(t *testing.T) {
|
||||
"exec_err_state": "Alerting",
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
"is_paused": false,
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +92,8 @@
|
||||
"is_paused": false,
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
"is_paused": false,
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
"is_paused": false,
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +92,8 @@
|
||||
"is_paused": false,
|
||||
"metadata": {
|
||||
"editor_settings": {
|
||||
"simplified_query_and_expressions_section": false
|
||||
"simplified_query_and_expressions_section": false,
|
||||
"simplified_notifications_section": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user