Merge branch 'main' into #41-email-notifications

# Conflicts:
#	app/Domain/CalendarGenerator.php
#	app/Domain/Enums/VacationRequestState.php
#	app/Domain/VacationRequestStateManager.php
#	resources/js/Composables/statusInfo.js
#	resources/js/Pages/Calendar.vue
#	resources/js/Shared/MainMenu.vue
#	resources/lang/pl.json
#	tests/Feature/VacationRequestTest.php
#	tests/Unit/VacationRequestStatesTest.php
This commit is contained in:
EwelinaLasowy
2022-02-16 08:53:55 +01:00
31 changed files with 256 additions and 175 deletions

View File

@@ -88,10 +88,10 @@ class UserTest extends FeatureTestCase
->post("/users", [
"firstName" => "John",
"lastName" => "Doe",
"role" => Role::EMPLOYEE->value,
"role" => Role::Employee->value,
"position" => "Test position",
"email" => "john.doe@example.com",
"employmentForm" => EmploymentForm::B2B_CONTRACT->value,
"employmentForm" => EmploymentForm::B2bContract->value,
"employmentDate" => Carbon::now()->toDateString(),
])
->assertSessionHasNoErrors();
@@ -100,9 +100,9 @@ class UserTest extends FeatureTestCase
"first_name" => "John",
"last_name" => "Doe",
"email" => "john.doe@example.com",
"role" => Role::EMPLOYEE->value,
"role" => Role::Employee->value,
"position" => "Test position",
"employment_form" => EmploymentForm::B2B_CONTRACT->value,
"employment_form" => EmploymentForm::B2bContract->value,
"employment_date" => Carbon::now()->toDateString(),
]);
}
@@ -127,9 +127,9 @@ class UserTest extends FeatureTestCase
"firstName" => "John",
"lastName" => "Doe",
"email" => "john.doe@example.com",
"role" => Role::EMPLOYEE->value,
"role" => Role::Employee->value,
"position" => "Test position",
"employmentForm" => EmploymentForm::B2B_CONTRACT->value,
"employmentForm" => EmploymentForm::B2bContract->value,
"employmentDate" => Carbon::now()->toDateString(),
])
->assertSessionHasNoErrors();
@@ -138,9 +138,9 @@ class UserTest extends FeatureTestCase
"first_name" => "John",
"last_name" => "Doe",
"email" => "john.doe@example.com",
"role" => Role::EMPLOYEE->value,
"role" => Role::Employee->value,
"position" => "Test position",
"employment_form" => EmploymentForm::B2B_CONTRACT->value,
"employment_form" => EmploymentForm::B2bContract->value,
"employment_date" => Carbon::now()->toDateString(),
]);
}

View File

