Alerting: Add simplified_notifications_section field to the alert rule metadata (#95988)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user