Added tests

This commit is contained in:
Constantin Graf
2024-04-15 19:25:09 +02:00
parent feb70910c7
commit eea5a3d01b
8 changed files with 87 additions and 2 deletions

View File

@@ -31,13 +31,14 @@ class ProfileInformationTest extends TestCase
{ {
// Arrange // Arrange
$user = User::factory()->create(); $user = User::factory()->create();
$timezone = app(TimezoneService::class)->getTimezones()[0];
$this->actingAs($user); $this->actingAs($user);
// Act // Act
$response = $this->put('/user/profile-information', [ $response = $this->put('/user/profile-information', [
'name' => 'Test Name', 'name' => 'Test Name',
'email' => 'test@example.com', 'email' => 'test@example.com',
'timezone' => app(TimezoneService::class)->getTimezones()[0], 'timezone' => $timezone,
'week_start' => Weekday::Sunday->value, 'week_start' => Weekday::Sunday->value,
]); ]);
@@ -46,7 +47,7 @@ class ProfileInformationTest extends TestCase
$user = $user->fresh(); $user = $user->fresh();
$this->assertEquals('Test Name', $user->name); $this->assertEquals('Test Name', $user->name);
$this->assertEquals('test@example.com', $user->email); $this->assertEquals('test@example.com', $user->email);
$this->assertEquals(app(TimezoneService::class)->getTimezones()[0], $user->timezone); $this->assertEquals($timezone, $user->timezone);
$this->assertEquals(Weekday::Sunday, $user->week_start); $this->assertEquals(Weekday::Sunday, $user->week_start);
} }
} }

View File

@@ -35,4 +35,16 @@ class ClientResourceTest extends FilamentTestCase
$response->assertSuccessful(); $response->assertSuccessful();
$response->assertCanSeeTableRecords($clients); $response->assertCanSeeTableRecords($clients);
} }
public function test_can_see_edit_page_of_client(): void
{
// Arrange
$client = Client::factory()->create();
// Act
$response = Livewire::test(ClientResource\Pages\EditClient::class, ['record' => $client->getKey()]);
// Assert
$response->assertSuccessful();
}
} }

View File

@@ -38,4 +38,16 @@ class OrganizationResourceTest extends FilamentTestCase
$response->assertSuccessful(); $response->assertSuccessful();
$response->assertCanSeeTableRecords($organizations); $response->assertCanSeeTableRecords($organizations);
} }
public function test_can_see_edit_page_of_organization(): void
{
// Arrange
$organization = Organization::factory()->create();
// Act
$response = Livewire::test(OrganizationResource\Pages\EditOrganization::class, ['record' => $organization->getKey()]);
// Assert
$response->assertSuccessful();
}
} }

View File

@@ -35,4 +35,16 @@ class ProjectResourceTest extends FilamentTestCase
$response->assertSuccessful(); $response->assertSuccessful();
$response->assertCanSeeTableRecords($projects); $response->assertCanSeeTableRecords($projects);
} }
public function test_can_see_edit_page_of_project(): void
{
// Arrange
$project = Project::factory()->create();
// Act
$response = Livewire::test(ProjectResource\Pages\EditProject::class, ['record' => $project->getKey()]);
// Assert
$response->assertSuccessful();
}
} }

View File

@@ -35,4 +35,16 @@ class TagResourceTest extends FilamentTestCase
$response->assertSuccessful(); $response->assertSuccessful();
$response->assertCanSeeTableRecords($tags); $response->assertCanSeeTableRecords($tags);
} }
public function test_can_see_edit_page_of_tag(): void
{
// Arrange
$tag = Tag::factory()->create();
// Act
$response = Livewire::test(TagResource\Pages\EditTag::class, ['record' => $tag->getKey()]);
// Assert
$response->assertSuccessful();
}
} }

View File

@@ -35,4 +35,16 @@ class TaskResourceTest extends FilamentTestCase
$response->assertSuccessful(); $response->assertSuccessful();
$response->assertCanSeeTableRecords($tasks); $response->assertCanSeeTableRecords($tasks);
} }
public function test_can_see_edit_page_of_task(): void
{
// Arrange
$task = Task::factory()->create();
// Act
$response = Livewire::test(TaskResource\Pages\EditTask::class, ['record' => $task->getKey()]);
// Assert
$response->assertSuccessful();
}
} }

View File

@@ -35,4 +35,16 @@ class TimeEntryResourceTest extends FilamentTestCase
$response->assertSuccessful(); $response->assertSuccessful();
$response->assertCanSeeTableRecords($timeEntry); $response->assertCanSeeTableRecords($timeEntry);
} }
public function test_can_see_edit_page_of_time_entry(): void
{
// Arrange
$timeEntry = TimeEntry::factory()->create();
// Act
$response = Livewire::test(TimeEntryResource\Pages\EditTimeEntry::class, ['record' => $timeEntry->getKey()]);
// Assert
$response->assertSuccessful();
}
} }

View File

@@ -34,4 +34,16 @@ class UserResourceTest extends FilamentTestCase
$response->assertSuccessful(); $response->assertSuccessful();
$response->assertCanSeeTableRecords($users); $response->assertCanSeeTableRecords($users);
} }
public function test_can_see_edit_page_of_user(): void
{
// Arrange
$user = User::factory()->create();
// Act
$response = Livewire::test(UserResource\Pages\EditUser::class, ['record' => $user->getKey()]);
// Assert
$response->assertSuccessful();
}
} }