Reseed demo tenants after each SSO login.
Deploy Ladill Meet / deploy (push) Successful in 2m13s

Demo Free/Pro/Enterprise accounts wipe and reload sample data on
authorization-code SSO callbacks so every sales walkthrough starts clean.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-17 11:21:10 +00:00
co-authored by Cursor
parent a3f19464bd
commit b0590842a4
5 changed files with 188 additions and 0 deletions
+79
View File
@@ -0,0 +1,79 @@
<?php
namespace Tests\Feature;
use App\Http\Middleware\EnsurePlatformSession;
use App\Models\User;
use App\Services\Meet\DemoLoginReseeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Cache;
use Tests\TestCase;
class DemoLoginReseederTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
$this->withoutMiddleware(EnsurePlatformSession::class);
config([
'demo_accounts.enabled' => true,
'demo_accounts.reset_on_login' => true,
]);
Cache::flush();
}
public function test_it_reseeds_demo_free_user_after_login(): void
{
$user = User::create([
'public_id' => 'demo-free-pid',
'name' => 'Ladill Demo (Free)',
'email' => 'demo-free@ladill.com',
]);
Artisan::shouldReceive('call')
->once()
->with('demo:seed', [
'identity' => $user->email,
'--plan' => 'free',
'--reset' => true,
])
->andReturn(0);
app(DemoLoginReseeder::class)->maybeResetAfterLogin($user);
$this->app->terminate();
}
public function test_it_skips_non_demo_users(): void
{
$user = User::create([
'public_id' => 'regular-pid',
'name' => 'Regular',
'email' => 'regular@example.com',
]);
Artisan::shouldReceive('call')->never();
app(DemoLoginReseeder::class)->maybeResetAfterLogin($user);
$this->app->terminate();
}
public function test_it_skips_when_disabled(): void
{
config(['demo_accounts.enabled' => false]);
$user = User::create([
'public_id' => 'demo-free-pid',
'name' => 'Ladill Demo (Free)',
'email' => 'demo-free@ladill.com',
]);
Artisan::shouldReceive('call')->never();
app(DemoLoginReseeder::class)->maybeResetAfterLogin($user);
$this->app->terminate();
}
}