- 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
189 lines
5.7 KiB
PHP
189 lines
5.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Enums\SocialAccount\Platform;
|
|
use App\Enums\User\Persona;
|
|
use App\Enums\User\Setup;
|
|
use App\Models\SocialAccount;
|
|
use App\Models\User;
|
|
use App\Models\Workspace;
|
|
|
|
beforeEach(function () {
|
|
$this->user = User::factory()->create(['setup' => Setup::Role]);
|
|
});
|
|
|
|
// Step 1 tests
|
|
test('step1 requires authentication', function () {
|
|
$response = $this->get(route('app.onboarding.role'));
|
|
|
|
$response->assertRedirect(route('login'));
|
|
});
|
|
|
|
test('step1 shows persona selection', function () {
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.role'));
|
|
|
|
$response->assertOk();
|
|
$response->assertInertia(fn ($page) => $page
|
|
->component('onboarding/Role', false)
|
|
->has('personas')
|
|
);
|
|
});
|
|
|
|
// Store Step 1 tests
|
|
test('store step1 requires authentication', function () {
|
|
$response = $this->post(route('app.onboarding.role.store'), [
|
|
'persona' => Persona::Founder->value,
|
|
]);
|
|
|
|
$response->assertRedirect(route('login'));
|
|
});
|
|
|
|
test('store step1 saves persona and redirects to step2', function () {
|
|
$response = $this->actingAs($this->user)->post(route('app.onboarding.role.store'), [
|
|
'persona' => Persona::Founder->value,
|
|
]);
|
|
|
|
$response->assertRedirect(route('app.onboarding.account'));
|
|
|
|
$this->user->refresh();
|
|
expect($this->user->persona)->toBe(Persona::Founder);
|
|
expect($this->user->setup)->toBe(Setup::Connections);
|
|
});
|
|
|
|
test('store step1 validates persona is required', function () {
|
|
$response = $this->actingAs($this->user)->post(route('app.onboarding.role.store'), [
|
|
'persona' => '',
|
|
]);
|
|
|
|
$response->assertSessionHasErrors('persona');
|
|
});
|
|
|
|
test('store step1 validates persona is valid enum', function () {
|
|
$response = $this->actingAs($this->user)->post(route('app.onboarding.role.store'), [
|
|
'persona' => 'invalid',
|
|
]);
|
|
|
|
$response->assertSessionHasErrors('persona');
|
|
});
|
|
|
|
// Step 2 tests
|
|
test('step2 requires authentication', function () {
|
|
$response = $this->get(route('app.onboarding.account'));
|
|
|
|
$response->assertRedirect(route('login'));
|
|
});
|
|
|
|
test('step2 shows social accounts connection', function () {
|
|
$this->user->update(['setup' => Setup::Connections]);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.account'));
|
|
|
|
$response->assertOk();
|
|
$response->assertInertia(fn ($page) => $page
|
|
->component('onboarding/Account', false)
|
|
->has('platforms')
|
|
->has('hasWorkspace')
|
|
);
|
|
});
|
|
|
|
test('step2 shows connected accounts for workspace', function () {
|
|
$this->user->update(['setup' => Setup::Connections]);
|
|
$workspace = Workspace::factory()->create(['user_id' => $this->user->id]);
|
|
$this->user->update(['current_workspace_id' => $workspace->id]);
|
|
|
|
SocialAccount::factory()->create([
|
|
'workspace_id' => $workspace->id,
|
|
'platform' => Platform::LinkedIn,
|
|
]);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.account'));
|
|
|
|
$response->assertOk();
|
|
$response->assertInertia(fn ($page) => $page
|
|
->where('hasWorkspace', true)
|
|
);
|
|
});
|
|
|
|
// Store Step 2 tests
|
|
test('store step2 requires authentication', function () {
|
|
$response = $this->post(route('app.onboarding.account.store'));
|
|
|
|
$response->assertRedirect(route('login'));
|
|
});
|
|
|
|
test('store step2 completes setup in self-hosted mode', function () {
|
|
config(['trypost.self_hosted' => true]);
|
|
$this->user->update(['setup' => Setup::Connections]);
|
|
|
|
$response = $this->actingAs($this->user)->post(route('app.onboarding.account.store'));
|
|
|
|
$response->assertRedirect(route('app.calendar'));
|
|
|
|
$this->user->refresh();
|
|
expect($this->user->setup)->toBe(Setup::Completed);
|
|
});
|
|
|
|
// Complete tests
|
|
test('complete requires authentication', function () {
|
|
$response = $this->get(route('app.onboarding.account'));
|
|
|
|
$response->assertRedirect(route('login'));
|
|
});
|
|
|
|
test('completed user is redirected to calendar', function () {
|
|
$this->user->update(['setup' => Setup::Completed]);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.account'));
|
|
|
|
$response->assertRedirect(route('app.calendar'));
|
|
});
|
|
|
|
// Step enforcement tests
|
|
test('step1 redirects to connect when user already completed role step', function () {
|
|
$this->user->update(['setup' => Setup::Connections]);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.role'));
|
|
|
|
$response->assertRedirect(route('app.onboarding.account'));
|
|
});
|
|
|
|
test('step1 redirects to calendar when setup is completed', function () {
|
|
$this->user->update(['setup' => Setup::Completed]);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.role'));
|
|
|
|
$response->assertRedirect(route('app.calendar'));
|
|
});
|
|
|
|
test('step2 redirects to role when user has not completed role step', function () {
|
|
$this->user->update(['setup' => Setup::Role]);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.account'));
|
|
|
|
$response->assertRedirect(route('app.onboarding.role'));
|
|
});
|
|
|
|
test('step2 redirects to calendar when setup is completed', function () {
|
|
$this->user->update(['setup' => Setup::Completed]);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.account'));
|
|
|
|
$response->assertRedirect(route('app.calendar'));
|
|
});
|
|
|
|
test('user on role step can access role page', function () {
|
|
$this->user->update(['setup' => Setup::Role]);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.role'));
|
|
|
|
$response->assertOk();
|
|
});
|
|
|
|
test('user on connections step can access connect page', function () {
|
|
$this->user->update(['setup' => Setup::Connections]);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.account'));
|
|
|
|
$response->assertOk();
|
|
});
|