mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-05-03 16:24:55 +00:00
🔥 **Cleanup:** Removed BookCase and OrangePill models, factories, migrations, and related references. Added tests for new service and meetup creation flows. Updated PHPUnit settings and browser-specific configurations.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use App\Jobs\FetchNostrProfileJob;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Livewire\Livewire;
|
||||
|
||||
it('creates a new user and dispatches FetchNostrProfileJob when an unknown pubkey logs in', function () {
|
||||
Queue::fake();
|
||||
$pubkey = 'npub1'.str_repeat('z', 58);
|
||||
|
||||
Livewire::test('auth.login')
|
||||
->dispatch('nostrLoggedIn', pubkey: $pubkey)
|
||||
->assertRedirect();
|
||||
|
||||
$user = User::query()->where('nostr', $pubkey)->first();
|
||||
expect($user)->not->toBeNull()
|
||||
->and((bool) $user->is_lecturer)->toBeTrue()
|
||||
->and($user->email)->toEndWith('@portal.einundzwanzig.space');
|
||||
|
||||
Queue::assertPushed(FetchNostrProfileJob::class);
|
||||
expect(auth()->id())->toBe($user->id);
|
||||
});
|
||||
|
||||
it('logs in an existing user without creating a duplicate when their pubkey is already known', function () {
|
||||
Queue::fake();
|
||||
$pubkey = 'npub1'.str_repeat('a', 58);
|
||||
$existing = User::factory()->create(['nostr' => $pubkey]);
|
||||
|
||||
Livewire::test('auth.login')
|
||||
->dispatch('nostrLoggedIn', pubkey: $pubkey)
|
||||
->assertRedirect();
|
||||
|
||||
expect(User::query()->where('nostr', $pubkey)->count())->toBe(1);
|
||||
expect(auth()->id())->toBe($existing->id);
|
||||
Queue::assertPushed(FetchNostrProfileJob::class);
|
||||
});
|
||||
Reference in New Issue
Block a user