set('trypost.self_hosted', false); }); test('redirects to onboarding when account has no active subscription', function () { $account = Account::factory()->create(); $user = User::factory()->create(['account_id' => $account->id]); $this->actingAs($user) ->get(route('app.calendar')) ->assertRedirect(route('app.onboarding')); }); test('redirects to workspace create when subscribed but no workspace', function () { $account = Account::factory()->create(); $user = User::factory()->create(['account_id' => $account->id]); $account->subscriptions()->create([ 'type' => Account::SUBSCRIPTION_NAME, 'stripe_id' => 'sub_test_'.fake()->uuid(), 'stripe_status' => 'active', 'stripe_price' => 'price_123', ]); $this->actingAs($user) ->get(route('app.calendar')) ->assertRedirect(route('app.workspaces.create')); }); test('passes through when subscribed and has workspace', function () { $account = Account::factory()->create(); $user = User::factory()->create(['account_id' => $account->id]); $workspace = Workspace::factory()->create(['account_id' => $account->id, 'user_id' => $user->id]); $workspace->members()->attach($user->id, ['role' => Role::Member->value]); $user->update(['current_workspace_id' => $workspace->id]); $account->subscriptions()->create([ 'type' => Account::SUBSCRIPTION_NAME, 'stripe_id' => 'sub_test_'.fake()->uuid(), 'stripe_status' => 'active', 'stripe_price' => 'price_123', ]); $this->actingAs($user) ->get(route('app.calendar')) ->assertOk(); }); test('skips subscription check when self-hosted is enabled', function () { config()->set('trypost.self_hosted', true); $account = Account::factory()->create(); $user = User::factory()->create(['account_id' => $account->id]); $workspace = Workspace::factory()->create(['account_id' => $account->id, 'user_id' => $user->id]); $workspace->members()->attach($user->id, ['role' => Role::Member->value]); $user->update(['current_workspace_id' => $workspace->id]); $this->actingAs($user) ->get(route('app.calendar')) ->assertOk(); }); test('redirects to workspace create when self-hosted and no workspace', function () { config()->set('trypost.self_hosted', true); $account = Account::factory()->create(); $user = User::factory()->create(['account_id' => $account->id]); $this->actingAs($user) ->get(route('app.calendar')) ->assertRedirect(route('app.workspaces.create')); });