Enhanced admin panel

This commit is contained in:
Constantin Graf
2024-04-26 14:39:36 +02:00
committed by Constantin Graf
parent 42ad5e004a
commit 0bf8a25d64
15 changed files with 258 additions and 77 deletions

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Tests\Feature;
use App\Enums\Role;
use App\Models\Membership;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -29,6 +30,6 @@ class CreateTeamTest extends TestCase
$this->assertCount(2, $user->fresh()->ownedTeams);
$this->assertEquals('Test Organization', $newOrganization->name);
$member = Membership::query()->whereBelongsTo($user, 'user')->whereBelongsTo($newOrganization, 'organization')->firstOrFail();
$this->assertSame('owner', $member->role);
$this->assertSame(Role::Owner->value, $member->role);
}
}

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Tests\Feature;
use App\Enums\Role;
use App\Models\Membership;
use App\Models\User;
use App\Providers\RouteServiceProvider;
@@ -58,7 +59,7 @@ class RegistrationTest extends TestCase
$organization = $user->organizations()->firstOrFail();
$this->assertSame(true, $organization->personal_team);
$member = Membership::query()->whereBelongsTo($user, 'user')->whereBelongsTo($organization, 'organization')->firstOrFail();
$this->assertSame('owner', $member->role);
$this->assertSame(Role::Owner->value, $member->role);
}
public function test_new_users_can_register_and_frontend_can_send_timezone_for_user(): void

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Tests\Feature;
use App\Enums\Role;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
@@ -64,12 +65,12 @@ class UpdateTeamMemberRoleTest extends TestCase
// Act
$response = $this->withoutExceptionHandling()->put('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->getKey(), [
'role' => 'owner',
'role' => Role::Owner->value,
]);
// Assert
$this->assertTrue($otherUser->fresh()->hasTeamRole(
$user->currentTeam->fresh(), 'owner'
$user->currentTeam->fresh(), Role::Owner->value
));
$this->assertSame($user->currentTeam->fresh()->user_id, $otherUser->getKey());
}

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Tests\Unit\Service;
use App\Enums\Role;
use App\Enums\Weekday;
use App\Models\Organization;
use App\Models\Project;
@@ -267,7 +268,7 @@ class DashboardServiceTest extends TestCase
]);
$organization = Organization::factory()->withOwner($user)->create();
$organization->users()->attach($user, [
'role' => 'owner',
'role' => Role::Owner->value,
]);
$project1 = Project::factory()->forOrganization($organization)->create();
$project2 = Project::factory()->forOrganization($organization)->create();