Skip to content

Commit

Permalink
Disable unnecessary tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NickMous committed May 3, 2024
1 parent f245df1 commit a100843
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 250 deletions.
60 changes: 30 additions & 30 deletions tests/Feature/ApiTokenPermissionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@
use Laravel\Jetstream\Http\Livewire\ApiTokenManager;
use Livewire\Livewire;

test('api token permissions can be updated', function () {
if (Features::hasTeamFeatures()) {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
} else {
$this->actingAs($user = User::factory()->create());
}

$token = $user->tokens()->create([
'name' => 'Test Token',
'token' => Str::random(40),
'abilities' => ['create', 'read'],
]);

Livewire::test(ApiTokenManager::class)
->set(['managingPermissionsFor' => $token])
->set(['updateApiTokenForm' => [
'permissions' => [
'delete',
'missing-permission',
],
]])
->call('updateApiToken');

expect($user->fresh()->tokens->first())
->can('delete')->toBeTrue()
->can('read')->toBeFalse()
->can('missing-permission')->toBeFalse();
})->skip(function () {
return ! Features::hasApiFeatures();
}, 'API support is not enabled.');
//test('api token permissions can be updated', function () {
// if (Features::hasTeamFeatures()) {
// $this->actingAs($user = User::factory()->withPersonalTeam()->create());
// } else {
// $this->actingAs($user = User::factory()->create());
// }
//
// $token = $user->tokens()->create([
// 'name' => 'Test Token',
// 'token' => Str::random(40),
// 'abilities' => ['create', 'read'],
// ]);
//
// Livewire::test(ApiTokenManager::class)
// ->set(['managingPermissionsFor' => $token])
// ->set(['updateApiTokenForm' => [
// 'permissions' => [
// 'delete',
// 'missing-permission',
// ],
// ]])
// ->call('updateApiToken');
//
// expect($user->fresh()->tokens->first())
// ->can('delete')->toBeTrue()
// ->can('read')->toBeFalse()
// ->can('missing-permission')->toBeFalse();
//})->skip(function () {
// return ! Features::hasApiFeatures();
//}, 'API support is not enabled.');
50 changes: 25 additions & 25 deletions tests/Feature/CreateApiTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
use Laravel\Jetstream\Http\Livewire\ApiTokenManager;
use Livewire\Livewire;

test('api tokens can be created', function () {
if (Features::hasTeamFeatures()) {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
} else {
$this->actingAs($user = User::factory()->create());
}

Livewire::test(ApiTokenManager::class)
->set(['createApiTokenForm' => [
'name' => 'Test Token',
'permissions' => [
'read',
'update',
],
]])
->call('createApiToken');

expect($user->fresh()->tokens)->toHaveCount(1);
expect($user->fresh()->tokens->first())
->name->toEqual('Test Token')
->can('read')->toBeTrue()
->can('delete')->toBeFalse();
})->skip(function () {
return ! Features::hasApiFeatures();
}, 'API support is not enabled.');
//test('api tokens can be created', function () {
// if (Features::hasTeamFeatures()) {
// $this->actingAs($user = User::factory()->withPersonalTeam()->create());
// } else {
// $this->actingAs($user = User::factory()->create());
// }
//
// Livewire::test(ApiTokenManager::class)
// ->set(['createApiTokenForm' => [
// 'name' => 'Test Token',
// 'permissions' => [
// 'read',
// 'update',
// ],
// ]])
// ->call('createApiToken');
//
// expect($user->fresh()->tokens)->toHaveCount(1);
// expect($user->fresh()->tokens->first())
// ->name->toEqual('Test Token')
// ->can('read')->toBeTrue()
// ->can('delete')->toBeFalse();
//})->skip(function () {
// return ! Features::hasApiFeatures();
//}, 'API support is not enabled.');
20 changes: 10 additions & 10 deletions tests/Feature/CreateTeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
use Laravel\Jetstream\Http\Livewire\CreateTeamForm;
use Livewire\Livewire;

test('teams can be created', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());

Livewire::test(CreateTeamForm::class)
->set(['state' => ['name' => 'Test Team']])
->call('createTeam');

