50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Livewire\Onboarding\Tour;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
class OnboardingTourTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_autostart_is_true_only_when_the_tour_was_never_dismissed(): void
|
|
{
|
|
Livewire::actingAs(User::factory()->create(['onboarding_tour_completed_at' => null]))
|
|
->test(Tour::class)->assertSet('autostart', true);
|
|
|
|
Livewire::actingAs(User::factory()->create(['onboarding_tour_completed_at' => now()]))
|
|
->test(Tour::class)->assertSet('autostart', false);
|
|
}
|
|
|
|
public function test_mark_seen_stamps_the_account_once(): void
|
|
{
|
|
$user = User::factory()->create(['onboarding_tour_completed_at' => null]);
|
|
|
|
Livewire::actingAs($user)->test(Tour::class)->call('markSeen');
|
|
|
|
$this->assertNotNull($user->fresh()->onboarding_tour_completed_at);
|
|
}
|
|
|
|
public function test_mark_seen_does_not_overwrite_an_existing_stamp(): void
|
|
{
|
|
$stamp = now()->subDays(3);
|
|
$user = User::factory()->create(['onboarding_tour_completed_at' => $stamp]);
|
|
|
|
Livewire::actingAs($user)->test(Tour::class)->call('markSeen');
|
|
|
|
$this->assertEquals($stamp->timestamp, $user->fresh()->onboarding_tour_completed_at->timestamp);
|
|
}
|
|
|
|
public function test_the_tour_renders_all_six_steps_on_the_panel(): void
|
|
{
|
|
$this->actingAs(User::factory()->create(['must_change_password' => false]));
|
|
|
|
$this->get('/')->assertOk()->assertSee(__('onboarding.welcome_title'))->assertSee(__('onboarding.done_title'));
|
|
}
|
|
}
|