trypost/tests/Feature/Middleware/EnsureUserSetupIsCompleteTest.php
Paulo Castellano ded1c998ec feat: redesign billing, onboarding, sidebar, and settings architecture
- Sidebar reorganized: Workspace group (connections, hashtags, labels,
  API keys, settings) and Account group (settings, usage, billing)
- Account group only visible to owner and hidden in self-hosted mode
- Onboarding simplified: role -> account (connect socials) -> completed
  -> redirect to /subscribe. Removed Subscription setup step.
- Subscribe page redesigned with 4 plan cards, monthly/yearly toggle,
  trial info, and per-plan features list
- Billing page redesigned following Sendkit layout (sections with
  sidebar labels)
- Processing page uses usePoll with immediate watch for subscription
  activation
- Cancel URL redirects directly to /subscribe
- Account settings page with name and billing_email (syncs with Stripe)
- Usage page with ring meters for all plan limits
- Settings layout tabs only for user pages (profile, password,
  notifications). Workspace/API keys/billing are standalone pages.
- GoogleAuthButton extracted as reusable component
- WorkspaceRole TypeScript enum for type-safe role checks in frontend
- Trial period changed to 7 days
- Fixed onboarding loop when user confirms email
- All 1101 tests passing
2026-04-15 00:33:38 -03:00

71 lines
2.4 KiB
PHP

<?php
declare(strict_types=1);
use App\Enums\User\Setup;
use App\Enums\UserWorkspace\Role;
use App\Models\User;
use App\Models\Workspace;
test('user with completed setup can access protected routes', function () {
config(['trypost.self_hosted' => true]);
$user = User::factory()->create(['setup' => Setup::Completed]);
$workspace = Workspace::factory()->create(['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('user on role step is redirected to onboarding step 1', function () {
config(['trypost.self_hosted' => true]);
$user = User::factory()->create(['setup' => Setup::Role]);
$workspace = Workspace::factory()->create(['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'))
->assertRedirect(route('app.onboarding.role'));
});
test('user on connections step is redirected to onboarding step 2', function () {
config(['trypost.self_hosted' => true]);
$user = User::factory()->create(['setup' => Setup::Connections]);
$workspace = Workspace::factory()->create(['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'))
->assertRedirect(route('app.onboarding.account'));
});
test('user on role step can access onboarding step 1', function () {
$user = User::factory()->create(['setup' => Setup::Role]);
$this->actingAs($user)
->get(route('app.onboarding.role'))
->assertOk();
});
test('user on connections step can access onboarding step 2', function () {
$user = User::factory()->create(['setup' => Setup::Connections]);
$this->actingAs($user)
->get(route('app.onboarding.account'))
->assertOk();
});
test('user on connections step can access social connect routes', function () {
$user = User::factory()->create(['setup' => Setup::Connections]);
$this->actingAs($user)
->get(route('app.social.linkedin.connect'))
->assertRedirect();
});