Skip to content

Commit 4dbfa8d

Browse files
authored
Skip tests for team invitations if disabled (#1063)
1 parent 3eda403 commit 4dbfa8d

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

stubs/pest-tests/inertia/InviteTeamMemberTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use App\Models\User;
44
use Illuminate\Support\Facades\Mail;
5+
use Laravel\Jetstream\Features;
56
use Laravel\Jetstream\Mail\TeamInvitation;
67

78
test('team members can be invited to team', function () {
@@ -17,7 +18,9 @@
1718
Mail::assertSent(TeamInvitation::class);
1819

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

2225
test('team member invitations can be cancelled', function () {
2326
Mail::fake();
@@ -32,4 +35,6 @@
3235
$response = $this->delete('/team-invitations/'.$invitation->id);
3336

3437
expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(0);
35-
});
38+
})->skip(function () {
39+
return ! Features::sendsTeamInvitations();
40+
}, 'Team invitations not enabled.');

stubs/pest-tests/livewire/InviteTeamMemberTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use App\Models\User;
44
use Illuminate\Support\Facades\Mail;
5+
use Laravel\Jetstream\Features;
56
use Laravel\Jetstream\Http\Livewire\TeamMemberManager;
67
use Laravel\Jetstream\Mail\TeamInvitation;
78
use Livewire\Livewire;
@@ -20,7 +21,9 @@
2021
Mail::assertSent(TeamInvitation::class);
2122

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

2528
test('team member invitations can be cancelled', function () {
2629
Mail::fake();
@@ -40,4 +43,6 @@
4043
$component->call('cancelTeamInvitation', $invitationId);
4144

4245
expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(0);
43-
});
46+
})->skip(function () {
47+
return ! Features::sendsTeamInvitations();
48+
}, 'Team invitations not enabled.');

stubs/tests/inertia/InviteTeamMemberTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Models\User;
66
use Illuminate\Foundation\Testing\RefreshDatabase;
77
use Illuminate\Support\Facades\Mail;
8+
use Laravel\Jetstream\Features;
89
use Laravel\Jetstream\Mail\TeamInvitation;
910
use Tests\TestCase;
1011

@@ -14,6 +15,10 @@ class InviteTeamMemberTest extends TestCase
1415

1516
public function test_team_members_can_be_invited_to_team()
1617
{
18+
if (! Features::sendsTeamInvitations()) {
19+
return $this->markTestSkipped('Team invitations not enabled.');
20+
}
21+
1722
Mail::fake();
1823

1924
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
@@ -30,6 +35,10 @@ public function test_team_members_can_be_invited_to_team()
3035

3136
public function test_team_member_invitations_can_be_cancelled()
3237
{
38+
if (! Features::sendsTeamInvitations()) {
39+
return $this->markTestSkipped('Team invitations not enabled.');
40+
}
41+
3342
Mail::fake();
3443

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

stubs/tests/livewire/InviteTeamMemberTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Models\User;
66
use Illuminate\Foundation\Testing\RefreshDatabase;
77
use Illuminate\Support\Facades\Mail;
8+
use Laravel\Jetstream\Features;
89
use Laravel\Jetstream\Http\Livewire\TeamMemberManager;
910
use Laravel\Jetstream\Mail\TeamInvitation;
1011
use Livewire\Livewire;
@@ -16,6 +17,10 @@ class InviteTeamMemberTest extends TestCase
1617

1718
public function test_team_members_can_be_invited_to_team()
1819
{
20+
if (! Features::sendsTeamInvitations()) {
21+
return $this->markTestSkipped('Team invitations not enabled.');
22+
}
23+
1924
Mail::fake();
2025

2126
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
@@ -33,6 +38,10 @@ public function test_team_members_can_be_invited_to_team()
3338

3439
public function test_team_member_invitations_can_be_cancelled()
3540
{
41+
if (! Features::sendsTeamInvitations()) {
42+
return $this->markTestSkipped('Team invitations not enabled.');
43+
}
44+
3645
Mail::fake();
3746

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

0 commit comments

Comments
 (0)