64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
use App\Livewire\Dashboard\Index as DashboardIndex;
|
|
use App\Models\Role;
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Livewire\Livewire;
|
|
|
|
uses(\Illuminate\Foundation\Testing\RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
$this->seed(\Database\Seeders\RolesSeeder::class);
|
|
|
|
$this->tenant = Tenant::firstOrCreate(
|
|
['name' => 'Test Schule'],
|
|
['type' => 'school', 'active' => true]
|
|
);
|
|
|
|
$this->user = User::withoutGlobalScopes()->create([
|
|
'name' => 'Lina Test',
|
|
'email' => 'lina@test.example',
|
|
'tenant_id' => $this->tenant->id,
|
|
'password' => bcrypt('password'),
|
|
]);
|
|
|
|
$childRole = Role::where('name', 'child')->first();
|
|
DB::table('role_user')->insert([
|
|
'user_id' => $this->user->id,
|
|
'role_id' => $childRole->id,
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
});
|
|
|
|
it('rendert ohne Fehler bei eingeloggtem child-User', function () {
|
|
$this->actingAs($this->user);
|
|
|
|
Livewire::test(DashboardIndex::class)
|
|
->assertStatus(200)
|
|
->assertSee('Hallo')
|
|
->assertSee('Meine Fächer')
|
|
->assertSee('Heutige Aufgaben');
|
|
});
|
|
|
|
it('zeigt Gamification-Werte: Punkte + Streak + Wochenminuten', function () {
|
|
$this->actingAs($this->user);
|
|
|
|
Livewire::test(DashboardIndex::class)
|
|
->assertSee('2.480')
|
|
->assertSee('7')
|
|
->assertSee('Tage');
|
|
});
|
|
|
|
it('zeigt 4 Stat-Tiles', function () {
|
|
$this->actingAs($this->user);
|
|
|
|
Livewire::test(DashboardIndex::class)
|
|
->assertSeeText('Gesamtpunkte')
|
|
->assertSeeText('Lernserie')
|
|
->assertSeeText('Diese Woche')
|
|
->assertSeeText('Bestandene Tests');
|
|
});
|