expect($user->fresh()->ownedTeams)->toHaveCount(2);
expect($user->fresh()->ownedTeams()->latest('id')->first()->name)->toEqual('Test Team');
});
//test('teams can be created', function () {
// $this->actingAs($user = User::factory()->withPersonalTeam()->create());
//
// Livewire::test(CreateTeamForm::class)
// ->set(['state' => ['name' => 'Test Team']])
// ->call('createTeam');
//
// expect($user->fresh()->ownedTeams)->toHaveCount(2);
// expect($user->fresh()->ownedTeams()->latest('id')->first()->name)->toEqual('Test Team');
//});
42 changes: 21 additions & 21 deletions tests/Feature/DeleteApiTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
use Laravel\Jetstream\Http\Livewire\ApiTokenManager;
use Livewire\Livewire;

test('api tokens can be deleted', function () {
if (Features::hasTeamFeatures()) {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
} else {
$this->actingAs($user = User::factory()->create());
}

$token = $user->tokens()->create([
'name' => 'Test Token',
'token' => Str::random(40),
'abilities' => ['create', 'read'],
]);

Livewire::test(ApiTokenManager::class)
->set(['apiTokenIdBeingDeleted' => $token->id])
->call('deleteApiToken');

expect($user->fresh()->tokens)->toHaveCount(0);
})->skip(function () {
return ! Features::hasApiFeatures();
}, 'API support is not enabled.');
//test('api tokens can be deleted', function () {
// if (Features::hasTeamFeatures()) {
// $this->actingAs($user = User::factory()->withPersonalTeam()->create());
// } else {
// $this->actingAs($user = User::factory()->create());
// }
//
// $token = $user->tokens()->create([
// 'name' => 'Test Token',
// 'token' => Str::random(40),
// 'abilities' => ['create', 'read'],
// ]);
//
// Livewire::test(ApiTokenManager::class)
// ->set(['apiTokenIdBeingDeleted' => $token->id])
// ->call('deleteApiToken');
//
// expect($user->fresh()->tokens)->toHaveCount(0);
//})->skip(function () {
// return ! Features::hasApiFeatures();
//}, 'API support is not enabled.');
54 changes: 27 additions & 27 deletions tests/Feature/DeleteTeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@
use Laravel\Jetstream\Http\Livewire\DeleteTeamForm;
use Livewire\Livewire;

test('teams can be deleted', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());

$user->ownedTeams()->save($team = Team::factory()->make([
'personal_team' => false,
]));

$team->users()->attach(
$otherUser = User::factory()->create(), ['role' => 'test-role']
);

$component = Livewire::test(DeleteTeamForm::class, ['team' => $team->fresh()])
->call('deleteTeam');

expect($team->fresh())->toBeNull();
expect($otherUser->fresh()->teams)->toHaveCount(0);
});

test('personal teams cant be deleted', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());

$component = Livewire::test(DeleteTeamForm::class, ['team' => $user->currentTeam])
->call('deleteTeam')
->assertHasErrors(['team']);

expect($user->currentTeam->fresh())->not->toBeNull();
});
//test('teams can be deleted', function () {
// $this->actingAs($user = User::factory()->withPersonalTeam()->create());
//
// $user->ownedTeams()->save($team = Team::factory()->make([
// 'personal_team' => false,
// ]));
//
// $team->users()->attach(
// $otherUser = User::factory()->create(), ['role' => 'test-role']
// );
//
// $component = Livewire::test(DeleteTeamForm::class, ['team' => $team->fresh()])
// ->call('deleteTeam');
//
// expect($team->fresh())->toBeNull();
// expect($otherUser->fresh()->teams)->toHaveCount(0);
//});
//
//test('personal teams cant be deleted', function () {
// $this->actingAs($user = User::factory()->withPersonalTeam()->create());
//
// $component = Livewire::test(DeleteTeamForm::class, ['team' => $user->currentTeam])
// ->call('deleteTeam')
// ->assertHasErrors(['team']);
//
// expect($user->currentTeam->fresh())->not->toBeNull();
//});
78 changes: 39 additions & 39 deletions tests/Feature/InviteTeamMemberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@
use Laravel\Jetstream\Mail\TeamInvitation;
use Livewire\Livewire;