@@ -65,7 +65,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user)
->post("/vacation-requests", [
"type" => VacationType::VACATION->value,
"type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
"comment" => "Comment for the vacation request.",
@@ -76,8 +76,8 @@ class VacationRequestTest extends FeatureTestCase
"user_id" => $user->id,
"year_period_id" => $currentYearPeriod->id,
"name" => "1/" . $currentYearPeriod->year,
"type" => VacationType::VACATION->value,
"state" => VacationRequestState::WAITING_FOR_TECHNICAL,
"type" => VacationType::Vacation->value,
"state" => VacationRequestState::WaitingForTechnical,
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
"comment" => "Comment for the vacation request.",
@@ -91,8 +91,8 @@ class VacationRequestTest extends FeatureTestCase
$currentYearPeriod = YearPeriod::current();
$vacationRequest = VacationRequest::factory([
"state" => VacationRequestState::WAITING_FOR_TECHNICAL,
"type" => VacationType::VACATION,
"state" => VacationRequestState::WaitingForTechnical,
"type" => VacationType::Vacation,
])
->for($user)
->for($currentYearPeriod)
@@ -103,7 +103,7 @@ class VacationRequestTest extends FeatureTestCase
->assertSessionHasNoErrors();
$this->assertDatabaseHas("vacation_requests", [
"state" => VacationRequestState::WAITING_FOR_ADMINISTRATIVE,
"state" => VacationRequestState::WaitingForAdministrative,
]);
}
@@ -115,7 +115,7 @@ class VacationRequestTest extends FeatureTestCase
$currentYearPeriod = YearPeriod::current();
$vacationRequest = VacationRequest::factory([
"state" => VacationRequestState::WAITING_FOR_ADMINISTRATIVE,
"state" => VacationRequestState::WaitingForAdministrative,
])
->for($user)
->for($currentYearPeriod)
@@ -126,7 +126,7 @@ class VacationRequestTest extends FeatureTestCase
->assertSessionHasNoErrors();
$this->assertDatabaseHas("vacation_requests", [
"state" => VacationRequestState::APPROVED,
"state" => VacationRequestState::Approved,
]);
}
@@ -144,8 +144,8 @@ class VacationRequestTest extends FeatureTestCase
->create();
$vacationRequest = VacationRequest::factory([
"state" => VacationRequestState::WAITING_FOR_TECHNICAL,
"type" => VacationType::VACATION,
"state" => VacationRequestState::WaitingForTechnical,
"type" => VacationType::Vacation,
])
->for($user)
->for($currentYearPeriod)
@@ -156,7 +156,7 @@ class VacationRequestTest extends FeatureTestCase
->assertSessionHasNoErrors();
$this->assertDatabaseHas("vacation_requests", [
"state" => VacationRequestState::REJECTED,
"state" => VacationRequestState::Rejected,
]);
}
@@ -174,7 +174,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user)
->post("/vacation-requests", [
"type" => VacationType::VACATION->value,
"type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
"comment" => "Comment for the vacation request.",
@@ -198,7 +198,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user)
->post("/vacation-requests", [
"type" => VacationType::VACATION->value,
"type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 2, 5)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 6)->toDateString(),
"comment" => "Vacation at weekend.",
@@ -229,7 +229,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user)
->post("/vacation-requests", [
"type" => VacationType::VACATION->value,
"type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
"comment" => "Vacation at holiday.",
@@ -252,8 +252,8 @@ class VacationRequestTest extends FeatureTestCase
->create();
VacationRequest::factory([
"type" => VacationType::VACATION->value,
"state" => VacationRequestState::WAITING_FOR_TECHNICAL,
"type" => VacationType::Vacation->value,
"state" => VacationRequestState::WaitingForTechnical,
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
"comment" => "Comment for the vacation request.",
@@ -264,7 +264,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user)
->post("/vacation-requests", [
"type" => VacationType::VACATION->value,
"type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
"comment" => "Another comment for the another vacation request.",
@@ -288,8 +288,8 @@ class VacationRequestTest extends FeatureTestCase
->create();
VacationRequest::factory([
"type" => VacationType::VACATION->value,
"state" => VacationRequestState::APPROVED,
"type" => VacationType::Vacation->value,
"state" => VacationRequestState::Approved,
"from" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
"comment" => "Comment for the vacation request.",
@@ -300,7 +300,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user)
->post("/vacation-requests", [
"type" => VacationType::VACATION->value,
"type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
"comment" => "Another comment for the another vacation request.",
@@ -316,7 +316,7 @@ class VacationRequestTest extends FeatureTestCase
$currentYearPeriod = YearPeriod::current();
$this->actingAs($user)
->post("/vacation-requests", [
"type" => VacationType::VACATION->value,
"type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 6)->toDateString(),
"comment" => "Comment for the vacation request.",
@@ -333,7 +333,7 @@ class VacationRequestTest extends FeatureTestCase
$nextYearPeriod = $this->createYearPeriod(Carbon::now()->year + 1);
$this->actingAs($user)
->post("/vacation-requests", [
"type" => VacationType::VACATION->value,
"type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 12, 27)->toDateString(),
"to" => Carbon::create($nextYearPeriod->year, 1, 2)->toDateString(),
"comment" => "Comment for the vacation request.",

View File

@@ -5,14 +5,11 @@ declare(strict_types=1);
namespace Tests\Unit;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Carbon;
use Tests\TestCase;
use Tests\Traits\InteractsWithYearPeriods;
use Toby\Domain\Enums\Role;
use Toby\Domain\Enums\VacationRequestState;
use Toby\Domain\Enums\VacationType;
use Toby\Domain\Notifications\VacationRequestNotification;
use Toby\Domain\VacationRequestStateManager;
use Toby\Eloquent\Models\User;
use Toby\Eloquent\Models\VacationRequest;
@@ -42,8 +39,8 @@ class VacationRequestStatesTest extends TestCase
/** @var VacationRequest $vacationRequest */
$vacationRequest = VacationRequest::factory([
"type" => VacationType::VACATION->value,
"state" => VacationRequestState::CREATED,
"type" => VacationType::Vacation->value,
"state" => VacationRequestState::Created,
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
"comment" => "Comment for the vacation request.",
@@ -54,7 +51,7 @@ class VacationRequestStatesTest extends TestCase
$this->stateManager->waitForTechnical($vacationRequest);
$this->assertEquals(VacationRequestState::WAITING_FOR_TECHNICAL, $vacationRequest->state);
$this->assertEquals(VacationRequestState::WaitingForTechnical, $vacationRequest->state);
}
public function testAfterCreatingVacationRequestOfTypeSickVacationItTransitsToProperState(): void
@@ -65,8 +62,8 @@ class VacationRequestStatesTest extends TestCase
/** @var VacationRequest $vacationRequest */
$vacationRequest = VacationRequest::factory([
"type" => VacationType::SICK_VACATION->value,
"state" => VacationRequestState::CREATED,
"type" => VacationType::Sick->value,
"state" => VacationRequestState::Created,
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
])
@@ -76,7 +73,7 @@ class VacationRequestStatesTest extends TestCase
$this->stateManager->approve($vacationRequest);
$this->assertEquals(VacationRequestState::APPROVED, $vacationRequest->state);
$this->assertEquals(VacationRequestState::Approved, $vacationRequest->state);
}
public function testAfterCreatingVacationRequestOfTypeTimeInLieuItTransitsToProperState(): void
@@ -87,8 +84,8 @@ class VacationRequestStatesTest extends TestCase
/** @var VacationRequest $vacationRequest */
$vacationRequest = VacationRequest::factory([
"type" => VacationType::TIME_IN_LIEU->value,
"state" => VacationRequestState::CREATED,
"type" => VacationType::TimeInLieu->value,
"state" => VacationRequestState::Created,
"from" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(),
])
@@ -98,6 +95,6 @@ class VacationRequestStatesTest extends TestCase
$this->stateManager->approve($vacationRequest);
$this->assertEquals(VacationRequestState::APPROVED, $vacationRequest->state);
$this->assertEquals(VacationRequestState::Approved, $vacationRequest->state);
}
}