diff --git a/app/Domain/Notifications/VacationRequestCreatedOnEmployeeBehalf.php b/app/Domain/Notifications/VacationRequestCreatedOnEmployeeBehalf.php index 7d255ff..cf54b6b 100644 --- a/app/Domain/Notifications/VacationRequestCreatedOnEmployeeBehalf.php +++ b/app/Domain/Notifications/VacationRequestCreatedOnEmployeeBehalf.php @@ -53,10 +53,10 @@ class VacationRequestCreatedOnEmployeeBehalf extends Notification ->greeting(__("Hi :user!", [ "user" => $user, ])) - ->subject(__("Vacation request :title has been created on your behalf.", [ + ->subject(__("Vacation request :title has been created on your behalf", [ "title" => $title, ])) - ->line(__("The vacation request :title has been created correctly by :creator on your behalf in the :appName.", [ + ->line(__("The vacation request :title has been created correctly by user :creator on your behalf in the :appName.", [ "title" => $title, "appName" => $appName, "creator" => $creator, diff --git a/resources/js/Composables/yearPeriodInfo.js b/resources/js/Composables/yearPeriodInfo.js index 98ca027..8425e0a 100644 --- a/resources/js/Composables/yearPeriodInfo.js +++ b/resources/js/Composables/yearPeriodInfo.js @@ -9,4 +9,4 @@ export default function useCurrentYearPeriodInfo() { minDate, maxDate, } -} \ No newline at end of file +} diff --git a/resources/lang/pl.json b/resources/lang/pl.json index 9ef462f..606b379 100644 --- a/resources/lang/pl.json +++ b/resources/lang/pl.json @@ -48,7 +48,7 @@ "Sum:": "Suma:", "Date": "Data", "Day of week": "Dzień tygodnia", - "Start date": "Data rozpoczecia", + "Start date": "Data rozpoczęcia", "End date": "Data zakończenia", "Worked hours": "Ilość godzin", "Hi :user!": "Cześć :user!", @@ -68,9 +68,9 @@ "Vacation request :title has been approved": "Wniosek urlopowy :title został zatwierdzony", "The vacation request :title for user :requester has been approved.": "Wniosek urlopowy :title od użytkownika :requester został zatwierdzony.", "Vacation request :title has been cancelled": "Wniosek urlopowy :title został anulowany", - "The vacation request :title for user :requester has been cancelled.": "Wniosek urlopowy :title od użytkownika :requester został anulowany.", + "The vacation request :title for user :requester has been cancelled.": "Wniosek urlopowy :title od użytkownika :requester został anulowany.", "Vacation request :title has been rejected": "Wniosek urlopowy :title został odrzucony", "The vacation request :title for user :requester has been rejected.": "Wniosek urlopowy :title od użytkownika :requester został odrzucony.", - "Vacation request :title has been created on your behalf.": "Wniosek urlopowy :title został utworzony w Twoim imieniu", - "The vacation request :title has been created correctly by :creator on your behalf in the :appName.": "W systemie :appName został w Twoim imieniu poprawnie utworzony wnioskek urlopowy :title przez :creator" + "Vacation request :title has been created on your behalf": "Wniosek urlopowy :title został utworzony w Twoim imieniu", + "The vacation request :title has been created correctly by user :creator on your behalf in the :appName.": "W systemie :appName został poprawnie utworzony wniosek urlopowy :title w Twoim imieniu przez użytkownika :creator." } diff --git a/tests/Feature/VacationRequestTest.php b/tests/Feature/VacationRequestTest.php index 1bc21d1..5cdc484 100644 --- a/tests/Feature/VacationRequestTest.php +++ b/tests/Feature/VacationRequestTest.php @@ -13,6 +13,7 @@ use Toby\Domain\Enums\VacationRequestState; use Toby\Domain\Enums\VacationType; use Toby\Domain\Events\VacationRequestAcceptedByAdministrative; use Toby\Domain\Events\VacationRequestAcceptedByTechnical; +use Toby\Domain\Events\VacationRequestApproved; use Toby\Domain\Events\VacationRequestRejected; use Toby\Domain\PolishHolidaysRetriever; use Toby\Eloquent\Models\User; @@ -89,6 +90,85 @@ class VacationRequestTest extends FeatureTestCase ]); } + public function testUserCanCreateVacationRequestOnEmployeeBehalf(): void + { + $creator = User::factory()->createQuietly(); + $user = User::factory()->createQuietly(); + + $currentYearPeriod = YearPeriod::current(); + + VacationLimit::factory([ + "days" => 20, + ]) + ->for($user) + ->for($currentYearPeriod) + ->create(); + + $this->actingAs($creator) + ->post("/vacation-requests", [ + "user" => $user->id, + "creator_id" => $creator->id, + "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.", + ]) + ->assertSessionHasNoErrors(); + + $this->assertDatabaseHas("vacation_requests", [ + "user_id" => $user->id, + "creator_id" => $creator->id, + "year_period_id" => $currentYearPeriod->id, + "name" => "1/" . $currentYearPeriod->year, + "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.", + ]); + } + + public function testUserCanCreateVacationRequestOnEmployeeBehalfAndSkipAcceptanceFlow(): void + { + Event::fake(VacationRequestApproved::class); + + $creator = User::factory()->createQuietly(); + $user = User::factory()->createQuietly(); + + $currentYearPeriod = YearPeriod::current(); + + VacationLimit::factory([ + "days" => 20, + ]) + ->for($user) + ->for($currentYearPeriod) + ->create(); + + $this->actingAs($creator) + ->post("/vacation-requests", [ + "user" => $user->id, + "creator_id" => $creator->id, + "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.", + "skipFlow" => 1, + ]) + ->assertSessionHasNoErrors(); + + $this->assertDatabaseHas("vacation_requests", [ + "user_id" => $user->id, + "creator_id" => $creator->id, + "year_period_id" => $currentYearPeriod->id, + "name" => "1/" . $currentYearPeriod->year, + "type" => VacationType::Vacation->value, + "state" => VacationRequestState::Approved, + "from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(), + "to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(), + "comment" => "Comment for the vacation request.", + ]); + } + public function testTechnicalApproverCanApproveVacationRequest(): void { Event::fake(VacationRequestAcceptedByTechnical::class);