test('team members can be invited to team', function () {
Mail::fake();

$this->actingAs($user = User::factory()->withPersonalTeam()->create());

$component = Livewire::test(TeamMemberManager::class, ['team' => $user->currentTeam])
->set('addTeamMemberForm', [
'email' => '[email protected]',
'role' => 'admin',
])->call('addTeamMember');

Mail::assertSent(TeamInvitation::class);

expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(1);
})->skip(function () {
return ! Features::sendsTeamInvitations();
}, 'Team invitations not enabled.');

test('team member invitations can be cancelled', function () {
Mail::fake();

$this->actingAs($user = User::factory()->withPersonalTeam()->create());

// Add the team member...
$component = Livewire::test(TeamMemberManager::class, ['team' => $user->currentTeam])
->set('addTeamMemberForm', [
'email' => '[email protected]',
'role' => 'admin',
])->call('addTeamMember');

$invitationId = $user->currentTeam->fresh()->teamInvitations->first()->id;

// Cancel the team invitation...
$component->call('cancelTeamInvitation', $invitationId);

expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(0);
})->skip(function () {
return ! Features::sendsTeamInvitations();
}, 'Team invitations not enabled.');
//test('team members can be invited to team', function () {
// Mail::fake();
//
// $this->actingAs($user = User::factory()->withPersonalTeam()->create());
//
// $component = Livewire::test(TeamMemberManager::class, ['team' => $user->currentTeam])
// ->set('addTeamMemberForm', [
// 'email' => '[email protected]',
// 'role' => 'admin',
// ])->call('addTeamMember');
//
// Mail::assertSent(TeamInvitation::class);
//
// expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(1);
//})->skip(function () {
// return ! Features::sendsTeamInvitations();
//}, 'Team invitations not enabled.');
//
//test('team member invitations can be cancelled', function () {
// Mail::fake();
//
// $this->actingAs($user = User::factory()->withPersonalTeam()->create());
//
// // Add the team member...
// $component = Livewire::test(TeamMemberManager::class, ['team' => $user->currentTeam])
// ->set('addTeamMemberForm', [
// 'email' => '[email protected]',
// 'role' => 'admin',
// ])->call('addTeamMember');
//
// $invitationId = $user->currentTeam->fresh()->teamInvitations->first()->id;
//
// // Cancel the team invitation...
// $component->call('cancelTeamInvitation', $invitationId);
//
// expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(0);
//})->skip(function () {
// return ! Features::sendsTeamInvitations();
//}, 'Team invitations not enabled.');
48 changes: 24 additions & 24 deletions tests/Feature/LeaveTeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
use Laravel\Jetstream\Http\Livewire\TeamMemberManager;
use Livewire\Livewire;

test('users can leave teams', function () {
$user = User::factory()->withPersonalTeam()->create();

$user->currentTeam->users()->attach(
$otherUser = User::factory()->create(), ['role' => 'admin']
);

$this->actingAs($otherUser);

$component = Livewire::test(TeamMemberManager::class, ['team' => $user->currentTeam])
->call('leaveTeam');

expect($user->currentTeam->fresh()->users)->toHaveCount(0);
});

test('team owners cant leave their own team', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());

$component = Livewire::test(TeamMemberManager::class, ['team' => $user->currentTeam])
->call('leaveTeam')
->assertHasErrors(['team']);

expect($user->currentTeam->fresh())->not->toBeNull();
});
//test('users can leave teams', function () {
// $user = User::factory()->withPersonalTeam()->create();
//
// $user->currentTeam->users()->attach(
// $otherUser = User::factory()->create(), ['role' => 'admin']
// );
//
// $this->actingAs($otherUser);
//
// $component = Livewire::test(TeamMemberManager::class, ['team' => $user->currentTeam])
// ->call('leaveTeam');
//
// expect($user->currentTeam->fresh()->users)->toHaveCount(0);
//});
//
//test('team owners cant leave their own team', function () {
// $this->actingAs($user = User::factory()->withPersonalTeam()->create());
//
// $component = Livewire::test(TeamMemberManager::class, ['team' => $user->currentTeam])
// ->call('leaveTeam')
// ->assertHasErrors(['team']);
//
// expect($user->currentTeam->fresh())->not->toBeNull();
//});
Loading

0 comments on commit a100843

Please sign in to comment.