mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-11 17:52:15 +01:00
Added importer details endpoint
This commit is contained in:
committed by
Gregor Vostrak
parent
fe61a54c35
commit
1f79d5e50a
@@ -25,7 +25,7 @@ class DeleteTeamTest extends TestCase
|
||||
$otherUser = User::factory()->create(), ['role' => 'test-role']
|
||||
);
|
||||
|
||||
$response = $this->delete('/teams/'.$team->id);
|
||||
$response = $this->delete('/teams/'.$team->getKey());
|
||||
|
||||
$this->assertNull($team->fresh());
|
||||
$this->assertCount(0, $otherUser->fresh()->teams);
|
||||
@@ -35,7 +35,7 @@ class DeleteTeamTest extends TestCase
|
||||
{
|
||||
$this->actingAs($user = User::factory()->withPersonalOrganization()->create());
|
||||
|
||||
$response = $this->delete('/teams/'.$user->currentTeam->id);
|
||||
$response = $this->delete('/teams/'.$user->currentTeam->getKey());
|
||||
|
||||
$this->assertNotNull($user->currentTeam->fresh());
|
||||
}
|
||||
|
||||
@@ -13,6 +13,49 @@ use Mockery\MockInterface;
|
||||
|
||||
class ImportEndpointTest extends ApiEndpointTestAbstract
|
||||
{
|
||||
public function test_index_fails_if_user_does_not_have_permission()
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
]);
|
||||
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->getJson(route('api.v1.import.index', ['organization' => $data->organization->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_index_returns_importers_if_user_has_permission()
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
'import',
|
||||
]);
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->getJson(route('api.v1.import.index', ['organization' => $data->organization->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertOk();
|
||||
$response->assertJsonStructure([
|
||||
'data' => [
|
||||
[
|
||||
'key',
|
||||
'name',
|
||||
'description',
|
||||
],
|
||||
],
|
||||
]);
|
||||
$toggleTimeEntries = collect($response->json('data'))->where('key', 'toggl_time_entries')->first();
|
||||
$this->assertSame('toggl_time_entries', $toggleTimeEntries['key']);
|
||||
$this->assertSame('Toggl Time Entries', $toggleTimeEntries['name']);
|
||||
$this->assertSame(__('importer.toggl_time_entries.description'), $toggleTimeEntries['description']);
|
||||
}
|
||||
|
||||
public function test_import_fails_if_user_does_not_have_permission()
|
||||
{
|
||||
// Arrange
|
||||
@@ -22,7 +65,7 @@ class ImportEndpointTest extends ApiEndpointTestAbstract
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->postJson(route('api.v1.import.import', ['organization' => $data->organization->id]), [
|
||||
$response = $this->postJson(route('api.v1.import.import', ['organization' => $data->organization->getKey()]), [
|
||||
'type' => 'toggl_time_entries',
|
||||
'data' => base64_encode('some data'),
|
||||
'options' => [],
|
||||
@@ -48,7 +91,7 @@ class ImportEndpointTest extends ApiEndpointTestAbstract
|
||||
Passport::actingAs($user->user);
|
||||
|
||||
// Act
|
||||
$response = $this->postJson(route('api.v1.import.import', ['organization' => $user->organization->id]), [
|
||||
$response = $this->postJson(route('api.v1.import.import', ['organization' => $user->organization->getKey()]), [
|
||||
'type' => 'toggl_time_entries',
|
||||
'data' => base64_encode('some data'),
|
||||
]);
|
||||
@@ -84,7 +127,7 @@ class ImportEndpointTest extends ApiEndpointTestAbstract
|
||||
Passport::actingAs($user->user);
|
||||
|
||||
// Act
|
||||
$response = $this->postJson(route('api.v1.import.import', ['organization' => $user->organization->id]), [
|
||||
$response = $this->postJson(route('api.v1.import.import', ['organization' => $user->organization->getKey()]), [
|
||||
'type' => 'toggl_time_entries',
|
||||
'data' => base64_encode('some data'),
|
||||
]);
|
||||
|
||||
@@ -233,7 +233,7 @@ class TaskEndpointTest extends ApiEndpointTestAbstract
|
||||
$this->assertDatabaseHas(Task::class, [
|
||||
'name' => 'Task 1',
|
||||
'project_id' => $project->getKey(),
|
||||
'organization_id' => $data->organization->id,
|
||||
'organization_id' => $data->organization->getKey(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class OrganizationResourceTest extends FilamentTestCase
|
||||
// Arrange
|
||||
$user = User::factory()->create();
|
||||
$organizations = Organization::factory()->state([
|
||||
'user_id' => $user->id,
|
||||
'user_id' => $user->getKey(),
|
||||
])->createMany(5);
|
||||
|
||||
// Act
|
||||
|
||||
@@ -113,7 +113,7 @@ class TimeEntryModelTest extends ModelTestAbstract
|
||||
$this->assertSame('UTC', $timeEntry->start->getTimezone()->toRegionName());
|
||||
$this->assertSame('2021-01-01 13:00:00', $timeEntry->start->toDateTimeString());
|
||||
$this->assertDatabaseHas(TimeEntry::class, [
|
||||
'id' => $timeEntry->id,
|
||||
'id' => $timeEntry->getKey(),
|
||||
'start' => '2021-01-01 13:00:00',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class UserServiceTest extends TestCase
|
||||
$userService->changeOwnership($organization, $newOwner);
|
||||
|
||||
// Assert
|
||||
$this->assertSame($newOwner->id, $organization->refresh()->user_id);
|
||||
$this->assertSame($newOwner->getKey(), $organization->refresh()->user_id);
|
||||
$this->assertSame(Role::Owner->value, Membership::whereBelongsTo($newOwner)->whereBelongsTo($organization)->firstOrFail()->role);
|
||||
$this->assertSame(Role::Admin->value, Membership::whereBelongsTo($oldOwner)->whereBelongsTo($organization)->firstOrFail()->role);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user