diff --git a/tests/Feature/Auth/AuthenticationTest.php b/tests/Feature/Auth/AuthenticationTest.php index 060b1218..8a49a676 100644 --- a/tests/Feature/Auth/AuthenticationTest.php +++ b/tests/Feature/Auth/AuthenticationTest.php @@ -12,6 +12,26 @@ $response->assertOk(); }); +test('login page exposes selfHosted as false when SELF_HOSTED is off', function () { + config()->set('trypost.self_hosted', false); + + $response = $this->get(route('login')); + + $response->assertOk(); + $page = $response->original->getData()['page']; + expect($page['props']['selfHosted'])->toBeFalse(); +}); + +test('login page exposes selfHosted as true when SELF_HOSTED is on', function () { + config()->set('trypost.self_hosted', true); + + $response = $this->get(route('login')); + + $response->assertOk(); + $page = $response->original->getData()['page']; + expect($page['props']['selfHosted'])->toBeTrue(); +}); + test('users can authenticate using the login screen', function () { $user = User::factory()->create(); diff --git a/tests/Feature/Auth/RegistrationTest.php b/tests/Feature/Auth/RegistrationTest.php index 466a40d2..495791ca 100644 --- a/tests/Feature/Auth/RegistrationTest.php +++ b/tests/Feature/Auth/RegistrationTest.php @@ -168,6 +168,19 @@ expect(User::where('email', 'invitee@example.com')->exists())->toBeTrue(); }); +test('register POST passes when self_hosted with invite query param even without prior session', function () { + config()->set('trypost.self_hosted', true); + + $response = $this->post(route('register.store', ['invite' => 'invite-xyz']), [ + 'name' => 'Invitee', + 'email' => 'invitee@example.com', + 'password' => 'Password123!', + ]); + + $response->assertSessionHasNoErrors(); + expect(User::where('email', 'invitee@example.com')->exists())->toBeTrue(); +}); + test('register works normally when not self_hosted even with pending invite in session', function () { config()->set('trypost.self_hosted', false); diff --git a/tests/Feature/Database/UserSeederTest.php b/tests/Feature/Database/UserSeederTest.php new file mode 100644 index 00000000..b8a98dfa --- /dev/null +++ b/tests/Feature/Database/UserSeederTest.php @@ -0,0 +1,26 @@ +toBe(0); + + $this->seed(UserSeeder::class); + + $admin = User::where('email', 'admin@trypost.it')->first(); + + expect($admin)->not->toBeNull(); + expect($admin->account_id)->not->toBeNull(); + expect($admin->workspaces()->count())->toBe(1); +}); + +test('seeder is idempotent when a user already exists', function () { + User::factory()->create(); + + $this->seed(UserSeeder::class); + + expect(User::where('email', 'admin@trypost.it')->exists())->toBeFalse(); +});