Skip to content

Commit

Permalink
DEV: skip teams related tests if the feature is not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
vinothkannans committed Nov 8, 2024
1 parent 04eddd0 commit eb9d3e3
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
5 changes: 4 additions & 1 deletion tests/Feature/CreateTeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use App\Models\User;
use Laravel\Jetstream\Http\Livewire\CreateTeamForm;
use Laravel\Jetstream\Jetstream;
use Livewire\Livewire;

test('teams can be created', function () {
Expand All @@ -13,4 +14,6 @@

expect($user->fresh()->ownedTeams)->toHaveCount(2);
expect($user->fresh()->ownedTeams()->latest('id')->first()->name)->toEqual('Test Team');
});
})->skip(function () {
return !Jetstream::hasTeamFeatures();
}, 'Teams feature is not enabled.');
9 changes: 7 additions & 2 deletions tests/Feature/DeleteTeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use App\Models\Team;
use App\Models\User;
use Laravel\Jetstream\Http\Livewire\DeleteTeamForm;
use Laravel\Jetstream\Jetstream;
use Livewire\Livewire;

test('teams can be deleted', function () {
Expand All @@ -22,7 +23,9 @@

expect($team->fresh())->toBeNull();
expect($otherUser->fresh()->teams)->toHaveCount(0);
});
})->skip(function () {
return !Jetstream::hasTeamFeatures();
}, 'Teams feature is not enabled.');

test('personal teams cant be deleted', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
Expand All @@ -32,4 +35,6 @@
->assertHasErrors(['team']);

expect($user->currentTeam->fresh())->not->toBeNull();
});
})->skip(function () {
return !Jetstream::hasTeamFeatures();
}, 'Teams feature is not enabled.');
9 changes: 7 additions & 2 deletions tests/Feature/LeaveTeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use App\Models\User;
use Laravel\Jetstream\Http\Livewire\TeamMemberManager;
use Laravel\Jetstream\Jetstream;
use Livewire\Livewire;

test('users can leave teams', function () {
Expand All @@ -18,7 +19,9 @@
->call('leaveTeam');

expect($user->currentTeam->fresh()->users)->toHaveCount(0);
});
})->skip(function () {
return !Jetstream::hasTeamFeatures();
}, 'Teams feature is not enabled.');

test('team owners cant leave their own team', function () {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
Expand All @@ -28,4 +31,6 @@
->assertHasErrors(['team']);

expect($user->currentTeam->fresh())->not->toBeNull();
});
})->skip(function () {
return !Jetstream::hasTeamFeatures();
}, 'Teams feature is not enabled.');
9 changes: 7 additions & 2 deletions tests/Feature/RemoveTeamMemberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use App\Models\User;
use Laravel\Jetstream\Http\Livewire\TeamMemberManager;
use Laravel\Jetstream\Jetstream;
use Livewire\Livewire;

test('team members can be removed from teams', function () {
Expand All @@ -17,7 +18,9 @@
->call('removeTeamMember');

expect($user->currentTeam->fresh()->users)->toHaveCount(0);
});
})->skip(function () {
return !Jetstream::hasTeamFeatures();
}, 'Teams feature is not enabled.');

test('only team owner can remove team members', function () {
$user = User::factory()->withPersonalTeam()->create();
Expand All @@ -33,4 +36,6 @@
->set('teamMemberIdBeingRemoved', $user->id)
->call('removeTeamMember')
->assertStatus(403);
});
})->skip(function () {
return !Jetstream::hasTeamFeatures();
}, 'Teams feature is not enabled.');
9 changes: 7 additions & 2 deletions tests/Feature/UpdateTeamMemberRoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use App\Models\User;
use Laravel\Jetstream\Http\Livewire\TeamMemberManager;
use Laravel\Jetstream\Jetstream;
use Livewire\Livewire;

test('team member roles can be updated', function () {
Expand All @@ -21,7 +22,9 @@
$user->currentTeam->fresh(),
'editor'
))->toBeTrue();
});
})->skip(function () {
return !Jetstream::hasTeamFeatures();
}, 'Teams feature is not enabled.');

test('only team owner can update team member roles', function () {
$user = User::factory()->withPersonalTeam()->create();
Expand All @@ -43,4 +46,6 @@
$user->currentTeam->fresh(),
'admin'
))->toBeTrue();
});
})->skip(function () {
return !Jetstream::hasTeamFeatures();
}, 'Teams feature is not enabled.');
5 changes: 4 additions & 1 deletion tests/Feature/UpdateTeamNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use App\Models\User;
use Laravel\Jetstream\Http\Livewire\UpdateTeamNameForm;
use Laravel\Jetstream\Jetstream;
use Livewire\Livewire;

test('team names can be updated', function () {
Expand All @@ -13,4 +14,6 @@

expect($user->fresh()->ownedTeams)->toHaveCount(1);
expect($user->currentTeam->fresh()->name)->toEqual('Test Team');
});
})->skip(function () {
return !Jetstream::hasTeamFeatures();
}, 'Teams feature is not enabled.');

0 comments on commit eb9d3e3

Please sign in to comment.