Strip healthcare packaging and Care integration from Queue.
Deploy Ladill Queue / deploy (push) Successful in 3m12s
Deploy Ladill Queue / deploy (push) Successful in 3m12s
Queue is general-purpose QMS only; Care runs its own native engine. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,242 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Branch;
|
||||
use App\Models\Counter;
|
||||
use App\Models\Organization;
|
||||
use App\Models\ServiceQueue;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CareIntegrationTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function careHeaders(string $owner = 'care-owner-uuid'): array
|
||||
{
|
||||
config(['qms.service_api_keys.care' => 'test-care-key']);
|
||||
|
||||
return [
|
||||
'Authorization' => 'Bearer test-care-key',
|
||||
'Accept' => 'application/json',
|
||||
];
|
||||
}
|
||||
|
||||
protected function provisionCareOrg(string $owner = 'care-owner-uuid'): Organization
|
||||
{
|
||||
$this->postJson('/api/v1/integrations/provision', [
|
||||
'owner' => $owner,
|
||||
'organization_name' => 'Care Clinic',
|
||||
'branch_name' => 'Main',
|
||||
], $this->careHeaders($owner))->assertSuccessful();
|
||||
|
||||
return Organization::owned($owner)->firstOrFail();
|
||||
}
|
||||
|
||||
public function test_provision_enables_care_integration(): void
|
||||
{
|
||||
$owner = 'care-owner-uuid';
|
||||
|
||||
$this->postJson('/api/v1/integrations/provision', [
|
||||
'owner' => $owner,
|
||||
'organization_name' => 'Care Clinic',
|
||||
'branch_name' => 'Main',
|
||||
], $this->careHeaders($owner))
|
||||
->assertCreated()
|
||||
->assertJsonPath('data.integrations.care', true);
|
||||
|
||||
$organization = Organization::owned($owner)->first();
|
||||
$this->assertTrue((bool) data_get($organization->settings, 'integrations.care_enabled'));
|
||||
}
|
||||
|
||||
public function test_counters_allowed_after_care_provision(): void
|
||||
{
|
||||
$owner = 'care-owner-uuid';
|
||||
$headers = $this->careHeaders($owner);
|
||||
|
||||
$this->provisionCareOrg($owner);
|
||||
|
||||
$this->getJson('/api/v1/counters?owner='.$owner, $headers)
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
public function test_counter_console_resolves_by_uuid(): void
|
||||
{
|
||||
$owner = 'care-owner-uuid';
|
||||
$headers = $this->careHeaders($owner);
|
||||
$organization = $this->provisionCareOrg($owner);
|
||||
$branch = Branch::owned($owner)->where('organization_id', $organization->id)->firstOrFail();
|
||||
$queue = ServiceQueue::create([
|
||||
'owner_ref' => $owner,
|
||||
'organization_id' => $organization->id,
|
||||
'branch_id' => $branch->id,
|
||||
'name' => 'Morning Shift',
|
||||
'prefix' => 'A',
|
||||
'strategy' => 'fifo',
|
||||
'is_active' => true,
|
||||
]);
|
||||
$counter = Counter::create([
|
||||
'owner_ref' => $owner,
|
||||
'organization_id' => $organization->id,
|
||||
'branch_id' => $branch->id,
|
||||
'name' => 'Counter 1',
|
||||
'code' => 'C001',
|
||||
'status' => 'available',
|
||||
'is_active' => true,
|
||||
]);
|
||||
$counter->serviceQueues()->sync([$queue->id]);
|
||||
|
||||
$this->getJson('/api/v1/counters/'.$counter->uuid.'/console?owner='.$owner, $headers)
|
||||
->assertOk()
|
||||
->assertJsonPath('data.counter.uuid', $counter->uuid);
|
||||
}
|
||||
|
||||
public function test_queue_models_use_uuid_route_key(): void
|
||||
{
|
||||
$this->assertSame('uuid', (new Counter)->getRouteKeyName());
|
||||
$this->assertSame('uuid', (new ServiceQueue)->getRouteKeyName());
|
||||
}
|
||||
|
||||
public function test_care_can_create_queue_and_counter_idempotently(): void
|
||||
{
|
||||
$owner = 'care-owner-uuid';
|
||||
$headers = $this->careHeaders($owner);
|
||||
$this->provisionCareOrg($owner);
|
||||
|
||||
$queueResponse = $this->postJson('/api/v1/queues', [
|
||||
'owner' => $owner,
|
||||
'name' => 'Dentistry',
|
||||
'prefix' => 'DEN',
|
||||
'branch_name' => 'Main',
|
||||
'external_key' => 'care:specialty:dentistry:queue:1',
|
||||
'strategy' => 'fifo',
|
||||
], $headers)
|
||||
->assertCreated()
|
||||
->assertJsonPath('data.name', 'Dentistry')
|
||||
->assertJsonPath('data.external_key', 'care:specialty:dentistry:queue:1');
|
||||
|
||||
$queueUuid = $queueResponse->json('data.uuid');
|
||||
|
||||
$this->postJson('/api/v1/queues', [
|
||||
'owner' => $owner,
|
||||
'name' => 'Dentistry Desk',
|
||||
'prefix' => 'DEN',
|
||||
'branch_name' => 'Main',
|
||||
'external_key' => 'care:specialty:dentistry:queue:1',
|
||||
'strategy' => 'fifo',
|
||||
], $headers)
|
||||
->assertOk()
|
||||
->assertJsonPath('data.uuid', $queueUuid)
|
||||
->assertJsonPath('data.name', 'Dentistry Desk');
|
||||
|
||||
$this->assertSame(1, ServiceQueue::owned($owner)->count());
|
||||
|
||||
$counterResponse = $this->postJson('/api/v1/counters', [
|
||||
'owner' => $owner,
|
||||
'name' => 'Dentistry counter',
|
||||
'branch_name' => 'Main',
|
||||
'queue_uuids' => [$queueUuid],
|
||||
'external_key' => 'care:specialty:dentistry:counter:1',
|
||||
], $headers)
|
||||
->assertCreated()
|
||||
->assertJsonPath('data.name', 'Dentistry counter')
|
||||
->assertJsonPath('data.branch', 'Main')
|
||||
->assertJsonPath('data.queues.0.uuid', $queueUuid);
|
||||
|
||||
$counterUuid = $counterResponse->json('data.uuid');
|
||||
|
||||
$this->postJson('/api/v1/counters', [
|
||||
'owner' => $owner,
|
||||
'name' => 'Dentistry counter',
|
||||
'branch_name' => 'Main',
|
||||
'queue_uuids' => [$queueUuid],
|
||||
'external_key' => 'care:specialty:dentistry:counter:1',
|
||||
], $headers)
|
||||
->assertOk()
|
||||
->assertJsonPath('data.uuid', $counterUuid);
|
||||
|
||||
$this->assertSame(1, Counter::owned($owner)->count());
|
||||
|
||||
$this->getJson('/api/v1/counters?owner='.$owner, $headers)
|
||||
->assertOk()
|
||||
->assertJsonPath('data.0.uuid', $counterUuid)
|
||||
->assertJsonPath('data.0.branch', 'Main')
|
||||
->assertJsonPath('data.0.queues.0.name', 'Dentistry Desk');
|
||||
}
|
||||
|
||||
public function test_care_can_soft_deactivate_counter(): void
|
||||
{
|
||||
$owner = 'care-owner-uuid';
|
||||
$headers = $this->careHeaders($owner);
|
||||
$organization = $this->provisionCareOrg($owner);
|
||||
$branch = Branch::owned($owner)->where('organization_id', $organization->id)->firstOrFail();
|
||||
$counter = Counter::create([
|
||||
'owner_ref' => $owner,
|
||||
'organization_id' => $organization->id,
|
||||
'branch_id' => $branch->id,
|
||||
'name' => 'Eye care counter',
|
||||
'status' => 'offline',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->patchJson('/api/v1/counters/'.$counter->uuid, [
|
||||
'owner' => $owner,
|
||||
'is_active' => false,
|
||||
], $headers)
|
||||
->assertOk()
|
||||
->assertJsonPath('data.is_active', false);
|
||||
|
||||
$this->assertFalse($counter->fresh()->is_active);
|
||||
$this->assertDatabaseHas('queue_counters', ['id' => $counter->id]);
|
||||
}
|
||||
|
||||
public function test_care_can_ensure_branch_by_name_idempotently(): void
|
||||
{
|
||||
$owner = 'care-owner-uuid';
|
||||
$headers = $this->careHeaders($owner);
|
||||
$this->provisionCareOrg($owner);
|
||||
|
||||
// Free plan is capped at 1 branch; provision already created Main — upsert must not duplicate.
|
||||
$this->postJson('/api/v1/branches', [
|
||||
'owner' => $owner,
|
||||
'name' => 'Main',
|
||||
], $headers)
|
||||
->assertOk()
|
||||
->assertJsonPath('data.name', 'Main')
|
||||
->assertJsonPath('data.is_active', true);
|
||||
|
||||
$this->assertSame(1, Branch::owned($owner)->count());
|
||||
}
|
||||
|
||||
public function test_care_can_issue_ticket_via_service_api(): void
|
||||
{
|
||||
$owner = 'care-owner-uuid';
|
||||
$headers = $this->careHeaders($owner);
|
||||
$this->provisionCareOrg($owner);
|
||||
|
||||
$queueUuid = $this->postJson('/api/v1/queues', [
|
||||
'owner' => $owner,
|
||||
'name' => 'Consultation',
|
||||
'prefix' => 'C',
|
||||
'branch_name' => 'Main',
|
||||
'external_key' => 'care:dept:consultation:queue:1',
|
||||
'strategy' => 'fifo',
|
||||
], $headers)->assertCreated()->json('data.uuid');
|
||||
|
||||
$this->postJson('/api/v1/tickets', [
|
||||
'owner' => $owner,
|
||||
'service_queue_id' => $queueUuid,
|
||||
'customer_name' => 'Ada Patient',
|
||||
'source' => 'appointment',
|
||||
'metadata' => [
|
||||
'care_entity' => 'appointment',
|
||||
'care_entity_id' => 42,
|
||||
],
|
||||
], $headers)
|
||||
->assertCreated()
|
||||
->assertJsonPath('data.ticket_number', 'C001')
|
||||
->assertJsonPath('data.status', 'waiting')
|
||||
->assertJsonPath('data.customer_name', 'Ada Patient');
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ class DemoSeedCommandTest extends TestCase
|
||||
$this->assertTrue(
|
||||
Member::query()
|
||||
->where('owner_ref', $user->public_id)
|
||||
->where('user_ref', 'demo-pro-receptionist@ladill.com')
|
||||
->where('user_ref', 'demo-pro-queue@ladill.com')
|
||||
->where('role', 'receptionist')
|
||||
->exists()
|
||||
);
|
||||
|
||||
@@ -23,12 +23,13 @@ class IndustryPackageTest extends TestCase
|
||||
{
|
||||
$registry = app(IndustryPackageRegistry::class);
|
||||
|
||||
$this->assertTrue($registry->has('healthcare'));
|
||||
$this->assertTrue($registry->has('banking'));
|
||||
$this->assertTrue($registry->has('vehicle'));
|
||||
$this->assertTrue($registry->has('restaurant'));
|
||||
$this->assertTrue($registry->has('custom'));
|
||||
$this->assertSame('Healthcare', $registry->get('healthcare')->label());
|
||||
$this->assertSame('patient', $registry->get('healthcare')->ticketEntity());
|
||||
$this->assertSame('Banking', $registry->get('banking')->label());
|
||||
$this->assertSame('customer', $registry->get('banking')->ticketEntity());
|
||||
$this->assertSame('vehicle', $registry->get('vehicle')->ticketEntity());
|
||||
$this->assertSame('order', $registry->get('restaurant')->ticketEntity());
|
||||
}
|
||||
|
||||
@@ -76,18 +77,18 @@ class IndustryPackageTest extends TestCase
|
||||
$this->assertGreaterThanOrEqual(3, $workflow->steps()->count());
|
||||
}
|
||||
|
||||
public function test_healthcare_uses_assigned_only_for_consultation(): void
|
||||
public function test_vehicle_uses_assigned_only_for_mechanic(): void
|
||||
{
|
||||
$user = User::create([
|
||||
'public_id' => 'pkg-care-owner',
|
||||
'name' => 'Clinic Owner',
|
||||
'email' => 'clinic-owner@example.com',
|
||||
'public_id' => 'pkg-vehicle-owner',
|
||||
'name' => 'Garage Owner',
|
||||
'email' => 'garage-owner@example.com',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
|
||||
// Pro plan so all healthcare stages fit under queue caps.
|
||||
// Pro plan so all vehicle stages fit under queue caps.
|
||||
$org = app(OrganizationResolver::class)->completeOnboarding($user, [
|
||||
'organization_name' => 'Ridge Clinic',
|
||||
'organization_name' => 'Ridge Motors',
|
||||
'industry' => 'custom',
|
||||
'appointment_mode' => 'hybrid',
|
||||
'branch_name' => 'Main',
|
||||
@@ -101,19 +102,19 @@ class IndustryPackageTest extends TestCase
|
||||
]);
|
||||
|
||||
$branch = Branch::where('organization_id', $org->id)->first();
|
||||
$result = app(IndustryPackageInstaller::class)->install($org->fresh(), $branch, 'healthcare');
|
||||
$result = app(IndustryPackageInstaller::class)->install($org->fresh(), $branch, 'vehicle');
|
||||
|
||||
$this->assertSame('healthcare', $result['package']);
|
||||
$this->assertSame('vehicle', $result['package']);
|
||||
$this->assertGreaterThanOrEqual(5, $result['stages']);
|
||||
|
||||
$consultation = ServiceQueue::query()
|
||||
$mechanic = ServiceQueue::query()
|
||||
->where('organization_id', $org->id)
|
||||
->where('settings->stage_code', 'consultation')
|
||||
->where('settings->stage_code', 'mechanic')
|
||||
->first();
|
||||
|
||||
$this->assertNotNull($consultation);
|
||||
$this->assertSame('assigned_only', $consultation->routingMode());
|
||||
$this->assertSame('C', $consultation->prefix);
|
||||
$this->assertNotNull($mechanic);
|
||||
$this->assertSame('assigned_only', $mechanic->routingMode());
|
||||
$this->assertSame('M', $mechanic->prefix);
|
||||
}
|
||||
|
||||
public function test_package_install_is_idempotent(): void
|
||||
@@ -182,38 +183,6 @@ class IndustryPackageTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_care_integration_skips_stage_materialization(): void
|
||||
{
|
||||
$user = User::create([
|
||||
'public_id' => 'pkg-care-skip',
|
||||
'name' => 'Care Skip',
|
||||
'email' => 'care-skip@example.com',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
|
||||
$org = app(OrganizationResolver::class)->completeOnboarding($user, [
|
||||
'organization_name' => 'Care Linked',
|
||||
'industry' => 'custom',
|
||||
'appointment_mode' => 'hybrid',
|
||||
'branch_name' => 'Main',
|
||||
'timezone' => 'UTC',
|
||||
]);
|
||||
$org->update([
|
||||
'settings' => array_merge($org->settings ?? [], [
|
||||
'integrations' => ['care_enabled' => true],
|
||||
]),
|
||||
]);
|
||||
$before = ServiceQueue::where('organization_id', $org->id)->count();
|
||||
$branch = Branch::where('organization_id', $org->id)->first();
|
||||
|
||||
$result = app(IndustryPackageInstaller::class)->install($org->fresh(), $branch, 'healthcare');
|
||||
|
||||
$this->assertSame('stages_managed_by_integration', $result['skipped_reason']);
|
||||
$this->assertSame(0, $result['stages']);
|
||||
$this->assertSame($before, ServiceQueue::where('organization_id', $org->id)->count());
|
||||
$this->assertSame('patient', data_get($org->fresh()->settings, 'industry_package.ticket_entity'));
|
||||
}
|
||||
|
||||
public function test_replace_install_clears_previous_queues_and_tickets(): void
|
||||
{
|
||||
$user = User::create([
|
||||
|
||||
@@ -39,7 +39,7 @@ class ServicePointRoutingTest extends TestCase
|
||||
]);
|
||||
$org = app(OrganizationResolver::class)->completeOnboarding($user, [
|
||||
'organization_name' => 'Clinic',
|
||||
'industry' => 'healthcare',
|
||||
'industry' => 'banking',
|
||||
'appointment_mode' => 'hybrid',
|
||||
'branch_name' => 'Main',
|
||||
'timezone' => 'UTC',
|
||||
@@ -354,18 +354,18 @@ class ServicePointRoutingTest extends TestCase
|
||||
$this->assertSame($third->id, $engine->waitingTickets($queue)[0]->id);
|
||||
}
|
||||
|
||||
public function test_care_api_can_issue_assigned_ticket(): void
|
||||
public function test_frontdesk_api_can_issue_assigned_ticket(): void
|
||||
{
|
||||
config(['qms.service_api_keys.care' => 'test-care-key']);
|
||||
$owner = 'care-sp-owner';
|
||||
config(['qms.service_api_keys.frontdesk' => 'test-frontdesk-key']);
|
||||
$owner = 'frontdesk-sp-owner';
|
||||
$headers = [
|
||||
'Authorization' => 'Bearer test-care-key',
|
||||
'Authorization' => 'Bearer test-frontdesk-key',
|
||||
'Accept' => 'application/json',
|
||||
];
|
||||
|
||||
$this->postJson('/api/v1/integrations/provision', [
|
||||
'owner' => $owner,
|
||||
'organization_name' => 'Care Clinic',
|
||||
'organization_name' => 'Visitor Desk',
|
||||
'branch_name' => 'Main',
|
||||
], $headers)->assertSuccessful();
|
||||
|
||||
@@ -374,7 +374,7 @@ class ServicePointRoutingTest extends TestCase
|
||||
'name' => 'Consultation',
|
||||
'prefix' => 'C',
|
||||
'branch_name' => 'Main',
|
||||
'external_key' => 'care:dept:consultation:queue:1',
|
||||
'external_key' => 'frontdesk:dept:consultation:queue:1',
|
||||
'routing_mode' => 'assigned_only',
|
||||
], $headers)->assertCreated()->json('data.uuid');
|
||||
|
||||
@@ -385,7 +385,7 @@ class ServicePointRoutingTest extends TestCase
|
||||
'staff_display_name' => 'Dr. Mensah',
|
||||
'branch_name' => 'Main',
|
||||
'queue_uuids' => [$queueUuid],
|
||||
'external_key' => 'care:point:consultation:practitioner:9',
|
||||
'external_key' => 'frontdesk:point:consultation:practitioner:9',
|
||||
], $headers)->assertCreated()->json('data.uuid');
|
||||
|
||||
$this->postJson('/api/v1/tickets', [
|
||||
|
||||
@@ -59,7 +59,7 @@ class SettingsBranchesTeamTest extends TestCase
|
||||
'appointment_mode' => 'walk_in_only',
|
||||
'industry' => 'retail',
|
||||
'notifications_enabled' => '1',
|
||||
'care_integration_enabled' => '1',
|
||||
'frontdesk_integration_enabled' => '1',
|
||||
])
|
||||
->assertRedirect()
|
||||
->assertSessionHas('success');
|
||||
@@ -68,7 +68,7 @@ class SettingsBranchesTeamTest extends TestCase
|
||||
$this->assertSame('Settings Org Updated', $this->organization->name);
|
||||
$this->assertSame('Africa/Accra', $this->organization->timezone);
|
||||
$this->assertSame('walk_in_only', data_get($this->organization->settings, 'appointment_mode'));
|
||||
$this->assertTrue((bool) data_get($this->organization->settings, 'integrations.care_enabled'));
|
||||
$this->assertTrue((bool) data_get($this->organization->settings, 'integrations.frontdesk_enabled'));
|
||||
}
|
||||
|
||||
public function test_settings_page_does_not_nest_reinstall_form(): void
|
||||
|
||||
@@ -45,7 +45,7 @@ class TicketTransferProTest extends TestCase
|
||||
|
||||
$this->organization = app(OrganizationResolver::class)->completeOnboarding($this->owner, [
|
||||
'organization_name' => 'Transfer Org',
|
||||
'industry' => 'healthcare',
|
||||
'industry' => 'banking',
|
||||
'appointment_mode' => 'hybrid',
|
||||
'branch_name' => 'Main',
|
||||
'timezone' => 'UTC',
|
||||
|
||||
Reference in New Issue
Block a user