Deploy Ladill POS / deploy (push) Successful in 32s
Finish removing the upstream platform fork: drop the Hosting/SSL/Domain notification classes + their mail views, the email/mailbox/domains/hosting view trees, the Mini/Afia/search/paystack partials and unused components, and the now-orphan support helpers (DomainConfig, MailboxPricing, ResellerClubLegacy), SmsService, and fork configs (afia, hosting, domain, email, mailbox, qr, mail_brands, notifications, ...). Reparent the notifications page off the hosting layout onto the POS app layout (it had referenced undefined hosting./mini. routes). Computed the removable set from a reachability scan of the POS view graph; kept views reference no removed routes/services. Branding: favicon now uses the updated favicon.ico (favicon.svg removed); signed-out fallback logo points at the POS logo. CRM import: constrain the catalogue pull to type=product so CRM services are never imported as POS products (server-side filter + defensive client skip). Test suite green (8 passed, 29 assertions); all routes resolve and every remaining Blade compiles. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
111 lines
3.2 KiB
PHP
111 lines
3.2 KiB
PHP
<?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.ico', 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);
|
|
}
|
|
}
|