WIP notifications and other refactors (#88)

* WIP notifications and other refactors
- refactor notification channels
- send notifications on events related to the servers and sites
- delete server log files on server deletion
- add telegram notification channel
- add new icons
- cache configs and icons on installation and updates
- new navbar for dark mode and settings

* discord channel

* build assets

* pint
This commit is contained in:
Saeed Vaziry
2024-01-07 09:54:08 +01:00
committed by GitHub
parent f06b8f7d20
commit e997d0deea
72 changed files with 1153 additions and 480 deletions

View File

@ -23,8 +23,17 @@ public function test_add_email_channel(): void
Livewire::test(AddChannel::class)
->set('provider', NotificationChannel::EMAIL)
->set('email', 'email@example.com')
->set('label', 'Email')
->call('add')
->assertSuccessful();
$this->assertDatabaseHas('notification_channels', [
'provider' => NotificationChannel::EMAIL,
'data' => cast_to_json([
'email' => 'email@example.com',
]),
'connected' => 1,
]);
}
public function test_add_slack_channel(): void
@ -36,9 +45,17 @@ public function test_add_slack_channel(): void
Livewire::test(AddChannel::class)
->set('provider', NotificationChannel::SLACK)
->set('label', 'Slack')
->set('webhook_url', $this->faker->url)
->set('webhook_url', 'https://hooks.slack.com/services/123/token')
->call('add')
->assertSuccessful();
$this->assertDatabaseHas('notification_channels', [
'provider' => NotificationChannel::SLACK,
'data' => cast_to_json([
'webhook_url' => 'https://hooks.slack.com/services/123/token',
]),
'connected' => 1,
]);
}
public function test_add_discord_channel(): void
@ -49,10 +66,42 @@ public function test_add_discord_channel(): void
Livewire::test(AddChannel::class)
->set('provider', NotificationChannel::DISCORD)
->set('label', 'Slack')
->set('webhook_url', $this->faker->url)
->set('label', 'Discord')
->set('webhook_url', 'https://discord.com/api/webhooks/123/token')
->call('add')
->assertSuccessful();
$this->assertDatabaseHas('notification_channels', [
'provider' => NotificationChannel::DISCORD,
'data' => cast_to_json([
'webhook_url' => 'https://discord.com/api/webhooks/123/token',
]),
'connected' => 1,
]);
}
public function test_add_telegram_channel(): void
{
$this->actingAs($this->user);
Http::fake();
Livewire::test(AddChannel::class)
->set('provider', NotificationChannel::TELEGRAM)
->set('label', 'Telegram')
->set('bot_token', 'token')
->set('chat_id', '123')
->call('add')
->assertSuccessful();
$this->assertDatabaseHas('notification_channels', [
'provider' => NotificationChannel::TELEGRAM,
'data' => cast_to_json([
'chat_id' => '123',
'bot_token' => 'token',
]),
'connected' => 1,
]);
}
public function test_see_channels_list(): void