added roles and organizations
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-15 20:59:32 -07:00
parent 2ca3860557
commit 177f122c10
57 changed files with 6378 additions and 247 deletions
+33
View File
@@ -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());