Fix webinar registration redirecting to ladl.link/undefined.
Deploy Ladill Events / deploy (push) Successful in 29s
Deploy Ladill Events / deploy (push) Successful in 29s
Exempt public register POST from cross-site CSRF, collect email on the landing form, and handle API errors instead of navigating to a missing success_url. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\QrCode;
|
||||
use App\Models\User;
|
||||
use App\Support\LadillLink;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EventRegistrationTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Http::fake([
|
||||
config('billing.api_url').'/balance*' => Http::response(['balance_minor' => 50000]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_free_registration_returns_success_url_without_session_cookie(): void
|
||||
{
|
||||
config(['link.public_domain' => 'ladl.link']);
|
||||
|
||||
$owner = User::create([
|
||||
'public_id' => 'usr_reg_free',
|
||||
'name' => 'Event Owner',
|
||||
'email' => 'owner-reg-free@example.com',
|
||||
]);
|
||||
|
||||
QrCode::create([
|
||||
'user_id' => $owner->id,
|
||||
'short_code' => 'webinar-demo',
|
||||
'type' => QrCode::TYPE_EVENT,
|
||||
'label' => 'Product webinar',
|
||||
'payload' => [
|
||||
'content' => [
|
||||
'name' => 'Product webinar',
|
||||
'mode' => 'free',
|
||||
'format' => 'virtual',
|
||||
'registration_open' => true,
|
||||
'tiers' => [['name' => 'Registration', 'price' => 0, 'capacity' => 0]],
|
||||
'virtual_sessions' => [
|
||||
['join_url' => 'https://meet.ladill.com/r/demo-room'],
|
||||
],
|
||||
],
|
||||
'style' => [],
|
||||
],
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$response = $this->postJson('/q/webinar-demo/register', [
|
||||
'tier' => 'Registration',
|
||||
'attendee_name' => 'Jane Doe',
|
||||
'attendee_email' => 'jane@example.com',
|
||||
'attendee_phone' => '+233200000000',
|
||||
], [
|
||||
'X-Ladill-Internal' => '1',
|
||||
]);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('paid', false)
|
||||
->assertJsonStructure(['success_url', 'badge_code']);
|
||||
|
||||
$this->assertStringStartsWith(
|
||||
LadillLink::path('webinar-demo', 'registered/'),
|
||||
(string) $response->json('success_url')
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user