Add Ladill POS v1 — register, Pay checkout, and commerce links.
Deploy Ladill Mini / deploy (push) Successful in 23s
Deploy Ladill Mini / deploy (push) Successful in 23s
Staff-facing counter register at pos.ladill.com with catalog cart, cash and MoMo/card checkout via Ladill Pay, CRM timeline/import, invoice prefill, and Merchant catalog import. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Http\Middleware\EnsurePlatformSession;
|
||||
use App\Models\PosProduct;
|
||||
use App\Models\PosSale;
|
||||
use App\Models\User;
|
||||
use App\Services\Pay\PayClient;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PosRegisterTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private function user(): User
|
||||
{
|
||||
return User::create([
|
||||
'public_id' => 'u-'.uniqid(),
|
||||
'name' => 'Cashier',
|
||||
'email' => uniqid().'@example.com',
|
||||
]);
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->withoutMiddleware(EnsurePlatformSession::class);
|
||||
$this->withoutVite();
|
||||
|
||||
config([
|
||||
'crm.url' => 'https://crm.test/api',
|
||||
'crm.key' => 'test-crm-key',
|
||||
]);
|
||||
|
||||
Http::fake([
|
||||
'crm.test/api/customers*' => Http::response(['data' => []], 200),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_dashboard_renders_for_signed_in_user(): void
|
||||
{
|
||||
$this->actingAs($this->user())
|
||||
->get(route('pos.dashboard'))
|
||||
->assertOk()
|
||||
->assertSee('Overview')
|
||||
->assertSee('favicon.svg', false);
|
||||
}
|
||||
|
||||
public function test_register_renders_products(): void
|
||||
{
|
||||
$user = $this->user();
|
||||
PosProduct::create([
|
||||
'owner_ref' => $user->public_id,
|
||||
'name' => 'Coffee',
|
||||
'price_minor' => 1500,
|
||||
'currency' => 'GHS',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('pos.register'))
|
||||
->assertOk()
|
||||
->assertSee('Coffee');
|
||||
}
|
||||
|
||||
public function test_cash_sale_is_recorded(): void
|
||||
{
|
||||
$user = $this->user();
|
||||
|
||||
$this->actingAs($user)->post(route('pos.register.charge'), [
|
||||
'payment_method' => 'cash',
|
||||
'lines' => [
|
||||
['name' => 'Tea', 'unit_price_minor' => 1000, 'quantity' => 2],
|
||||
],
|
||||
])->assertRedirect();
|
||||
|
||||
$sale = PosSale::where('owner_ref', $user->public_id)->first();
|
||||
$this->assertNotNull($sale);
|
||||
$this->assertSame(PosSale::STATUS_PAID, $sale->status);
|
||||
$this->assertSame(PosSale::METHOD_CASH, $sale->payment_method);
|
||||
$this->assertSame(2000, $sale->total_minor);
|
||||
}
|
||||
|
||||
public function test_pay_sale_redirects_to_checkout(): void
|
||||
{
|
||||
$user = $this->user();
|
||||
|
||||
$this->mock(PayClient::class, function ($mock) {
|
||||
$mock->shouldReceive('createCheckout')->once()->andReturn([
|
||||
'id' => 99,
|
||||
'reference' => 'LP-TESTREF',
|
||||
'checkout_url' => 'https://checkout.paystack.com/test',
|
||||
]);
|
||||
});
|
||||
|
||||
$this->actingAs($user)->post(route('pos.register.charge'), [
|
||||
'payment_method' => 'pay',
|
||||
'lines' => [
|
||||
['name' => 'Snack', 'unit_price_minor' => 500, 'quantity' => 1],
|
||||
],
|
||||
])->assertRedirect('https://checkout.paystack.com/test');
|
||||
|
||||
$sale = PosSale::where('owner_ref', $user->public_id)->first();
|
||||
$this->assertSame('LP-TESTREF', $sale->payment_reference);
|
||||
$this->assertSame(PosSale::STATUS_PENDING, $sale->status);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user