128 lines
4.1 KiB
PHP
128 lines
4.1 KiB
PHP
<?php
|
|
|
|
use App\Livewire\Notifications\Index as NotificationsIndex;
|
|
use App\Livewire\PhotoHelp\Index as PhotoHelpIndex;
|
|
use App\Livewire\Progress\Index as ProgressIndex;
|
|
use App\Livewire\Rewards\Index as RewardsIndex;
|
|
use App\Livewire\Settings\Index as SettingsIndex;
|
|
use App\Livewire\Subjects\Index as SubjectsIndex;
|
|
use App\Livewire\Tasks\Index as TasksIndex;
|
|
use App\Models\License;
|
|
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' => 'Sidebar Tester',
|
|
'email' => 'sidebar@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(),
|
|
]);
|
|
|
|
$license = License::withoutGlobalScopes()->create([
|
|
'tenant_id' => $this->tenant->id,
|
|
'type' => 'school_flat',
|
|
'seats' => null,
|
|
'expires_at' => now()->addYear(),
|
|
'active' => true,
|
|
]);
|
|
|
|
DB::table('license_assignments')->insert([
|
|
'license_id' => $license->id,
|
|
'user_id' => $this->user->id,
|
|
'created_at' => now(),
|
|
'updated_at' => now(),
|
|
]);
|
|
});
|
|
|
|
it('Subjects page renders for authenticated user', function () {
|
|
$this->actingAs($this->user);
|
|
Livewire::test(SubjectsIndex::class)->assertStatus(200)->assertSee('Meine Fächer');
|
|
});
|
|
|
|
it('Tasks page renders for authenticated user', function () {
|
|
$this->actingAs($this->user);
|
|
Livewire::test(TasksIndex::class)->assertStatus(200)->assertSee('Aufgaben');
|
|
});
|
|
|
|
it('PhotoHelp page renders for authenticated user', function () {
|
|
$this->actingAs($this->user);
|
|
Livewire::test(PhotoHelpIndex::class)->assertStatus(200)->assertSee('Foto');
|
|
});
|
|
|
|
it('Rewards page renders for authenticated user', function () {
|
|
$this->actingAs($this->user);
|
|
Livewire::test(RewardsIndex::class)->assertStatus(200)->assertSee('Belohnungen');
|
|
});
|
|
|
|
it('Progress page renders for authenticated user', function () {
|
|
$this->actingAs($this->user);
|
|
Livewire::test(ProgressIndex::class)->assertStatus(200)->assertSee('Fortschritt');
|
|
});
|
|
|
|
it('Notifications page renders for authenticated user', function () {
|
|
$this->actingAs($this->user);
|
|
Livewire::test(NotificationsIndex::class)->assertStatus(200)->assertSee('Mitteilungen');
|
|
});
|
|
|
|
it('Settings page renders for authenticated user', function () {
|
|
$this->actingAs($this->user);
|
|
Livewire::test(SettingsIndex::class)->assertStatus(200)->assertSee('Einstellungen');
|
|
});
|
|
|
|
it('Subjects route is reachable when authenticated', function () {
|
|
$this->actingAs($this->user);
|
|
$this->get(route('subjects'))->assertStatus(200);
|
|
});
|
|
|
|
it('Tasks route is reachable when authenticated', function () {
|
|
$this->actingAs($this->user);
|
|
$this->get(route('tasks'))->assertStatus(200);
|
|
});
|
|
|
|
it('Settings route is reachable when authenticated', function () {
|
|
$this->actingAs($this->user);
|
|
$this->get(route('settings'))->assertStatus(200);
|
|
});
|
|
|
|
it('all sidebar config routes resolve', function () {
|
|
foreach (config('sidebar.groups') as $group) {
|
|
foreach ($group['items'] as $item) {
|
|
expect(\Illuminate\Support\Facades\Route::has($item['route']))
|
|
->toBeTrue("Route {$item['route']} is not registered");
|
|
}
|
|
}
|
|
});
|
|
|
|
it('sidebar config groups have label + items[] structure', function () {
|
|
$groups = config('sidebar.groups');
|
|
expect($groups)->toBeArray()->not->toBeEmpty();
|
|
|
|
foreach ($groups as $group) {
|
|
expect($group)->toHaveKeys(['label', 'items']);
|
|
foreach ($group['items'] as $item) {
|
|
expect($item)->toHaveKeys(['key', 'route', 'label', 'icon']);
|
|
}
|
|
}
|
|
});
|