Auth pages: - Create AuthSplitLayout with animated feature slides (6 slides, 3 languages) - All auth pages use split layout (form left, visual right) - Add show/hide password toggle with tooltip on Register - Legal footer only shown on Register via showLegal prop Subscribe page: - Redesign to match auth card pattern (centered, clean) - Platform icons, feature checklist, dynamic trial days (trialDays - 1) - Add "Switch workspace" link - Full i18n (en, es, pt-BR) Onboarding: - Rename URLs: step1 -> role, step2 -> connect - Add enforceStep() to prevent skipping/going back steps - Redirect /onboarding to /onboarding/role - Redesign Step2 with AuthSplitLayout and compact platform list - 21 tests covering all step enforcement scenarios Workspaces page: - Redesign with AuthSplitLayout (list with avatars, current badge) Language system: - Move locale from DB to cookie (forever, unencrypted, session.domain) - Create SetLocale middleware (sets cookie if missing, validates against config) - Rename lang/pt-br to lang/pt-BR - Add dayjs es locale Other: - Copy utils.ts from sendkit (formatNumber, formatMoney, copyToClipboard) - ConfirmDeleteModal with text confirmation (sendkit pattern) - i18n for ConfirmDeleteModal internal strings (common.php) - EmptyState component for posts index - Exact match for "All" posts in sidebar - Posts breadcrumbs show current status filter - DialogFooter buttons aligned left - API Keys page redesign with Table, DropdownMenu, EmptyState - Extract CreateApiKeyDialog and InviteMemberDialog to components - Remove API Keys from sidebar - DropdownMenuItem destructive variant for Remove action
208 lines
6.3 KiB
PHP
208 lines
6.3 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/Step1', 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.connect'));
|
|
|
|
$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.connect'));
|
|
|
|
$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.connect'));
|
|
|
|
$response->assertOk();
|
|
$response->assertInertia(fn ($page) => $page
|
|
->component('onboarding/Step2', 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.connect'));
|
|
|
|
$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.connect.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.connect.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.complete'));
|
|
|
|
$response->assertRedirect(route('login'));
|
|
});
|
|
|
|
test('complete marks setup as completed', function () {
|
|
$this->user->update(['setup' => Setup::Subscription]);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.complete'));
|
|
|
|
$response->assertRedirect(route('app.calendar'));
|
|
|
|
$this->user->refresh();
|
|
expect($this->user->setup)->toBe(Setup::Completed);
|
|
});
|
|
|
|
// 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.connect'));
|
|
});
|
|
|
|
test('step1 redirects to subscribe when user is on subscription step', function () {
|
|
$this->user->update(['setup' => Setup::Subscription]);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.role'));
|
|
|
|
$response->assertRedirect(route('app.subscribe'));
|
|
});
|
|
|
|
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.connect'));
|
|
|
|
$response->assertRedirect(route('app.onboarding.role'));
|
|
});
|
|
|
|
test('step2 redirects to subscribe when user is on subscription step', function () {
|
|
$this->user->update(['setup' => Setup::Subscription]);
|
|
|
|
$response = $this->actingAs($this->user)->get(route('app.onboarding.connect'));
|
|
|
|
$response->assertRedirect(route('app.subscribe'));
|
|
});
|
|
|
|
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.connect'));
|
|
|
|
$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.connect'));
|
|
|
|
$response->assertOk();
|
|
});
|