Fix programme attachment dropdown always appearing disabled on events.
Deploy Ladill Events / deploy (push) Successful in 31s
Deploy Ladill Events / deploy (push) Successful in 31s
Load itinerary options in the event show controller and link to programme creation when none exist yet. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\QrCode;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EventProgrammeAttachmentTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->withoutMiddleware(\App\Http\Middleware\EnsurePlatformSession::class);
|
||||
Http::fake([
|
||||
config('billing.api_url').'/balance*' => Http::response(['balance_minor' => 50000]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_event_show_lists_programmes_for_attachment(): void
|
||||
{
|
||||
$owner = User::factory()->create(['public_id' => 'usr_prog_attach']);
|
||||
|
||||
$programme = QrCode::create([
|
||||
'user_id' => $owner->id,
|
||||
'short_code' => 'prog-attach-1',
|
||||
'type' => QrCode::TYPE_ITINERARY,
|
||||
'label' => 'Summit schedule',
|
||||
'payload' => ['content' => ['title' => 'Summit schedule'], 'style' => []],
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$event = QrCode::create([
|
||||
'user_id' => $owner->id,
|
||||
'short_code' => 'evt-attach-1',
|
||||
'type' => QrCode::TYPE_EVENT,
|
||||
'label' => 'Annual summit',
|
||||
'payload' => ['content' => ['name' => 'Annual summit'], 'style' => []],
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->actingAs($owner)
|
||||
->get(route('events.show', $event))
|
||||
->assertOk()
|
||||
->assertSee('name="programme_qr_id"', false)
|
||||
->assertSee('Summit schedule', false)
|
||||
->assertDontSee('Create a programme first to attach it here', false);
|
||||
}
|
||||
|
||||
public function test_event_show_prompts_to_create_programme_when_none_exist(): void
|
||||
{
|
||||
$owner = User::factory()->create(['public_id' => 'usr_prog_empty']);
|
||||
|
||||
$event = QrCode::create([
|
||||
'user_id' => $owner->id,
|
||||
'short_code' => 'evt-empty-1',
|
||||
'type' => QrCode::TYPE_EVENT,
|
||||
'label' => 'Workshop',
|
||||
'payload' => ['content' => ['name' => 'Workshop'], 'style' => []],
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->actingAs($owner)
|
||||
->get(route('events.show', $event))
|
||||
->assertOk()
|
||||
->assertSee('Create a programme', false)
|
||||
->assertDontSee('name="programme_qr_id"', false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user