20-02-2026
This commit is contained in:
parent
854ce02bf6
commit
4d6b4930b2
128 changed files with 18247 additions and 2093 deletions
|
|
@ -4,7 +4,9 @@ use App\Models\User;
|
|||
use Livewire\Volt\Volt as LivewireVolt;
|
||||
|
||||
test('login screen can be rendered', function () {
|
||||
$response = $this->get('/login');
|
||||
$portalUrl = 'https://'.config('domains.domain_portal');
|
||||
|
||||
$response = $this->get($portalUrl.'/login');
|
||||
|
||||
$response->assertStatus(200);
|
||||
});
|
||||
|
|
@ -38,9 +40,11 @@ test('users can not authenticate with invalid password', function () {
|
|||
});
|
||||
|
||||
test('users can logout', function () {
|
||||
$portalUrl = 'https://'.config('domains.domain_portal');
|
||||
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->post('/logout');
|
||||
$response = $this->actingAs($user)->post($portalUrl.'/logout');
|
||||
|
||||
$response->assertRedirect('/');
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ use Illuminate\Support\Facades\Event;
|
|||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
test('email verification screen can be rendered', function () {
|
||||
$portalUrl = 'https://'.config('domains.domain_portal');
|
||||
|
||||
$user = User::factory()->unverified()->create();
|
||||
|
||||
$response = $this->actingAs($user)->get('/verify-email');
|
||||
$response = $this->actingAs($user)->get($portalUrl.'/verify-email');
|
||||
|
||||
$response->assertStatus(200);
|
||||
});
|
||||
|
|
@ -29,7 +31,7 @@ test('email can be verified', function () {
|
|||
Event::assertDispatched(Verified::class);
|
||||
|
||||
expect($user->fresh()->hasVerifiedEmail())->toBeTrue();
|
||||
$response->assertRedirect(route('dashboard', absolute: false).'?verified=1');
|
||||
$response->assertRedirect(route('partner.setup.wizard', absolute: false));
|
||||
});
|
||||
|
||||
test('email is not verified with invalid hash', function () {
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@ use App\Models\User;
|
|||
use Livewire\Volt\Volt;
|
||||
|
||||
test('confirm password screen can be rendered', function () {
|
||||
$portalUrl = 'https://'.config('domains.domain_portal');
|
||||
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->get('/confirm-password');
|
||||
$response = $this->actingAs($user)->get($portalUrl.'/confirm-password');
|
||||
|
||||
$response->assertStatus(200);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Auth\Notifications\ResetPassword;
|
||||
use App\Notifications\CustomResetPasswordNotification;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Livewire\Volt\Volt;
|
||||
|
||||
test('reset password link screen can be rendered', function () {
|
||||
$response = $this->get('/forgot-password');
|
||||
$portalUrl = 'https://'.config('domains.domain_portal');
|
||||
|
||||
$response = $this->get($portalUrl.'/forgot-password');
|
||||
|
||||
$response->assertStatus(200);
|
||||
});
|
||||
|
|
@ -20,7 +22,7 @@ test('reset password link can be requested', function () {
|
|||
->set('email', $user->email)
|
||||
->call('sendPasswordResetLink');
|
||||
|
||||
Notification::assertSentTo($user, ResetPassword::class);
|
||||
Notification::assertSentTo($user, CustomResetPasswordNotification::class);
|
||||
});
|
||||
|
||||
test('reset password screen can be rendered', function () {
|
||||
|
|
@ -32,8 +34,10 @@ test('reset password screen can be rendered', function () {
|
|||
->set('email', $user->email)
|
||||
->call('sendPasswordResetLink');
|
||||
|
||||
Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
|
||||
$response = $this->get('/reset-password/'.$notification->token);
|
||||
Notification::assertSentTo($user, CustomResetPasswordNotification::class, function ($notification) {
|
||||
$portalUrl = 'https://'.config('domains.domain_portal');
|
||||
|
||||
$response = $this->get($portalUrl.'/reset-password/'.$notification->token);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
|
|
@ -50,7 +54,7 @@ test('password can be reset with valid token', function () {
|
|||
->set('email', $user->email)
|
||||
->call('sendPasswordResetLink');
|
||||
|
||||
Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
|
||||
Notification::assertSentTo($user, CustomResetPasswordNotification::class, function ($notification) use ($user) {
|
||||
$response = Volt::test('auth.reset-password', ['token' => $notification->token])
|
||||
->set('email', $user->email)
|
||||
->set('password', 'password')
|
||||
|
|
@ -59,7 +63,7 @@ test('password can be reset with valid token', function () {
|
|||
|
||||
$response
|
||||
->assertHasNoErrors()
|
||||
->assertRedirect(route('login', absolute: false));
|
||||
->assertRedirect(route('login'));
|
||||
|
||||
return true;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,14 +1,54 @@
|
|||
<?php
|
||||
|
||||
use App\Models\RegistrationCode;
|
||||
use App\Models\User;
|
||||
use Livewire\Volt\Volt;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
test('registration screen can be rendered', function () {
|
||||
$response = $this->get('/register');
|
||||
test('registration landing page can be rendered for valid role', function () {
|
||||
Role::create([
|
||||
'name' => 'Broker',
|
||||
'guard_name' => 'web',
|
||||
'reg_prefix' => 'M',
|
||||
'can_be_invited' => true,
|
||||
'reg_start_number' => 10000001,
|
||||
]);
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response = $this->get('/reg/m');
|
||||
|
||||
$response->assertOk();
|
||||
});
|
||||
|
||||
test('new users can register', function () {
|
||||
test('registration landing page returns 404 for invalid role', function () {
|
||||
$response = $this->get('/reg/invalid');
|
||||
|
||||
$response->assertNotFound();
|
||||
});
|
||||
|
||||
test('registration requires valid code in session', function () {
|
||||
$response = Volt::test('auth.register')
|
||||
->set('name', 'Test User')
|
||||
->set('email', 'test@example.com')
|
||||
->set('password', 'password')
|
||||
->set('password_confirmation', 'password')
|
||||
->call('register');
|
||||
|
||||
$response->assertHasErrors('registration_code');
|
||||
});
|
||||
|
||||
test('new users can register with valid registration code', function () {
|
||||
$code = RegistrationCode::create([
|
||||
'code' => 'M10000001',
|
||||
'role' => 'broker',
|
||||
'name' => 'Test Makler',
|
||||
'status' => RegistrationCode::STATUS_AVAILABLE,
|
||||
]);
|
||||
|
||||
session([
|
||||
'registration_code_id' => $code->id,
|
||||
'registration_role' => 'broker',
|
||||
]);
|
||||
|
||||
$response = Volt::test('auth.register')
|
||||
->set('name', 'Test User')
|
||||
->set('email', 'test@example.com')
|
||||
|
|
@ -21,4 +61,7 @@ test('new users can register', function () {
|
|||
->assertRedirect(route('dashboard', absolute: false));
|
||||
|
||||
$this->assertAuthenticated();
|
||||
|
||||
expect(User::where('email', 'test@example.com')->exists())->toBeTrue();
|
||||
expect($code->fresh()->status)->toBe(RegistrationCode::STATUS_USED);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue