mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
Added member and invitation endpoints
This commit is contained in:
@@ -14,23 +14,69 @@ class UpdateTeamMemberRoleTest extends TestCase
|
||||
|
||||
public function test_team_member_roles_can_be_updated(): void
|
||||
{
|
||||
$this->actingAs($user = User::factory()->withPersonalOrganization()->create());
|
||||
// Arrange
|
||||
$user = User::factory()->withPersonalOrganization()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$user->currentTeam->users()->attach(
|
||||
$otherUser = User::factory()->create(), ['role' => 'admin']
|
||||
);
|
||||
|
||||
// Act
|
||||
$response = $this->put('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id, [
|
||||
'role' => 'employee',
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$this->assertTrue($otherUser->fresh()->hasTeamRole(
|
||||
$user->currentTeam->fresh(), 'employee'
|
||||
));
|
||||
}
|
||||
|
||||
public function test_team_member_roles_can_not_be_updated_to_placeholder(): void
|
||||
{
|
||||
// Arrange
|
||||
$user = User::factory()->withPersonalOrganization()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
$user->currentTeam->users()->attach(
|
||||
$otherUser = User::factory()->create(), ['role' => 'admin']
|
||||
);
|
||||
|
||||
// Act
|
||||
$response = $this->put('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id, [
|
||||
'role' => 'placeholder',
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$this->assertTrue($otherUser->fresh()->hasTeamRole(
|
||||
$user->currentTeam->fresh(), 'admin'
|
||||
));
|
||||
}
|
||||
|
||||
public function test_team_member_roles_can_be_updated_to_owner_which_changes_ownership(): void
|
||||
{
|
||||
// Arrange
|
||||
$user = User::factory()->withPersonalOrganization()->create();
|
||||
$this->actingAs($user);
|
||||
$otherUser = User::factory()->create();
|
||||
$user->currentTeam->users()->attach($otherUser, ['role' => 'admin']);
|
||||
|
||||
// Act
|
||||
$response = $this->withoutExceptionHandling()->put('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->getKey(), [
|
||||
'role' => 'owner',
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$this->assertTrue($otherUser->fresh()->hasTeamRole(
|
||||
$user->currentTeam->fresh(), 'owner'
|
||||
));
|
||||
$this->assertSame($user->currentTeam->fresh()->user_id, $otherUser->getKey());
|
||||
}
|
||||
|
||||
public function test_only_team_owner_can_update_team_member_roles(): void
|
||||
{
|
||||
// Arrange
|
||||
$user = User::factory()->withPersonalOrganization()->create();
|
||||
|
||||
$user->currentTeam->users()->attach(
|
||||
@@ -39,10 +85,13 @@ class UpdateTeamMemberRoleTest extends TestCase
|
||||
|
||||
$this->actingAs($otherUser);
|
||||
|
||||
// Act
|
||||
$response = $this->put('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id, [
|
||||
'role' => 'employee',
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
$this->assertTrue($otherUser->fresh()->hasTeamRole(
|
||||
$user->currentTeam->fresh(), 'admin'
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user