@@ -3,6 +3,7 @@
|
||||
use App\Models\Organization;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\OrganizationRole;
|
||||
use Livewire\Livewire;
|
||||
|
||||
test('guests are redirected from the plan pricing page', function () {
|
||||
@@ -16,6 +17,38 @@ test('non-admins cannot access the plan pricing page', function () {
|
||||
$this->get(route('admin.plan-pricing'))->assertForbidden();
|
||||
});
|
||||
|
||||
test('workspace admins are not site admins and cannot access the plan pricing page', function () {
|
||||
$workspaceAdmin = User::factory()->create();
|
||||
$organization = Organization::factory()->family()
|
||||
->withMember($workspaceAdmin, OrganizationRole::Admin)
|
||||
->create();
|
||||
|
||||
$this->actingAs($workspaceAdmin);
|
||||
|
||||
expect($organization->userHasRole($workspaceAdmin, OrganizationRole::Admin))->toBeTrue();
|
||||
|
||||
$this->get(route('admin.plan-pricing'))->assertForbidden();
|
||||
});
|
||||
|
||||
test('a non-admin cannot save plan amounts through a direct action call', function () {
|
||||
config()->set('plans.plans', [
|
||||
'pro' => ['name' => 'Pro', 'price' => 'price_pro', 'interval' => 'month'],
|
||||
]);
|
||||
|
||||
$admin = User::factory()->asAdmin()->create();
|
||||
$this->actingAs($admin);
|
||||
|
||||
$member = User::factory()->create();
|
||||
|
||||
$component = Livewire::test('pages::admin.plan-pricing');
|
||||
|
||||
$this->actingAs($member);
|
||||
|
||||
$component->set('amounts.pro', '99.00')->call('saveAmounts')->assertForbidden();
|
||||
|
||||
expect(Organization::planAmount('pro'))->toBe(1000);
|
||||
});
|
||||
|
||||
test('non-admins do not see the plan pricing navigation item', function () {
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user