mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
@ -26,12 +26,35 @@ public function test_add_email_channel(): void
|
||||
/** @var \App\Models\NotificationChannel $channel */
|
||||
$channel = \App\Models\NotificationChannel::query()
|
||||
->where('provider', NotificationChannel::EMAIL)
|
||||
->where('label', 'Email')
|
||||
->first();
|
||||
|
||||
$this->assertEquals('email@example.com', $channel->data['email']);
|
||||
$this->assertTrue($channel->connected);
|
||||
}
|
||||
|
||||
public function test_cannot_add_email_channel(): void
|
||||
{
|
||||
config()->set('mail.default', 'smtp');
|
||||
config()->set('mail.mailers.smtp.host', '127.0.0.1'); // invalid host
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('notification-channels.add'), [
|
||||
'provider' => NotificationChannel::EMAIL,
|
||||
'email' => 'email@example.com',
|
||||
'label' => 'Email',
|
||||
])->assertSessionHasErrors();
|
||||
|
||||
/** @var \App\Models\NotificationChannel $channel */
|
||||
$channel = \App\Models\NotificationChannel::query()
|
||||
->where('provider', NotificationChannel::EMAIL)
|
||||
->where('label', 'Email')
|
||||
->first();
|
||||
|
||||
$this->assertNull($channel);
|
||||
}
|
||||
|
||||
public function test_add_slack_channel(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -53,6 +76,28 @@ public function test_add_slack_channel(): void
|
||||
$this->assertTrue($channel->connected);
|
||||
}
|
||||
|
||||
public function test_cannot_add_slack_channel(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Http::fake([
|
||||
'slack.com/*' => Http::response(['ok' => false], 401),
|
||||
]);
|
||||
|
||||
$this->post(route('notification-channels.add'), [
|
||||
'provider' => NotificationChannel::SLACK,
|
||||
'webhook_url' => 'https://hooks.slack.com/services/123/token',
|
||||
'label' => 'Slack',
|
||||
])->assertSessionHasErrors();
|
||||
|
||||
/** @var \App\Models\NotificationChannel $channel */
|
||||
$channel = \App\Models\NotificationChannel::query()
|
||||
->where('provider', NotificationChannel::SLACK)
|
||||
->first();
|
||||
|
||||
$this->assertNull($channel);
|
||||
}
|
||||
|
||||
public function test_add_discord_channel(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
@ -74,9 +119,27 @@ public function test_add_discord_channel(): void
|
||||
$this->assertTrue($channel->connected);
|
||||
}
|
||||
|
||||
/*
|
||||
* @TODO fix json comparison
|
||||
*/
|
||||
public function test_cannot_add_discord_channel(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Http::fake([
|
||||
'discord.com/*' => Http::response(['ok' => false], 401),
|
||||
]);
|
||||
|
||||
$this->post(route('notification-channels.add'), [
|
||||
'provider' => NotificationChannel::DISCORD,
|
||||
'webhook_url' => 'https://discord.com/api/webhooks/123/token',
|
||||
'label' => 'Discord',
|
||||
])->assertSessionHasErrors();
|
||||
|
||||
/** @var \App\Models\NotificationChannel $channel */
|
||||
$channel = \App\Models\NotificationChannel::query()
|
||||
->where('provider', NotificationChannel::DISCORD)
|
||||
->first();
|
||||
|
||||
$this->assertNull($channel);
|
||||
}
|
||||
|
||||
public function test_add_telegram_channel(): void
|
||||
{
|
||||
@ -101,6 +164,29 @@ public function test_add_telegram_channel(): void
|
||||
$this->assertTrue($channel->connected);
|
||||
}
|
||||
|
||||
public function test_cannot_add_telegram_channel(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
Http::fake([
|
||||
'api.telegram.org/*' => Http::response(['ok' => false], 401),
|
||||
]);
|
||||
|
||||
$this->post(route('notification-channels.add'), [
|
||||
'provider' => NotificationChannel::TELEGRAM,
|
||||
'bot_token' => 'token',
|
||||
'chat_id' => '123',
|
||||
'label' => 'Telegram',
|
||||
])->assertSessionHasErrors();
|
||||
|
||||
/** @var \App\Models\NotificationChannel $channel */
|
||||
$channel = \App\Models\NotificationChannel::query()
|
||||
->where('provider', NotificationChannel::TELEGRAM)
|
||||
->first();
|
||||
|
||||
$this->assertNull($channel);
|
||||
}
|
||||
|
||||
public function test_see_channels_list(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
Reference in New Issue
Block a user