first commit
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled

This commit is contained in:
brusnitsyn
2026-04-06 00:06:00 +09:00
commit fb2e6c58e3
409 changed files with 42953 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
<?php
use App\Models\Department;
use App\Models\DepartmentProfile;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Inertia\Testing\AssertableInertia as Assert;
uses(RefreshDatabase::class);
test('authenticated users can open the departments reference page', function () {
$user = User::factory()->create();
$departmentProfile = DepartmentProfile::factory()->create([
'name' => 'Диагностический профиль',
]);
$department = Department::factory()->create([
'name' => 'Рентген-отделение',
'department_profile_id' => $departmentProfile->id,
]);
$response = $this
->actingAs($user)
->get(route('references.departments.index', ['current_team' => $user->currentTeam->slug]));
$response
->assertOk()
->assertInertia(fn (Assert $page) => $page
->component('references/departments/Index')
->where('departmentProfiles.0.name', 'Диагностический профиль')
->where('departments.0.name', 'Рентген-отделение')
->where('departments.0.departmentProfile.name', 'Диагностический профиль'));
});
test('authenticated users can create a department profile', function () {
$user = User::factory()->create();
$response = $this
->actingAs($user)
->post(route('references.department-profiles.store', ['current_team' => $user->currentTeam->slug]), [
'name' => 'Хирургический профиль',
]);
$response->assertRedirect(route('references.departments.index', ['current_team' => $user->currentTeam->slug]));
$this->assertDatabaseHas('department_profiles', [
'name' => 'Хирургический профиль',
]);
});
test('authenticated users can create a department', function () {
$user = User::factory()->create();
$departmentProfile = DepartmentProfile::factory()->create();
$response = $this
->actingAs($user)
->post(route('references.departments.store', ['current_team' => $user->currentTeam->slug]), [
'name' => 'Терапевтическое отделение',
'department_profile_id' => $departmentProfile->id,
'is_active' => true,
]);
$response->assertRedirect(route('references.departments.index', ['current_team' => $user->currentTeam->slug]));
$this->assertDatabaseHas('departments', [
'name' => 'Терапевтическое отделение',
'department_profile_id' => $departmentProfile->id,
'is_active' => true,
]);
});