trypost/tests/Feature/Auth/RegistrationTest.php
Paulo Castellano f3f72afecd refactor: auth split layout, subscribe redesign, onboarding, i18n, cookie locale
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
2026-03-30 11:53:42 -03:00

117 lines
3.6 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\User;
test('registration screen can be rendered', function () {
$response = $this->get(route('register'));
$response->assertOk();
});
test('new users can register', function () {
$response = $this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'Password123!',
]);
$response->assertSessionHasNoErrors();
$this->assertAuthenticated();
$response->assertRedirect(route('app.onboarding.role', absolute: false));
});
test('new users get a default workspace on registration', function () {
$this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'Password123!',
]);
$user = User::where('email', 'test@example.com')->first();
expect($user)->not->toBeNull();
expect($user->workspaces)->toHaveCount(1);
expect($user->workspaces->first()->name)->toBe("Test User's Workspace");
expect($user->workspaces->first()->timezone)->toBe('UTC');
});
test('new users workspace uses provided timezone', function () {
$this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'Password123!',
'timezone' => 'America/Sao_Paulo',
]);
$user = User::where('email', 'test@example.com')->first();
expect($user)->not->toBeNull();
expect($user->workspaces->first()->timezone)->toBe('America/Sao_Paulo');
});
test('new users do not have verified email by default', function () {
$this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'Password123!',
]);
$user = User::where('email', 'test@example.com')->first();
expect($user->email_verified_at)->toBeNull();
});
test('new users can register with deprecated timezone Asia/Calcutta', function () {
$this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'Password123!',
'timezone' => 'Asia/Calcutta',
]);
$user = User::where('email', 'test@example.com')->first();
expect($user)->not->toBeNull();
expect($user->workspaces->first()->timezone)->toBe('Asia/Calcutta');
});
test('new users can register with deprecated timezone US/Eastern', function () {
$this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'Password123!',
'timezone' => 'US/Eastern',
]);
$user = User::where('email', 'test@example.com')->first();
expect($user)->not->toBeNull();
expect($user->workspaces->first()->timezone)->toBe('US/Eastern');
});
test('new users cannot register with invalid timezone', function () {
$response = $this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'Password123!',
'timezone' => 'Invalid/Timezone',
]);
$response->assertSessionHasErrors('timezone');
expect(User::where('email', 'test@example.com')->exists())->toBeFalse();
});
test('new users registering via invite have verified email automatically', function () {
$this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'Password123!',
'redirect' => '/invites/some-invite-id',
]);
$user = User::where('email', 'test@example.com')->first();
expect($user->email_verified_at)->not->toBeNull();
});