Certified/tests/Feature/Settings/CertificateSettingsTest.php
Joël van de Wouw ac340d125c
Some checks failed
linter / quality (push) Failing after 13s
tests / ci (8.3) (push) Failing after 2s
tests / ci (8.4) (push) Failing after 2s
tests / ci (8.5) (push) Failing after 3s
Initial commit
Certificate manager built on Laravel 13, Livewire 4, and Flux.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-12 14:44:58 +02:00

55 lines
1.6 KiB
PHP

<?php
use App\Models\User;
use Livewire\Livewire;
test('the certificate settings page is displayed', function () {
$this->actingAs(User::factory()->create());
$this->get(route('certificate-settings.edit'))->assertOk();
});
test('a user can update their reminder and ocr settings', function () {
$user = User::factory()->create();
$this->actingAs($user);
Livewire::test('pages::settings.certificates')
->set('reminder_months_before', 3)
->set('ocr_provider', 'klippa')
->set('ocr_api_key', 'secret-key')
->call('updateSettings')
->assertHasNoErrors();
$user->refresh();
expect($user->reminder_months_before)->toBe(3)
->and($user->ocr_provider)->toBe('klippa')
->and($user->ocr_api_key)->toBe('secret-key');
});
test('a blank api key keeps the existing one', function () {
$user = User::factory()->create();
$user->ocr_provider = 'klippa';
$user->ocr_api_key = 'original-key';
$user->save();
$this->actingAs($user);
Livewire::test('pages::settings.certificates')
->set('reminder_months_before', 2)
->set('ocr_provider', 'klippa')
->set('ocr_api_key', '')
->call('updateSettings')
->assertHasNoErrors();
expect($user->refresh()->ocr_api_key)->toBe('original-key');
});
test('an unknown ocr provider is rejected', function () {
$this->actingAs(User::factory()->create());
Livewire::test('pages::settings.certificates')
->set('ocr_provider', 'hacker')
->call('updateSettings')
->assertHasErrors(['ocr_provider']);
});