* fix css focuses * #90 - wip * #90 - fix to generate PDF * #90 - wip * #90 - wip * #90 - wip * #90 - wip * #90 - fix to calendar * #90 - wip * #90 - fix * #90 - fix lint * #90 - fix * Apply suggestions from code review Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * #90 - cr fixes * #90 - fix Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl> Co-authored-by: Krzysztof Rewak <krzysztof.rewak@gmail.com> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
This commit is contained in:
@@ -25,6 +25,7 @@ class HolidayTest extends FeatureTestCase
|
||||
|
||||
$this->actingAs($user)
|
||||
->get("/holidays")
|
||||
->assertOk()
|
||||
->assertInertia(
|
||||
fn(Assert $page) => $page
|
||||
->component("Holidays/Index")
|
||||
|
38
tests/Feature/TrackLastActivityMiddlewareTest.php
Normal file
38
tests/Feature/TrackLastActivityMiddlewareTest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Tests\FeatureTestCase;
|
||||
use Toby\Eloquent\Models\User;
|
||||
|
||||
class TrackLastActivityMiddlewareTest extends FeatureTestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
public function testLastActiveAtFieldIsUpdatedWhenUserDidRequest(): void
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
Carbon::setTestNow($now);
|
||||
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->assertDatabaseHas("users", [
|
||||
"id" => $user->id,
|
||||
"last_active_at" => null,
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get("/")
|
||||
->assertOk();
|
||||
|
||||
$this->assertDatabaseHas("users", [
|
||||
"id" => $user->id,
|
||||
"last_active_at" => $now,
|
||||
]);
|
||||
}
|
||||
}
|
@@ -34,25 +34,30 @@ class UserTest extends FeatureTestCase
|
||||
|
||||
public function testAdminCanSearchUsersList(): void
|
||||
{
|
||||
User::factory([
|
||||
"first_name" => "Test",
|
||||
"last_name" => "User1",
|
||||
])->create();
|
||||
User::factory()
|
||||
->hasprofile([
|
||||
"first_name" => "Test",
|
||||
"last_name" => "User1",
|
||||
])
|
||||
->create();
|
||||
|
||||
User::factory([
|
||||
"first_name" => "Test",
|
||||
"last_name" => "User2",
|
||||
])->create();
|
||||
User::factory()
|
||||
->hasProfile([
|
||||
"first_name" => "Test",
|
||||
"last_name" => "User2",
|
||||
])->create();
|
||||
|
||||
User::factory([
|
||||
"first_name" => "Test",
|
||||
"last_name" => "User3",
|
||||
])->create();
|
||||
User::factory()
|
||||
->hasProfile([
|
||||
"first_name" => "Test",
|
||||
"last_name" => "User3",
|
||||
])->create();
|
||||
|
||||
$admin = User::factory([
|
||||
"first_name" => "John",
|
||||
"last_name" => "Doe",
|
||||
])->admin()->create();
|
||||
$admin = User::factory()
|
||||
->hasProfile([
|
||||
"first_name" => "John",
|
||||
"last_name" => "Doe",
|
||||
])->admin()->create();
|
||||
|
||||
$this->assertDatabaseCount("users", 4);
|
||||
|
||||
@@ -99,11 +104,20 @@ class UserTest extends FeatureTestCase
|
||||
])
|
||||
->assertSessionHasNoErrors();
|
||||
|
||||
$user = User::query()
|
||||
->where("email", "john.doe@example.com")
|
||||
->first();
|
||||
|
||||
$this->assertDatabaseHas("users", [
|
||||
"first_name" => "John",
|
||||
"last_name" => "Doe",
|
||||
"id" => $user->id,
|
||||
"email" => "john.doe@example.com",
|
||||
"role" => Role::Employee->value,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas("profiles", [
|
||||
"user_id" => $user->id,
|
||||
"first_name" => "John",
|
||||
"last_name" => "Doe",
|
||||
"position" => "Test position",
|
||||
"employment_form" => EmploymentForm::B2bContract->value,
|
||||
"employment_date" => Carbon::now()->toDateString(),
|
||||
@@ -118,12 +132,12 @@ class UserTest extends FeatureTestCase
|
||||
|
||||
Carbon::setTestNow();
|
||||
|
||||
$this->assertDatabaseHas("users", [
|
||||
"first_name" => $user->first_name,
|
||||
"last_name" => $user->last_name,
|
||||
"email" => $user->email,
|
||||
"employment_form" => $user->employment_form->value,
|
||||
"employment_date" => $user->employment_date->toDateString(),
|
||||
$this->assertDatabaseHas("profiles", [
|
||||
"user_id" => $user->id,
|
||||
"first_name" => $user->profile->first_name,
|
||||
"last_name" => $user->profile->last_name,
|
||||
"employment_form" => $user->profile->employment_form->value,
|
||||
"employment_date" => $user->profile->employment_date->toDateString(),
|
||||
]);
|
||||
|
||||
$this->actingAs($admin)
|
||||
@@ -139,10 +153,15 @@ class UserTest extends FeatureTestCase
|
||||
->assertSessionHasNoErrors();
|
||||
|
||||
$this->assertDatabaseHas("users", [
|
||||
"first_name" => "John",
|
||||
"last_name" => "Doe",
|
||||
"id" => $user->id,
|
||||
"email" => "john.doe@example.com",
|
||||
"role" => Role::Employee->value,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas("profiles", [
|
||||
"user_id" => $user->id,
|
||||
"first_name" => "John",
|
||||
"last_name" => "Doe",
|
||||
"position" => "Test position",
|
||||
"employment_form" => EmploymentForm::B2bContract->value,
|
||||
"employment_date" => Carbon::now()->toDateString(),
|
||||
|
@@ -17,7 +17,8 @@ class VacationCalendarTest extends FeatureTestCase
|
||||
{
|
||||
$administrativeApprover = User::factory()->administrativeApprover()->create();
|
||||
|
||||
User::factory(["employment_form" => EmploymentForm::EmploymentContract])
|
||||
User::factory()
|
||||
->hasProfile(["employment_form" => EmploymentForm::EmploymentContract])
|
||||
->count(10)
|
||||
->create();
|
||||
|
||||
|
@@ -9,6 +9,7 @@ use Tests\TestCase;
|
||||
use Tests\Traits\InteractsWithYearPeriods;
|
||||
use Toby\Domain\Actions\CreateUserAction;
|
||||
use Toby\Domain\Actions\CreateYearPeriodAction;
|
||||
use Toby\Eloquent\Models\Profile;
|
||||
use Toby\Eloquent\Models\User;
|
||||
use Toby\Eloquent\Models\YearPeriod;
|
||||
|
||||
@@ -31,9 +32,10 @@ class VacationLimitTest extends TestCase
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
$createUserAction = $this->app->make(CreateUserAction::class);
|
||||
|
||||
$dumpData = User::factory()->raw();
|
||||
$dumpUserData = User::factory()->raw();
|
||||
$dumpProfileData = Profile::factory()->raw();
|
||||
|
||||
$user = $createUserAction->execute($dumpData);
|
||||
$user = $createUserAction->execute($dumpUserData, $dumpProfileData);
|
||||
|
||||
$this->assertDatabaseCount("vacation_limits", 1);
|
||||
|
||||
|
Reference in New Issue
Block a user