Auth: convert auth views and verification email to Nova layout
This commit is contained in:
38
tests/Feature/Auth/UsernameAvailabilityTest.php
Normal file
38
tests/Feature/Auth/UsernameAvailabilityTest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
it('returns available true for valid free username', function () {
|
||||
$response = $this->getJson('/api/username/availability?username=free_name');
|
||||
|
||||
$response->assertOk()->assertJson([
|
||||
'available' => true,
|
||||
'normalized' => 'free_name',
|
||||
]);
|
||||
});
|
||||
|
||||
it('returns validation error for invalid username format', function () {
|
||||
$response = $this->getJson('/api/username/availability?username=bad.name');
|
||||
|
||||
$response->assertStatus(422)->assertJsonPath('available', false);
|
||||
});
|
||||
|
||||
it('returns validation error for reserved username', function () {
|
||||
$response = $this->getJson('/api/username/availability?username=admin');
|
||||
|
||||
$response->assertStatus(422)->assertJsonPath('available', false);
|
||||
});
|
||||
|
||||
it('returns available false for already taken username', function () {
|
||||
User::factory()->create(['username' => 'taken_name']);
|
||||
|
||||
$response = $this->getJson('/api/username/availability?username=taken_name');
|
||||
|
||||
$response->assertOk()->assertJson([
|
||||
'available' => false,
|
||||
'normalized' => 'taken_name',
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user