- small changes (#98)
* - added some test * - cr fix * wip * wip * Update resources/js/Shared/MainMenu.vue Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * fix Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
This commit is contained in:
@@ -40,7 +40,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testUserCanSeeVacationRequestsList(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationRequest::factory()
|
||||
@@ -50,7 +50,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->get("/vacation-requests/me")
|
||||
->get("/vacation/requests/me")
|
||||
->assertOk()
|
||||
->assertInertia(
|
||||
fn(Assert $page) => $page
|
||||
@@ -61,7 +61,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testUserCanCreateVacationRequest(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
@@ -73,7 +73,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
->post("/vacation/requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
@@ -95,8 +95,8 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testUserCanCreateVacationRequestOnEmployeeBehalf(): void
|
||||
{
|
||||
$creator = User::factory()->admin()->createQuietly();
|
||||
$user = User::factory()->createQuietly();
|
||||
$creator = User::factory()->admin()->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
@@ -108,7 +108,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($creator)
|
||||
->post("/vacation-requests", [
|
||||
->post("/vacation/requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
@@ -131,8 +131,8 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testUserCanCreateVacationRequestOnEmployeeBehalfAndSkipAcceptanceFlow(): void
|
||||
{
|
||||
$creator = User::factory()->admin()->createQuietly();
|
||||
$user = User::factory()->createQuietly();
|
||||
$creator = User::factory()->admin()->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
@@ -144,7 +144,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($creator)
|
||||
->post("/vacation-requests", [
|
||||
->post("/vacation/requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
@@ -168,8 +168,8 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testTechnicalApproverCanApproveVacationRequest(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$technicalApprover = User::factory()->technicalApprover()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$technicalApprover = User::factory()->technicalApprover()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
$vacationRequest = VacationRequest::factory([
|
||||
@@ -181,7 +181,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($technicalApprover)
|
||||
->post("/vacation-requests/{$vacationRequest->id}/accept-as-technical")
|
||||
->post("/vacation/requests/{$vacationRequest->id}/accept-as-technical")
|
||||
->assertRedirect();
|
||||
|
||||
$vacationRequest->refresh();
|
||||
@@ -191,8 +191,8 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testAdministrativeApproverCanApproveVacationRequest(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$administrativeApprover = User::factory()->administrativeApprover()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$administrativeApprover = User::factory()->administrativeApprover()->create();
|
||||
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
@@ -204,7 +204,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($administrativeApprover)
|
||||
->post("/vacation-requests/{$vacationRequest->id}/accept-as-administrative")
|
||||
->post("/vacation/requests/{$vacationRequest->id}/accept-as-administrative")
|
||||
->assertRedirect();
|
||||
|
||||
$vacationRequest->refresh();
|
||||
@@ -214,8 +214,8 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testTechnicalApproverCanRejectVacationRequest(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$technicalApprover = User::factory()->technicalApprover()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$technicalApprover = User::factory()->technicalApprover()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
@@ -235,7 +235,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($technicalApprover)
|
||||
->post("/vacation-requests/{$vacationRequest->id}/reject")
|
||||
->post("/vacation/requests/{$vacationRequest->id}/reject")
|
||||
->assertRedirect();
|
||||
|
||||
$vacationRequest->refresh();
|
||||
@@ -245,7 +245,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testUserCannotCreateVacationRequestIfHeExceedsHisVacationLimit(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
@@ -256,7 +256,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
->post("/vacation/requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
@@ -270,7 +270,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testUserCannotCreateVacationRequestAtWeekend(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
@@ -281,7 +281,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
->post("/vacation/requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 5)->toDateString(),
|
||||
@@ -295,7 +295,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testUserCannotCreateVacationRequestAtHoliday(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
@@ -313,7 +313,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
}
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
->post("/vacation/requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
|
||||
@@ -327,7 +327,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testUserCannotCreateVacationRequestIfHeHasPendingVacationRequestInThisRange(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
@@ -349,7 +349,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
->post("/vacation/requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||
@@ -363,7 +363,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testUserCannotCreateVacationRequestIfHeHasApprovedVacationRequestInThisRange(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
@@ -385,7 +385,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
->post("/vacation/requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||
@@ -399,10 +399,10 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testUserCannotCreateVacationRequestWithEndDatePriorToTheStartDate(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
->post("/vacation/requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
@@ -416,11 +416,11 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testUserCannotCreateVacationRequestAtTheTurnOfTheYear(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
$nextYearPeriod = $this->createYearPeriod(Carbon::now()->year + 1);
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
->post("/vacation/requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 12, 27)->toDateString(),
|
||||
@@ -434,22 +434,22 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testEmployeeCanSeeOnlyHisVacationRequests(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->get("/vacation-requests")
|
||||
->assertRedirect("/vacation-requests/me");
|
||||
->get("/vacation/requests")
|
||||
->assertRedirect("/vacation/requests/me");
|
||||
}
|
||||
|
||||
public function testEmployeeCannotCreateVacationRequestForAnotherEmployee(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$anotherUser = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$anotherUser = User::factory()->create();
|
||||
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
->post("/vacation/requests", [
|
||||
"user" => $anotherUser->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
@@ -461,7 +461,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testEmployeeCanCancelVacationRequestWithWaitingForAdministrativeStatus(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
@@ -481,7 +481,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests/{$vacationRequest->id}/cancel")
|
||||
->post("/vacation/requests/{$vacationRequest->id}/cancel")
|
||||
->assertRedirect();
|
||||
|
||||
$vacationRequest->refresh();
|
||||
@@ -491,7 +491,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testEmployeeCannotCancelVacationRequestWithApprovedStatus(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
@@ -511,14 +511,14 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests/{$vacationRequest->id}/cancel")
|
||||
->post("/vacation/requests/{$vacationRequest->id}/cancel")
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testAdministrativeApproverCanCancelVacationRequestWithApprovedStatus(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$administrativeApprover = User::factory()->administrativeApprover()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$administrativeApprover = User::factory()->administrativeApprover()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
@@ -538,7 +538,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($administrativeApprover)
|
||||
->post("/vacation-requests/{$vacationRequest->id}/cancel")
|
||||
->post("/vacation/requests/{$vacationRequest->id}/cancel")
|
||||
->assertRedirect();
|
||||
|
||||
$vacationRequest->refresh();
|
||||
@@ -548,7 +548,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
public function testEmployeeCanDownloadHisVacationRequestAsPdf(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
@@ -568,14 +568,14 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->get("/vacation-requests/{$vacationRequest->id}/download")
|
||||
->get("/vacation/requests/{$vacationRequest->id}/download")
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
public function testEmployeeCannotDownloadAnotherEmployeesVacationRequestAsPdf(): void
|
||||
{
|
||||
$user = User::factory()->createQuietly();
|
||||
$anotherUser = User::factory()->createQuietly();
|
||||
$user = User::factory()->create();
|
||||
$anotherUser = User::factory()->create();
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
@@ -595,7 +595,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->get("/vacation-requests/{$vacationRequest->id}/download")
|
||||
->get("/vacation/requests/{$vacationRequest->id}/download")
|
||||
->assertForbidden();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user