trypost/tests/Feature/Database/UserSeederTest.php
Paulo Castellano e4bc6f1d5c test(auth): cover remaining surfaces of the registration gate
- POST /register with ?invite query and no prior session passes the gate.
- UserSeeder seeds the admin + workspace on an empty DB and skips when a
  user already exists.
- Login page exposes selfHosted prop in both modes (proves the flag the
  frontend uses to hide the "Sign up" link reaches the client).
2026-05-19 12:03:41 -03:00

26 lines
681 B
PHP

<?php
declare(strict_types=1);
use App\Models\User;
use Database\Seeders\UserSeeder;
test('seeder creates the admin user and a workspace when database is empty', function () {
expect(User::count())->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();
});