Add notification filters
This commit is contained in:
@@ -29,6 +29,13 @@ class ProjectNotificationSettingsControllerTest extends TestCase
|
||||
->for($project)
|
||||
->create([
|
||||
'name' => 'Discord alerts',
|
||||
'filters' => [
|
||||
[
|
||||
'attribute' => 'status.to.label',
|
||||
'operator' => 'equals',
|
||||
'value' => 'Doing',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->syncProjectPermissions($project, $user, ['edit']);
|
||||
@@ -44,10 +51,15 @@ class ProjectNotificationSettingsControllerTest extends TestCase
|
||||
->where('notificationActions.0.event_type', NotificationEventType::TicketStatusChanged->value)
|
||||
->where('notificationActions.0.enabled', true)
|
||||
->where('notificationActions.0.has_delivery_url', true)
|
||||
->where('notificationActions.0.filters.0.attribute', 'status.to.label')
|
||||
->where('notificationActions.0.filters.0.operator', 'equals')
|
||||
->where('notificationActions.0.filters.0.value', 'Doing')
|
||||
->where('notificationActions.0.updated_at', $notificationAction->updated_at?->toISOString())
|
||||
->where('channelOptions.0.value', NotificationChannel::Discord->value)
|
||||
->where('eventTypeOptions.0.value', NotificationEventType::TicketStatusChanged->value)
|
||||
->where('eventTypeOptions.1.value', NotificationEventType::TicketCreate->value)
|
||||
->where('filterAttributeOptions.0.value', 'project.id')
|
||||
->where('filterOperatorOptions.0.value', 'equals')
|
||||
->where('templateVariables.0.value', '$url')
|
||||
->where('templateVariables.6.value', '$actor_name')
|
||||
->missing('notificationActions.0.delivery_url'),
|
||||
@@ -86,6 +98,13 @@ class ProjectNotificationSettingsControllerTest extends TestCase
|
||||
'channel' => NotificationChannel::Discord->value,
|
||||
'enabled' => '1',
|
||||
'delivery_url' => 'https://discord.com/api/webhooks/123456/discord-alerts',
|
||||
'filters' => json_encode([
|
||||
[
|
||||
'attribute' => 'status.to.label',
|
||||
'operator' => 'equals',
|
||||
'value' => 'Doing',
|
||||
],
|
||||
], JSON_THROW_ON_ERROR),
|
||||
'message_template' => '$ticket_key moved from $status_from to $status_to by $actor_name: $url',
|
||||
])
|
||||
->assertRedirect(route('projects.settings.notifications', $project))
|
||||
@@ -101,6 +120,13 @@ class ProjectNotificationSettingsControllerTest extends TestCase
|
||||
'https://discord.com/api/webhooks/123456/discord-alerts',
|
||||
$notificationAction->delivery_url,
|
||||
);
|
||||
$this->assertSame([
|
||||
[
|
||||
'attribute' => 'status.to.label',
|
||||
'operator' => 'equals',
|
||||
'value' => 'Doing',
|
||||
],
|
||||
], $notificationAction->filters);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,6 +153,13 @@ class ProjectNotificationSettingsControllerTest extends TestCase
|
||||
'channel' => NotificationChannel::Discord->value,
|
||||
'enabled' => '1',
|
||||
'delivery_url' => '',
|
||||
'filters' => json_encode([
|
||||
[
|
||||
'attribute' => 'ticket.key',
|
||||
'operator' => 'in',
|
||||
'value' => ['CORE-1', 'CORE-2'],
|
||||
],
|
||||
], JSON_THROW_ON_ERROR),
|
||||
'message_template' => '$ticket_key moved to $status_to: $url',
|
||||
])
|
||||
->assertRedirect(route('projects.settings.notifications', $project))
|
||||
@@ -139,6 +172,13 @@ class ProjectNotificationSettingsControllerTest extends TestCase
|
||||
'https://discord.com/api/webhooks/123456/original-secret',
|
||||
$notificationAction->delivery_url,
|
||||
);
|
||||
$this->assertSame([
|
||||
[
|
||||
'attribute' => 'ticket.key',
|
||||
'operator' => 'in',
|
||||
'value' => ['CORE-1', 'CORE-2'],
|
||||
],
|
||||
], $notificationAction->filters);
|
||||
$this->assertSame('$ticket_key moved to $status_to: $url', $notificationAction->message_template);
|
||||
}
|
||||
|
||||
@@ -258,6 +298,13 @@ class ProjectNotificationSettingsControllerTest extends TestCase
|
||||
'channel' => NotificationChannel::Discord->value,
|
||||
'enabled' => 'definitely-not-a-boolean',
|
||||
'delivery_url' => 'not-a-url',
|
||||
'filters' => json_encode([
|
||||
[
|
||||
'attribute' => 'ticket.key',
|
||||
'operator' => 'in',
|
||||
'value' => [],
|
||||
],
|
||||
], JSON_THROW_ON_ERROR),
|
||||
'message_template' => '',
|
||||
])
|
||||
->assertRedirect(route('projects.settings.notifications', $project))
|
||||
@@ -266,6 +313,7 @@ class ProjectNotificationSettingsControllerTest extends TestCase
|
||||
'event_type',
|
||||
'enabled',
|
||||
'delivery_url',
|
||||
'filters.0.value',
|
||||
'message_template',
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user