Admin Panel
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-09-29 14:57:37 +07:00
parent 04fbddba13
commit 8c6dad2a31
94 changed files with 4864 additions and 1151 deletions
+82
View File
@@ -0,0 +1,82 @@
<?php
namespace Tests\Feature;
use App\Enums\ConsultationStatus;
use App\Models\Consultation;
use App\Notifications\NewConsultationRequest;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
class ConsultationRequestTest extends TestCase
{
use RefreshDatabase;
/**
* @return array<string, mixed>
*/
private function payload(array $overrides = []): array
{
return [
'source' => 'home',
'name' => 'Budi Santoso',
'email' => 'budi@example.com',
'phone' => '0811 2345 678',
'service' => 'Implementasi Odoo ERP',
...$overrides,
];
}
public function test_visitor_request_is_saved_and_busdev_is_notified()
{
Notification::fake();
$this->from(route('home'))
->post(route('consultations.store'), $this->payload())
->assertRedirect(route('home'))
->assertSessionHasNoErrors();
$consultation = Consultation::query()->sole();
$this->assertSame('Budi Santoso', $consultation->name);
$this->assertSame(ConsultationStatus::New, $consultation->status);
$this->assertSame('id', $consultation->locale);
Notification::assertSentTo(
new AnonymousNotifiable,
NewConsultationRequest::class,
fn ($notification, $channels, $notifiable) => $notifiable->routes['mail'] === 'busdev@probindo.com',
);
}
public function test_required_fields_are_validated()
{
Notification::fake();
$this->post(route('consultations.store'), $this->payload(['name' => '', 'email' => 'bukan-email']))
->assertSessionHasErrors(['name', 'email']);
$this->assertDatabaseCount('consultations', 0);
Notification::assertNothingSent();
}
public function test_contact_form_requires_nda_consent()
{
$this->post(route('consultations.store'), $this->payload(['source' => 'contact']))
->assertSessionHasErrors('nda_agreed');
$this->post(route('consultations.store'), $this->payload(['source' => 'contact', 'nda_agreed' => '1']))
->assertSessionHasNoErrors();
$this->assertTrue(Consultation::query()->sole()->nda_agreed);
}
public function test_honeypot_submissions_are_rejected()
{
$this->post(route('consultations.store'), $this->payload(['website' => 'http://spam.test']))
->assertSessionHasErrors('website');
$this->assertDatabaseCount('consultations', 0);
}
}